Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85292932 authored by Rhed Jao's avatar Rhed Jao
Browse files

More logs for UiAutomation

Test: atest UiAutomationTest
Bug: 134536201
Change-Id: Ibab34b1908143d894076abf5d9f3692bc03c70db
parent 0175dd80
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ class UiAutomationManager {
                    mUiAutomationServiceOwner.unlinkToDeath(this, 0);
                    mUiAutomationServiceOwner = null;
                    destroyUiAutomationService();
                    Slog.v(LOG_TAG, "UiAutomation service owner died");
                }
            };