diff options
| author | Rhed Jao <rhedjao@google.com> | 2019-08-16 19:00:28 +0800 |
|---|---|---|
| committer | Rhed Jao <rhedjao@google.com> | 2019-08-16 19:07:13 +0800 |
| commit | 85292932319db139f5130b8a9ff0ac2067663db3 (patch) | |
| tree | f39b92564bb99dec63913bf5513a6bd7157700b8 /core/java/android | |
| parent | 0175dd803ac226f587cff006d8e0440af30be69f (diff) | |
More logs for UiAutomation
Test: atest UiAutomationTest
Bug: 134536201
Change-Id: Ibab34b1908143d894076abf5d9f3692bc03c70db
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/UiAutomation.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/core/java/android/app/UiAutomation.java b/core/java/android/app/UiAutomation.java index ed2b99187b95..f9b96c50e0b8 100644 --- a/core/java/android/app/UiAutomation.java +++ b/core/java/android/app/UiAutomation.java @@ -242,7 +242,7 @@ public final class UiAutomation { mUiAutomationConnection.connect(mClient, flags); mFlags = flags; } catch (RemoteException re) { - throw new RuntimeException("Error while connecting UiAutomation", re); + throw new RuntimeException("Error while connecting " + this, re); } synchronized (mLock) { @@ -255,7 +255,7 @@ public final class UiAutomation { final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis; final long remainingTimeMillis = CONNECT_TIMEOUT_MILLIS - elapsedTimeMillis; if (remainingTimeMillis <= 0) { - throw new RuntimeException("Error while connecting UiAutomation"); + throw new RuntimeException("Error while connecting " + this); } try { mLock.wait(remainingTimeMillis); @@ -290,7 +290,7 @@ public final class UiAutomation { synchronized (mLock) { if (mIsConnecting) { throw new IllegalStateException( - "Cannot call disconnect() while connecting!"); + "Cannot call disconnect() while connecting " + this); } throwIfNotConnectedLocked(); mConnectionId = CONNECTION_ID_UNDEFINED; @@ -299,7 +299,7 @@ public final class UiAutomation { // Calling out without a lock held. mUiAutomationConnection.disconnect(); } catch (RemoteException re) { - throw new RuntimeException("Error while disconnecting UiAutomation", re); + throw new RuntimeException("Error while disconnecting " + this, re); } finally { mRemoteCallbackThread.quit(); mRemoteCallbackThread = null; @@ -1184,19 +1184,29 @@ public final class UiAutomation { return result; } + @Override + public String toString() { + final StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("UiAutomation@").append(Integer.toHexString(hashCode())); + stringBuilder.append("[id=").append(mConnectionId); + stringBuilder.append(", flags=").append(mFlags); + stringBuilder.append("]"); + return stringBuilder.toString(); + } + private boolean isConnectedLocked() { return mConnectionId != CONNECTION_ID_UNDEFINED; } private void throwIfConnectedLocked() { if (mConnectionId != CONNECTION_ID_UNDEFINED) { - throw new IllegalStateException("UiAutomation not connected!"); + throw new IllegalStateException("UiAutomation not connected, " + this); } } private void throwIfNotConnectedLocked() { if (!isConnectedLocked()) { - throw new IllegalStateException("UiAutomation not connected!"); + throw new IllegalStateException("UiAutomation not connected, " + this); } } @@ -1220,6 +1230,9 @@ public final class UiAutomation { mConnectionId = connectionId; mLock.notifyAll(); } + if (Build.IS_DEBUGGABLE) { + Log.v(LOG_TAG, "Init " + UiAutomation.this); + } } @Override |
