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

Commit 30b78727 authored by Ivan Podogov's avatar Ivan Podogov
Browse files

resolve merge conflicts of 5f4cb939 to nyc-mr2-dev-plus-aosp

Test: Treehugger
Change-Id: Ie994c37011f6f4255ca681e4f0c0a99fa5c337fd
parents 1af8102e 5f4cb939
Loading
Loading
Loading
Loading
+25 −8
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.content.pm.UserInfo;
import android.database.ContentObserver;
import android.os.Binder;
import android.os.Bundle;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
@@ -183,7 +184,12 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
            final boolean bluetoothDisallowed =
                    newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH);
            if ((mEnable || mEnableExternal) && bluetoothDisallowed) {
                disable(true);
                try {
                  disable("android.os.UserManagerInternal", true);
                } catch (RemoteException e) {
                  // Shouldn't happen: startConsentUiIfNeeded not called
                  // when from system.
                }
            }
        }
    };
@@ -669,7 +675,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
        return true;
    }

    public boolean enable() {
    public boolean enable(String packageName) throws RemoteException {
        if (isBluetoothDisallowed()) {
            if (DBG) {
                Slog.d(TAG,"enable(): not enabling - bluetooth disallowed");
@@ -677,14 +683,25 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
            return false;
        }

        if ((Binder.getCallingUid() != Process.SYSTEM_UID) &&
            (!checkIfCallerIsForegroundUser())) {
        final int callingUid = Binder.getCallingUid();
        final boolean callerSystem = UserHandle.getAppId(callingUid) == Process.SYSTEM_UID;

        if (!callerSystem) {
            if (!checkIfCallerIsForegroundUser()) {
                Slog.w(TAG, "enable(): not allowed for non-active and non system user");
                return false;
            }

            mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                    "Need BLUETOOTH ADMIN permission");

            if (!isEnabled() && mPermissionReviewRequired
                    && startConsentUiIfNeeded(packageName, callingUid,
                            BluetoothAdapter.ACTION_REQUEST_ENABLE)) {
                return false;
            }
        }

        if (DBG) {
            Slog.d(TAG,"enable():  mBluetooth =" + mBluetooth +
                    " mBinding = " + mBinding + " mState = " + mState);