summaryrefslogtreecommitdiffstats
path: root/services/appwidget/java
diff options
context:
space:
mode:
authorKenny Guy <kennyguy@google.com>2015-02-16 18:09:48 +0000
committerKenny Guy <kennyguy@google.com>2015-02-17 20:33:36 +0000
commit0f7fab6662c85b2af83438297e4960483cc39b1e (patch)
tree0f45c92def4b54b0fcbbd9139405f3ffc5c09328 /services/appwidget/java
parenta8451c4c56eccde7992bfc73d6b2a83905265a1a (diff)
downloadframeworks_base-0f7fab6662c85b2af83438297e4960483cc39b1e.zip
frameworks_base-0f7fab6662c85b2af83438297e4960483cc39b1e.tar.gz
frameworks_base-0f7fab6662c85b2af83438297e4960483cc39b1e.tar.bz2
Remove widgets for packages no longer whitelisted by admin
When cross profile widget whitelist is updated by device admin remove providers for removed packages. Bug: 19293923 Change-Id: I7a5f7b706486055346d906c89d48510bfe1ad352
Diffstat (limited to 'services/appwidget/java')
-rw-r--r--services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java32
1 files changed, 27 insertions, 5 deletions
diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
index 7623514..da11dad 100644
--- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
+++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java
@@ -2837,10 +2837,10 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
return providersUpdated;
}
- private boolean removeHostsAndProvidersForPackageLocked(String pkgName, int userId) {
+ private boolean removeProvidersForPackageLocked(String pkgName, int userId) {
boolean removed = false;
- int N = mProviders.size();
+ final int N = mProviders.size();
for (int i = N - 1; i >= 0; i--) {
Provider provider = mProviders.get(i);
if (pkgName.equals(provider.info.provider.getPackageName())
@@ -2849,11 +2849,16 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
removed = true;
}
}
+ return removed;
+ }
+
+ private boolean removeHostsAndProvidersForPackageLocked(String pkgName, int userId) {
+ boolean removed = removeProvidersForPackageLocked(pkgName, userId);
// Delete the hosts for this package too
// By now, we have removed any AppWidgets that were in any hosts here,
// so we don't need to worry about sending DISABLE broadcasts to them.
- N = mHosts.size();
+ final int N = mHosts.size();
for (int i = N - 1; i >= 0; i--) {
Host host = mHosts.get(i);
if (pkgName.equals(host.id.packageName)
@@ -2925,13 +2930,30 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
synchronized (mLock) {
boolean providersChanged = false;
+ ArraySet<String> previousPackages = new ArraySet<String>();
+ final int providerCount = mProviders.size();
+ for (int i = 0; i < providerCount; ++i) {
+ Provider provider = mProviders.get(i);
+ if (provider.getUserId() == userId) {
+ previousPackages.add(provider.id.componentName.getPackageName());
+ }
+ }
+
final int packageCount = packages.size();
for (int i = 0; i < packageCount; i++) {
String packageName = packages.get(i);
+ previousPackages.remove(packageName);
providersChanged |= updateProvidersForPackageLocked(packageName,
userId, null);
}
+ // Some packages are no longer whitelisted.
+ final int removedCount = previousPackages.size();
+ for (int i = 0; i < removedCount; ++i) {
+ providersChanged |= removeProvidersForPackageLocked(
+ previousPackages.valueAt(i), userId);
+ }
+
if (providersChanged) {
saveGroupStateAsync(userId);
scheduleNotifyGroupHostsForProvidersChangedLocked(userId);
@@ -3142,10 +3164,10 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
if (parentId != callerId) {
return false;
}
- return isProviderWhitelListed(packageName, profileId);
+ return isProviderWhiteListed(packageName, profileId);
}
- public boolean isProviderWhitelListed(String packageName, int profileId) {
+ public boolean isProviderWhiteListed(String packageName, int profileId) {
DevicePolicyManagerInternal devicePolicyManager = LocalServices.getService(
DevicePolicyManagerInternal.class);