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

Commit 7f2303f3 authored by Luca Stefani's avatar Luca Stefani
Browse files

Expose the ADBRoot interface to priv-apps

Change-Id: I493f3322b19b6474bf8899a103156794ef412ae2
parent b978e884
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -671,6 +671,8 @@ java_defaults {
        ":dumpstate_aidl",
        ":incidentcompanion_aidl",

        ":adbrootservice_aidl",

        "lowpan/java/android/net/lowpan/ILowpanEnergyScanCallback.aidl",
        "lowpan/java/android/net/lowpan/ILowpanNetScanCallback.aidl",
        "lowpan/java/android/net/lowpan/ILowpanInterfaceListener.aidl",
+71 −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.
 */

package android.adb;

import android.adbroot.IADBRootService;
import android.annotation.SystemApi;
import android.content.Context;
import android.os.RemoteException;
import android.os.ServiceManager;

/**
 * {@hide}
 */
@SystemApi
public class ADBRootService {
    private static final String TAG = "ADBRootService";

    private static final String ADB_ROOT_SERVICE = "adbroot_service";

    private IADBRootService mADBRootService;
    private Context mContext;

    /**
     * Creates a new instance.
     */
    public ADBRootService(Context context) {
        mADBRootService = IADBRootService.Stub.asInterface(
                ServiceManager.getService(ADB_ROOT_SERVICE));
        mContext = context;
    }

    /**
     * @hide
     */
    public void setEnabled(boolean enable) {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.ADBROOT, "adbroot");
        try {
            mADBRootService.setEnabled(enable);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @hide
     */
    public boolean getEnabled() {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.ADBROOT, "adbroot");
        try {
            return mADBRootService.getEnabled();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -4609,6 +4609,13 @@
    <permission android:name="android.permission.PREVENT_POWER_KEY"
                android:protectionLevel="signature|privileged" />

    <!-- @SystemApi Allows an application to manage ADB Root
         @hide <p>Not for use by third-party applications.
    -->
    <permission android:name="android.permission.ADBROOT"
                android:protectionLevel="signature|privileged" />


    <application android:process="system"
                 android:persistent="true"
                 android:hasCode="false"