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

Commit 3def1683 authored by Fabien Sanglard's avatar Fabien Sanglard
Browse files

Clarify ownership in AdbDebuggingManager

Variable mThread is managed and used by AdbDebuggingHandler. The handler
should be the owner of this variable.

Test: Manual
Bug: NA
Flag: EXEMPT(refactor)
Change-Id: I0ecb1cf1362bf20bcc56eb3149999ee528ecf6a7
parent b1880670
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import android.debug.AdbManager;
import android.debug.AdbNotifications;
import android.debug.AdbProtoEnums;
import android.debug.AdbTransportType;
import android.debug.IAdbTransport;
import android.debug.PairDevice;
import android.net.ConnectivityManager;
import android.net.LocalSocket;
@@ -145,7 +144,6 @@ public class AdbDebuggingManager {
    private final Context mContext;
    private final ContentResolver mContentResolver;
    @VisibleForTesting final AdbDebuggingHandler mHandler;
    @Nullable private AdbDebuggingThread mThread;
    private boolean mAdbUsbEnabled = false;
    private boolean mAdbWifiEnabled = false;
    private String mFingerprints;
@@ -200,9 +198,8 @@ public class AdbDebuggingManager {
        mConfirmComponent = confirmComponent;
        mUserKeyFile = testUserKeyFile;
        mTempKeysFile = tempKeysFile;
        mThread = adbDebuggingThread;
        mTicker = ticker;
        mHandler = new AdbDebuggingHandler(FgThread.get().getLooper(), mThread);
        mHandler = new AdbDebuggingHandler(FgThread.get().getLooper(), adbDebuggingThread);
    }

    static void sendBroadcastWithDebugPermission(@NonNull Context context, @NonNull Intent intent,
@@ -804,6 +801,8 @@ public class AdbDebuggingManager {
        // connection unless all transport types are disconnected.
        private int mAdbEnabledRefCount = 0;

        @Nullable private AdbDebuggingThread mThread;

        private ContentObserver mAuthTimeObserver = new ContentObserver(this) {
            @Override
            public void onChange(boolean selfChange, Uri uri) {
@@ -1794,7 +1793,10 @@ public class AdbDebuggingManager {
    public void dump(DualDumpOutputStream dump, String idName, long id) {
        long token = dump.start(idName, id);

        dump.write("connected_to_adb", AdbDebuggingManagerProto.CONNECTED_TO_ADB, mThread != null);
        dump.write(
                "connected_to_adb",
                AdbDebuggingManagerProto.CONNECTED_TO_ADB,
                mHandler.mThread != null);
        writeStringIfNotNull(dump, "last_key_received", AdbDebuggingManagerProto.LAST_KEY_RECEVIED,
                mFingerprints);