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

Commit 90a198a6 authored by Ivan Podogov's avatar Ivan Podogov
Browse files

resolve merge conflicts of 903d6414 to nyc-mr2-dev-plus-aosp

Test: Treehugger
Change-Id: Ie994c37011f6f4255ca681e4f0c0a99fa5c337fd
parents 0ca78d3f 903d6414
Loading
Loading
Loading
Loading
+25 −8
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@ import android.content.pm.UserInfo;
import android.database.ContentObserver;
import android.database.ContentObserver;
import android.os.Binder;
import android.os.Binder;
import android.os.Bundle;
import android.os.Bundle;
import android.os.Build;
import android.os.Handler;
import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder;
import android.os.Looper;
import android.os.Looper;
@@ -183,7 +184,12 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
            final boolean bluetoothDisallowed =
            final boolean bluetoothDisallowed =
                    newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH);
                    newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH);
            if ((mEnable || mEnableExternal) && bluetoothDisallowed) {
            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;
        return true;
    }
    }


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


        if ((Binder.getCallingUid() != Process.SYSTEM_UID) &&
        final int callingUid = Binder.getCallingUid();
            (!checkIfCallerIsForegroundUser())) {
        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");
                Slog.w(TAG, "enable(): not allowed for non-active and non system user");
                return false;
                return false;
            }
            }


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

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

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