diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-04-13 00:19:40 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-04-13 00:19:40 +0000 |
commit | 9cad72e5f3058e6e6adad04ab9a15737a912182a (patch) | |
tree | 723f0d7e784b48194947c34bd340aa710a2d4526 /service | |
parent | 3a2a2a79bce7ce0f8fe4f4f8de6d0ec478532141 (diff) | |
parent | 102b0edddadbd08d9e252ae87f873ce1bd84d138 (diff) |
Merge "WifiServiceImpl: Fix package removal broadcast handling" into pi-dev
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index 7d6c109c1..49f00f88f 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -567,7 +567,6 @@ public class WifiServiceImpl extends IWifiManager.Stub { // can result in race conditions when apps toggle wifi in the background // without active user involvement. Always receive broadcasts. registerForBroadcasts(); - registerForPackageOrUserRemoval(); mInIdleMode = mPowerManager.isDeviceIdleMode(); if (!mWifiStateMachine.syncInitialize(mWifiStateMachineChannel)) { @@ -2303,6 +2302,9 @@ public class WifiServiceImpl extends IWifiManager.Stub { String action = intent.getAction(); if (action.equals(Intent.ACTION_USER_PRESENT)) { mWifiController.sendMessage(CMD_USER_PRESENT); + } else if (action.equals(Intent.ACTION_USER_REMOVED)) { + int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0); + mWifiStateMachine.removeUserConfigs(userHandle); } else if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) { int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, BluetoothAdapter.STATE_DISCONNECTED); @@ -2368,6 +2370,7 @@ public class WifiServiceImpl extends IWifiManager.Stub { private void registerForBroadcasts() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_USER_PRESENT); + intentFilter.addAction(Intent.ACTION_USER_REMOVED); intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); intentFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); @@ -2378,39 +2381,26 @@ public class WifiServiceImpl extends IWifiManager.Stub { if (trackEmergencyCallState) { intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALL_STATE_CHANGED); } - mContext.registerReceiver(mReceiver, intentFilter); - } - private void registerForPackageOrUserRemoval() { - IntentFilter intentFilter = new IntentFilter(); - intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); - intentFilter.addAction(Intent.ACTION_USER_REMOVED); - mContext.registerReceiverAsUser(new BroadcastReceiver() { + intentFilter = new IntentFilter(); + intentFilter.addAction(Intent.ACTION_PACKAGE_FULLY_REMOVED); + intentFilter.addDataScheme("package"); + mContext.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - switch (intent.getAction()) { - case Intent.ACTION_PACKAGE_REMOVED: { - if (intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { - return; - } - int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); - Uri uri = intent.getData(); - if (uid == -1 || uri == null) { - return; - } - String pkgName = uri.getSchemeSpecificPart(); - mWifiStateMachine.removeAppConfigs(pkgName, uid); - break; - } - case Intent.ACTION_USER_REMOVED: { - int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0); - mWifiStateMachine.removeUserConfigs(userHandle); - break; + String action = intent.getAction(); + if (action.equals(Intent.ACTION_PACKAGE_FULLY_REMOVED)) { + int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); + Uri uri = intent.getData(); + if (uid == -1 || uri == null) { + return; } + String pkgName = uri.getSchemeSpecificPart(); + mWifiStateMachine.removeAppConfigs(pkgName, uid); } } - }, UserHandle.ALL, intentFilter, null, null); + }, intentFilter); } @Override |