Loading services/core/java/com/android/server/BluetoothManagerService.java +19 −19 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.Manifest.permission.BLUETOOTH_CONNECT; import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.os.PowerExemptionManager.TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED; import static android.os.UserHandle.USER_SYSTEM; import static android.permission.PermissionCheckerManager.PERMISSION_HARD_DENIED; import android.Manifest; Loading Loading @@ -64,7 +65,6 @@ import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.IUserRestrictionsListener; import android.os.Looper; import android.os.Message; import android.os.PowerExemptionManager; Loading @@ -88,6 +88,9 @@ import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.DumpUtils; import com.android.internal.util.FrameworkStatsLog; import com.android.server.pm.UserManagerInternal; import com.android.server.pm.UserManagerInternal.UserRestrictionsListener; import com.android.server.pm.UserRestrictionsUtils; import java.io.FileDescriptor; import java.io.PrintWriter; Loading Loading @@ -262,34 +265,30 @@ class BluetoothManagerService extends IBluetoothManager.Stub { } }; private final IUserRestrictionsListener mUserRestrictionsListener = new IUserRestrictionsListener.Stub() { private final UserRestrictionsListener mUserRestrictionsListener = new UserRestrictionsListener() { @Override public void onUserRestrictionsChanged(int userId, Bundle newRestrictions, Bundle prevRestrictions) { final boolean newDisallowBluetoothSharing = newRestrictions .getBoolean(UserManager.DISALLOW_BLUETOOTH_SHARING, false); final boolean prevDisallowBluetoothSharing = prevRestrictions .getBoolean(UserManager.DISALLOW_BLUETOOTH_SHARING, false); if (newDisallowBluetoothSharing != prevDisallowBluetoothSharing) { if (UserRestrictionsUtils.restrictionsChanged(prevRestrictions, newRestrictions, UserManager.DISALLOW_BLUETOOTH_SHARING)) { updateOppLauncherComponentState(userId, newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH_SHARING)); } final boolean newDisallowBluetooth = newRestrictions .getBoolean(UserManager.DISALLOW_BLUETOOTH, false); final boolean prevDisallowBluetooth = prevRestrictions .getBoolean(UserManager.DISALLOW_BLUETOOTH, false); // DISALLOW_BLUETOOTH can only be set by DO or PO on the system user. final boolean isUserSystem = userId == UserHandle.SYSTEM.getIdentifier(); if (isUserSystem && newDisallowBluetooth != prevDisallowBluetooth) { if (isUserSystem && newDisallowBluetooth) { if (userId == USER_SYSTEM && UserRestrictionsUtils.restrictionsChanged(prevRestrictions, newRestrictions, UserManager.DISALLOW_BLUETOOTH)) { if (userId == USER_SYSTEM && newRestrictions.getBoolean( UserManager.DISALLOW_BLUETOOTH)) { updateOppLauncherComponentState(userId, true); // Sharing disallowed sendDisableMsg(BluetoothProtoEnums.ENABLE_DISABLE_REASON_DISALLOWED, mContext.getPackageName()); } else { updateOppLauncherComponentState(userId, newDisallowBluetoothSharing); updateOppLauncherComponentState(userId, newRestrictions.getBoolean( UserManager.DISALLOW_BLUETOOTH_SHARING)); } } } Loading Loading @@ -542,7 +541,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { if (!noHome) { PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class); systemUiUid = pm.getPackageUid(pm.getSystemUiServiceComponent().getPackageName(), MATCH_SYSTEM_ONLY, UserHandle.SYSTEM.getIdentifier()); MATCH_SYSTEM_ONLY, USER_SYSTEM); } if (systemUiUid >= 0) { Slog.d(TAG, "Detected SystemUiUid: " + Integer.toString(systemUiUid)); Loading Loading @@ -1397,8 +1396,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub { Slog.d(TAG, "Bluetooth boot completed"); } mAppOps = mContext.getSystemService(AppOpsManager.class); UserManager userManager = mContext.getSystemService(UserManager.class); userManager.addUserRestrictionsListener(mUserRestrictionsListener); UserManagerInternal userManagerInternal = LocalServices.getService(UserManagerInternal.class); userManagerInternal.addUserRestrictionsListener(mUserRestrictionsListener); final boolean isBluetoothDisallowed = isBluetoothDisallowed(); if (isBluetoothDisallowed) { return; Loading Loading
services/core/java/com/android/server/BluetoothManagerService.java +19 −19 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.Manifest.permission.BLUETOOTH_CONNECT; import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.os.PowerExemptionManager.TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED; import static android.os.UserHandle.USER_SYSTEM; import static android.permission.PermissionCheckerManager.PERMISSION_HARD_DENIED; import android.Manifest; Loading Loading @@ -64,7 +65,6 @@ import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.IUserRestrictionsListener; import android.os.Looper; import android.os.Message; import android.os.PowerExemptionManager; Loading @@ -88,6 +88,9 @@ import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.DumpUtils; import com.android.internal.util.FrameworkStatsLog; import com.android.server.pm.UserManagerInternal; import com.android.server.pm.UserManagerInternal.UserRestrictionsListener; import com.android.server.pm.UserRestrictionsUtils; import java.io.FileDescriptor; import java.io.PrintWriter; Loading Loading @@ -262,34 +265,30 @@ class BluetoothManagerService extends IBluetoothManager.Stub { } }; private final IUserRestrictionsListener mUserRestrictionsListener = new IUserRestrictionsListener.Stub() { private final UserRestrictionsListener mUserRestrictionsListener = new UserRestrictionsListener() { @Override public void onUserRestrictionsChanged(int userId, Bundle newRestrictions, Bundle prevRestrictions) { final boolean newDisallowBluetoothSharing = newRestrictions .getBoolean(UserManager.DISALLOW_BLUETOOTH_SHARING, false); final boolean prevDisallowBluetoothSharing = prevRestrictions .getBoolean(UserManager.DISALLOW_BLUETOOTH_SHARING, false); if (newDisallowBluetoothSharing != prevDisallowBluetoothSharing) { if (UserRestrictionsUtils.restrictionsChanged(prevRestrictions, newRestrictions, UserManager.DISALLOW_BLUETOOTH_SHARING)) { updateOppLauncherComponentState(userId, newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH_SHARING)); } final boolean newDisallowBluetooth = newRestrictions .getBoolean(UserManager.DISALLOW_BLUETOOTH, false); final boolean prevDisallowBluetooth = prevRestrictions .getBoolean(UserManager.DISALLOW_BLUETOOTH, false); // DISALLOW_BLUETOOTH can only be set by DO or PO on the system user. final boolean isUserSystem = userId == UserHandle.SYSTEM.getIdentifier(); if (isUserSystem && newDisallowBluetooth != prevDisallowBluetooth) { if (isUserSystem && newDisallowBluetooth) { if (userId == USER_SYSTEM && UserRestrictionsUtils.restrictionsChanged(prevRestrictions, newRestrictions, UserManager.DISALLOW_BLUETOOTH)) { if (userId == USER_SYSTEM && newRestrictions.getBoolean( UserManager.DISALLOW_BLUETOOTH)) { updateOppLauncherComponentState(userId, true); // Sharing disallowed sendDisableMsg(BluetoothProtoEnums.ENABLE_DISABLE_REASON_DISALLOWED, mContext.getPackageName()); } else { updateOppLauncherComponentState(userId, newDisallowBluetoothSharing); updateOppLauncherComponentState(userId, newRestrictions.getBoolean( UserManager.DISALLOW_BLUETOOTH_SHARING)); } } } Loading Loading @@ -542,7 +541,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { if (!noHome) { PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class); systemUiUid = pm.getPackageUid(pm.getSystemUiServiceComponent().getPackageName(), MATCH_SYSTEM_ONLY, UserHandle.SYSTEM.getIdentifier()); MATCH_SYSTEM_ONLY, USER_SYSTEM); } if (systemUiUid >= 0) { Slog.d(TAG, "Detected SystemUiUid: " + Integer.toString(systemUiUid)); Loading Loading @@ -1397,8 +1396,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub { Slog.d(TAG, "Bluetooth boot completed"); } mAppOps = mContext.getSystemService(AppOpsManager.class); UserManager userManager = mContext.getSystemService(UserManager.class); userManager.addUserRestrictionsListener(mUserRestrictionsListener); UserManagerInternal userManagerInternal = LocalServices.getService(UserManagerInternal.class); userManagerInternal.addUserRestrictionsListener(mUserRestrictionsListener); final boolean isBluetoothDisallowed = isBluetoothDisallowed(); if (isBluetoothDisallowed) { return; Loading