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

Commit e55224ba authored by Kyrylo Mikos's avatar Kyrylo Mikos Committed by Michael Bestas
Browse files

BluetoothManagerService: fix enabling/disabling BT from Quictsettings under second user,

Change-Id: I8173559b2c734968ef4a8d86fddaa3a73d5c2b1e
(cherry picked from commit fe625c56)
parent 29fbca6b
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
    private static final String SECURE_SETTINGS_BLUETOOTH_ADDR_VALID="bluetooth_addr_valid";
    private static final String SECURE_SETTINGS_BLUETOOTH_ADDRESS="bluetooth_address";
    private static final String SECURE_SETTINGS_BLUETOOTH_NAME="bluetooth_name";
    private static final String SYSTEMUI_PACKAGE_NAME="com.android.systemui";
    private static final int TIMEOUT_BIND_MS = 3000; //Maximum msec to wait for a bind
    private static final int TIMEOUT_SAVE_MS = 500; //Maximum msec to wait for a save
    //Maximum msec to wait for service restart
@@ -1110,11 +1111,20 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
        int callingUid = Binder.getCallingUid();
        long callingIdentity = Binder.clearCallingIdentity();
        int callingAppId = UserHandle.getAppId(callingUid);
        String[] packages = mContext.getPackageManager().getPackagesForUid(callingUid);
        boolean isSystemUi = false;
        for (String p : packages) {
            if (SYSTEMUI_PACKAGE_NAME.equals(p)) {
                isSystemUi = true;
                break;
            }
        }
        boolean valid = false;
        try {
            foregroundUser = ActivityManager.getCurrentUser();
            valid = (callingUser == foregroundUser) ||
                    callingAppId == Process.NFC_UID;
            valid = (callingUser == foregroundUser)
                    || callingAppId == Process.NFC_UID
                    || isSystemUi;
            if (DBG) {
                Log.d(TAG, "checkIfCallerIsForegroundUser: valid=" + valid
                    + " callingUser=" + callingUser