diff options
| author | 2015-08-26 17:52:48 -0700 | |
|---|---|---|
| committer | 2015-08-27 12:03:25 -0700 | |
| commit | 6c0773ec7dc7f6a024b9dde5641fd442cb4a7cc1 (patch) | |
| tree | 222cf440a76d9e5c18a404f285df4e65bee2e2a2 | |
| parent | 2e8c5bfd6dfb3ff5c64196bbe565446294643d4f (diff) | |
Removing profile's pinned apps upon a profile removal.
Bug: 20024603
Change-Id: I4b17bffe202d3f4cf211b3289ee021c4ec16e91f
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarApps.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarApps.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarApps.java index 4c1aab988f23..adcec986d465 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarApps.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarApps.java @@ -87,6 +87,9 @@ class NavigationBarApps extends LinearLayout { if (Intent.ACTION_USER_SWITCHED.equals(action)) { int currentUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1); onUserSwitched(currentUserId); + } else if (Intent.ACTION_MANAGED_PROFILE_REMOVED.equals(action)) { + UserHandle removedProfile = intent.getParcelableExtra(Intent.EXTRA_USER); + onManagedProfileRemoved(removedProfile); } } }; @@ -205,6 +208,7 @@ class NavigationBarApps extends LinearLayout { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_USER_SWITCHED); + filter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED); mContext.registerReceiver(mBroadcastReceiver, filter); mAppPackageMonitor.register(mContext, null, UserHandle.ALL, true); @@ -571,4 +575,17 @@ class NavigationBarApps extends LinearLayout { sAppsModel.setCurrentUser(currentUserId); recreateAppButtons(); } + + private void onManagedProfileRemoved(UserHandle removedProfile) { + boolean removedApps = false; + for(int i = sAppsModel.getAppCount() - 1; i >= 0; --i) { + AppInfo appInfo = sAppsModel.getApp(i); + if (!appInfo.getUser().equals(removedProfile)) continue; + + removeViewAt(i); + sAppsModel.removeApp(i); + removedApps = true; + } + if (removedApps) sAppsModel.savePrefs(); + } } |