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

Commit e6bb09e3 authored by Luca Stefani's avatar Luca Stefani Committed by Michael Bestas
Browse files

Expose the ADBRoot interface to priv-apps

Author: Luca Stefani <luca.stefani.ge1@gmail.com>
    Expose the ADBRoot interface to priv-apps

    Change-Id: I493f3322b19b6474bf8899a103156794ef412ae2

Author: Luca Stefani <luca.stefani.ge1@gmail.com>
    Whitelist settings to use adb root permission

    Change-Id: I93122777c82fad33be04fcce002ba1a8468cacbe

Author: Michael Bestas <mkbestas@lineageos.org>
    Fix ADB root system API extension

    * Fixes checkapi:
      out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/current-apicheck/srcjars/android/Manifest.java:3435:
      error: Added field android.Manifest.permission.ADBROOT to the system API [AddedField]

      error: Added package android.adb to the system API [AddedPackage]

    Change-Id: Idd509c31d961a0b20fac8cccd2c83c6bf23c5a38

Author: dianlujitao <dianlujitao@lineageos.org>
    ADBRootService: Deal with binder death

    Change-Id: Id5e4a455ea16a4158086816abf093d8f603d4e49

Author: dianlujitao <dianlujitao@lineageos.org>
    ADBRootService: Remove redundant permission check

     * First of all, the check is performed in a helper class, one can
       easily bypass it by directly issuing the binder API.
     * On the other hand, enforceCallingOrSelfPermission allows root and
       system UID to do everything, i.e., any process running in system UID
       is allowed to pass the check, including Settings app, thus it's
       simply a no-op.

    Change-Id: I82f58d6165c2ef35c61047d5899de3e8ca6f7f39
parent 12920376
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",
+90 −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.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Slog;

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

    private static final String ADB_ROOT_SERVICE = "adbroot_service";

    private IADBRootService mService;

    private final IBinder.DeathRecipient mDeathRecipient = new IBinder.DeathRecipient() {
        @Override
        public void binderDied() {
            if (mService != null) {
                mService.asBinder().unlinkToDeath(this, 0);
            }
            mService = null;
        }
    };

    private synchronized IADBRootService getService()
            throws RemoteException {
        if (mService != null) {
            return mService;
        }

        final IBinder service = ServiceManager.getService(ADB_ROOT_SERVICE);
        if (service != null) {
            service.linkToDeath(mDeathRecipient, 0);
            mService = IADBRootService.Stub.asInterface(service);
            return mService;
        }

        Slog.e(TAG, "Unable to acquire ADBRootService");
        return null;
    }

    /**
     * @hide
     */
    public void setEnabled(boolean enable) {
        try {
            final IADBRootService svc = getService();
            if (svc != null) {
                svc.setEnabled(enable);
            }
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @hide
     */
    public boolean getEnabled() {
        try {
            final IADBRootService svc = getService();
            if (svc != null) {
                return svc.getEnabled();
            }
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        return false;
    }
}