From 8b4838e5e3d512f77d2772d4db7020349f2a9843 Mon Sep 17 00:00:00 2001 From: Andre Eisenbach Date: Thu, 12 Jan 2017 15:56:39 +0000 Subject: [PATCH] Revert "Don't offer the BT sharing option to the user if BT is disallowed." Causes boot loop issue: 02-15 02:31:59.785 770 770 E System : Caused by: java.lang.IllegalArgumentException: Unknown component: com.android.bluetooth/com.android.bluetooth.opp.BluetoothOppLauncherActivity 02-15 02:31:59.785 770 770 E System : .at com.android.server.pm.PackageManagerService.setEnabledSetting(PackageManagerService.java:18500) 02-15 02:31:59.785 770 770 E System : .at com.android.server.pm.PackageManagerService.setComponentEnabledSetting(PackageManagerService.java:18461) 02-15 02:31:59.785 770 770 E System : .at android.app.ApplicationPackageManager.setComponentEnabledSetting(ApplicationPackageManager.java:2129) 02-15 02:31:59.785 770 770 E System : .at com.android.server.BluetoothManagerService.updateOppLauncherComponentState(BluetoothManagerService.java:2036) This reverts commit 77fe44ffb6b5d40daf3b127cb36d5111b7618cc1. Change-Id: Ia079bb2fcc91bb5979a3840ab50b9d9ddda1cf24 --- .../server/BluetoothManagerService.java | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index f2e1fb6781892..4f43eac8b3cab 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -217,11 +217,6 @@ class BluetoothManagerService extends IBluetoothManager.Stub { @Override public void onUserRestrictionsChanged(int userId, Bundle newRestrictions, Bundle prevRestrictions) { - if (!newRestrictions.containsKey(UserManager.DISALLOW_BLUETOOTH) - && !prevRestrictions.containsKey(UserManager.DISALLOW_BLUETOOTH)) { - // The relevant restriction has not changed - do nothing. - return; - } final boolean bluetoothDisallowed = newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH); if ((mEnable || mEnableExternal) && bluetoothDisallowed) { @@ -232,7 +227,6 @@ class BluetoothManagerService extends IBluetoothManager.Stub { // when from system. } } - updateOppLauncherComponentState(bluetoothDisallowed); } }; @@ -944,9 +938,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { UserManagerInternal userManagerInternal = LocalServices.getService(UserManagerInternal.class); userManagerInternal.addUserRestrictionsListener(mUserRestrictionsListener); - final boolean isBluetoothDisallowed = isBluetoothDisallowed(); - updateOppLauncherComponentState(isBluetoothDisallowed); - if (isBluetoothDisallowed) { + if (isBluetoothDisallowed()) { return; } if (mEnableExternal && isBluetoothPersistedStateOnBluetooth()) { @@ -2003,24 +1995,6 @@ class BluetoothManagerService extends IBluetoothManager.Stub { } } - /** - * Disables BluetoothOppLauncherActivity component, so the Bluetooth sharing option is not - * offered to the user if Bluetooth is disallowed. Puts the component to its default state if - * Bluetooth is not disallowed. - * - * @param bluetoothDisallowed whether the {@link UserManager.DISALLOW_BLUETOOTH} user - * restriction was set. - */ - private void updateOppLauncherComponentState(boolean bluetoothDisallowed) { - final ComponentName oppLauncherComponent = new ComponentName("com.android.bluetooth", - "com.android.bluetooth.opp.BluetoothOppLauncherActivity"); - final int newState = bluetoothDisallowed - ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED - : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; - mContext.getPackageManager() - .setComponentEnabledSetting(oppLauncherComponent, newState, 0); - } - @Override public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);