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

Commit 9e7b06ef authored by Michael Groover's avatar Michael Groover
Browse files

Revoke 'always allow' adb grants after period of inactivity

Bug: 111656592
Change-Id: I679078dc3e8f61f33ca0922a47777eedb6a933de
Fixes: 116512306
Test: atest AdbDebuggingManagerTest
parent f1cef973
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import "frameworks/base/core/proto/android/app/job/enums.proto";
import "frameworks/base/core/proto/android/bluetooth/enums.proto";
import "frameworks/base/core/proto/android/bluetooth/hci/enums.proto";
import "frameworks/base/core/proto/android/bluetooth/hfp/enums.proto";
import "frameworks/base/core/proto/android/debug/enums.proto";
import "frameworks/base/core/proto/android/net/networkcapabilities.proto";
import "frameworks/base/core/proto/android/os/enums.proto";
import "frameworks/base/core/proto/android/server/connectivity/data_stall_event.proto";
@@ -204,6 +205,7 @@ message Atom {
        SeOmapiReported se_omapi_reported = 141;
        BroadcastDispatchLatencyReported broadcast_dispatch_latency_reported = 142;
        AttentionManagerServiceResultReported attention_manager_service_result_reported = 143;
        AdbConnectionChanged adb_connection_changed = 144;
    }

    // Pulled events will start at field 10000.
@@ -4497,3 +4499,25 @@ message AttentionManagerServiceResultReported {
    }
    optional AttentionCheckResult attention_check_result = 1 [default = UNKNOWN];
}

/**
 * Logs when an adb connection changes state.
 *
 * Logged from:
 *     frameworks/base/services/core/java/com/android/server/adb/AdbDebuggingManager.java
 */
message AdbConnectionChanged {
    // The last time this system connected via adb, or 0 if the 'always allow' option was not
    // previously selected for this system.
    optional int64 last_connection_time_millis = 1;

    // The time in ms within which a subsequent connection from an 'always allow' system is allowed
    // to reconnect via adb without user interaction.
    optional int64 auth_window_millis = 2;

    // The state of the adb connection from frameworks/base/core/proto/android/debug/enums.proto.
    optional android.debug.AdbConnectionStateEnum state = 3;

    // True if the 'always allow' option was selected for this system.
    optional bool always_allow = 4;
}
+22 −0
Original line number Diff line number Diff line
@@ -11868,6 +11868,28 @@ public final class Settings {
         */
        public static final String KEEP_PROFILE_IN_BACKGROUND = "keep_profile_in_background";
        /**
         * The default time in ms within which a subsequent connection from an always allowed system
         * is allowed to reconnect without user interaction.
         *
         * @hide
         */
        public static final long DEFAULT_ADB_ALLOWED_CONNECTION_TIME = 604800000;
        /**
         * When the user first connects their device to a system a prompt is displayed to allow
         * the adb connection with an option to 'Always allow' connections from this system. If the
         * user selects this always allow option then the connection time is stored for the system.
         * This setting is the time in ms within which a subsequent connection from an always
         * allowed system is allowed to reconnect without user interaction.
         *
         * Type: long
         *
         * @hide
         */
        public static final String ADB_ALLOWED_CONNECTION_TIME =
                "adb_allowed_connection_time";
        /**
         * Get the key that retrieves a bluetooth headset's priority.
         * @hide
+67 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.
 */

syntax = "proto2";
package android.debug;

option java_outer_classname = "AdbProtoEnums";
option java_multiple_files = true;

/**
 * adb connection state used to track adb connection changes in AdbDebuggingManager.java.
 */
enum AdbConnectionStateEnum {
    UNKNOWN = 0;

    /**
     * The adb connection is waiting for approval from the user.
     */
    AWAITING_USER_APPROVAL = 1;

    /**
     * The user allowed the adb connection from the system.
     */
    USER_ALLOWED = 2;

    /**
     * The user denied the adb connection from the system.
     */
    USER_DENIED = 3;

    /**
     * The adb connection was automatically allowed without user interaction due to the system
     * being previously allowed by the user with the 'always allow' option selected, and the adb
     * grant has not yet expired.
     */
    AUTOMATICALLY_ALLOWED = 4;

    /**
     * An empty or invalid base64 encoded key was provided to the framework; the connection was
     * automatically denied.
     */
    DENIED_INVALID_KEY = 5;

    /**
     * vold decrypt has not yet occurred; the connection was automatically denied.
     */
    DENIED_VOLD_DECRYPT = 6;

    /**
     * The adb session has been disconnected.
     */
    DISCONNECTED = 7;
}
+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ public class SettingsBackupTest {
                    Settings.Global.ACTIVITY_MANAGER_CONSTANTS,
                    Settings.Global.ACTIVITY_STARTS_LOGGING_ENABLED,
                    Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED,
                    Settings.Global.ADB_ALLOWED_CONNECTION_TIME,
                    Settings.Global.ADB_ENABLED,
                    Settings.Global.ADD_USERS_WHEN_LOCKED,
                    Settings.Global.AIRPLANE_MODE_ON,
+402 −18

File changed.

Preview size limit exceeded, changes collapsed.

Loading