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

Commit 66d34345 authored by David Anderson's avatar David Anderson Committed by Paul Lawrence
Browse files

Introduce an ITradeInMode service.

This is used by the DeviceDiagnostics app to enter trade-in mode during setup wizard.

Bug: 307713521
Test: manual test
Flag: com.android.tradeinmode.flags.enable_trade_in_mode
Change-Id: Ib1b4b2979a17aa63ab5e45701ed038e348348f9a
parent 42cdae92
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ aconfig_declarations_group {
    java_aconfig_libraries: [
        // !!! KEEP THIS LIST ALPHABETICAL !!!
        "aconfig_mediacodec_flags_java_lib",
        "aconfig_trade_in_mode_flags_java_lib",
        "android-sdk-flags-java",
        "android.adaptiveauth.flags-aconfig-java",
        "android.app.appfunctions.flags-aconfig-java",
+62 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.os;

/** @hide */
interface ITradeInMode {
    /**
     * Enable adb in limited-privilege trade-in mode. Returns true if trade-in
     * mode was enabled.
     *
     * Trade-in mode can be enabled if the following conditions are all true:
     *   ro.debuggable is 0.
     *   Settings.Global.ADB_ENABLED is 0.
     *   Settings.Global.USER_SETUP_COMPLETE is 0.
     *   Settings.Secure.DEVICE_PROVISIONED is 0.
     *
     * It is stopped automatically when any of the following conditions become
     * true:
     *
     *   Settings.Global.USER_SETUP_COMPLETE is 1.
     *   Settings.Secure.DEVICE_PROVISIONED is 1.
     *   A change in network configuration occurs.
     *   An account is added.
     *
     * ENTER_TRADE_IN_MODE permission is required.
     */
    boolean start();

    /**
     * Returns whether evaluation mode is allowed on this device. It will return
     * false if any kind of device protection (such as FRP) is detected.
     *
     * ENTER_TRADE_IN_MODE permission is required.
     */
    boolean isEvaluationModeAllowed();

    /**
     * Enable full adb access and provision the device. This forces a factory
     * reset on the next boot.
     *
     * This will return false if start() was not called, if factory reset
     * protection is active, or if trade-in mode was disabled due to any of the
     * conditions listed above for start().
     *
     * ENTER_TRADE_IN_MODE permission is required.
     */
    boolean enterEvaluationMode();
}
+1 −0
Original line number Diff line number Diff line
@@ -169,6 +169,7 @@ android_app {
        "android.media.tv.flags-aconfig",
        "android.security.flags-aconfig",
        "com.android.hardware.input.input-aconfig",
        "aconfig_trade_in_mode_flags",
    ],
}

+8 −0
Original line number Diff line number Diff line
@@ -8464,6 +8464,14 @@
    <permission android:name="android.permission.SETUP_FSVERITY"
                android:protectionLevel="signature|privileged"/>

    <!-- Allows app to enter trade-in-mode.
        <p>Protection level: signature|privileged
        @hide
    -->
    <permission android:name="android.permission.ENTER_TRADE_IN_MODE"
                android:protectionLevel="signature|privileged"
                android:featureFlag="com.android.tradeinmode.flags.enable_trade_in_mode" />

    <!--
        @TestApi
        Signature permission reserved for testing. This should never be used to
+1 −0
Original line number Diff line number Diff line
@@ -659,5 +659,6 @@ applications that come with the platform
   <privapp-permissions package="com.android.devicediagnostics">
        <permission name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
        <permission name="android.permission.BATTERY_STATS"/>
        <permission name="android.permission.ENTER_TRADE_IN_MODE"/>
    </privapp-permissions>
</permissions>
Loading