Loading Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -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", Loading core/java/android/adb/ADBRootService.java 0 → 100644 +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(); } } } core/res/AndroidManifest.xml +7 −0 Original line number Diff line number Diff line Loading @@ -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" Loading Loading
Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -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", Loading
core/java/android/adb/ADBRootService.java 0 → 100644 +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(); } } }
core/res/AndroidManifest.xml +7 −0 Original line number Diff line number Diff line Loading @@ -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" Loading