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

Commit 1dc105ef authored by David Anderson's avatar David Anderson
Browse files

Allow ITradeInMode to be used on ro.debuggable builds.

If persist.adb.test_tradeinmode is 1, then trade-in mode is allowed on
ro.debuggable=1 builds.

Bug: 379970773
Test: adb shell tradeinmode testing start
Flag: com.android.tradeinmode.flags.enable_trade_in_mode
Change-Id: Id6ae7d53aadd5e65d87d18cb86040a5b185f1b78
parent f8ac9625
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -137,12 +137,13 @@ public final class TradeInModeService extends SystemService {
                Slog.i(TAG, "Not starting trade-in mode, device is setup.");
                return false;
            }
            if (SystemProperties.getInt("ro.debuggable", 0) == 1) {
            if (isDebuggable()) {
                if (!isForceEnabledForTesting()) {
                    // We don't want to force adbd into TIM on debug builds.
                    Slog.e(TAG, "Not starting trade-in mode, device is debuggable.");
                    return false;
                }
            if (isAdbEnabled()) {
            } else if (isAdbEnabled()) {
                Slog.e(TAG, "Not starting trade-in mode, adb is already enabled.");
                return false;
            }
@@ -234,6 +235,10 @@ public final class TradeInModeService extends SystemService {
        return SystemProperties.getInt("ro.debuggable", 0) == 1;
    }

    private boolean isForceEnabledForTesting() {
        return SystemProperties.getInt("persist.adb.test_tradeinmode", 0) == 1;
    }

    private boolean isAdbEnabled() {
        final ContentResolver cr = mContext.getContentResolver();
        return Settings.Global.getInt(cr, Settings.Global.ADB_ENABLED, 0) == 1;