Merge "Fix the issue widget retore doesn't play well with work profile" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
476efd5f8b
@@ -4414,7 +4414,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
|
|||||||
// a given package. Keep track of what we've done so far here; the list is
|
// a given package. Keep track of what we've done so far here; the list is
|
||||||
// cleared at the start of every system restore pass, but preserved through
|
// cleared at the start of every system restore pass, but preserved through
|
||||||
// any install-time restore operations.
|
// any install-time restore operations.
|
||||||
private final HashSet<String> mPrunedApps = new HashSet<>();
|
private final SparseArray<Set<String>> mPrunedAppsPerUser = new SparseArray<>();
|
||||||
|
|
||||||
private final HashMap<Provider, ArrayList<RestoreUpdateRecord>> mUpdatesByProvider =
|
private final HashMap<Provider, ArrayList<RestoreUpdateRecord>> mUpdatesByProvider =
|
||||||
new HashMap<>();
|
new HashMap<>();
|
||||||
@@ -4537,7 +4537,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
|
|||||||
// We're starting a new "system" restore operation, so any widget restore
|
// We're starting a new "system" restore operation, so any widget restore
|
||||||
// state that we see from here on is intended to replace the current
|
// state that we see from here on is intended to replace the current
|
||||||
// widget configuration of any/all of the affected apps.
|
// widget configuration of any/all of the affected apps.
|
||||||
mPrunedApps.clear();
|
getPrunedAppsLocked(userId).clear();
|
||||||
mUpdatesByProvider.clear();
|
mUpdatesByProvider.clear();
|
||||||
mUpdatesByHost.clear();
|
mUpdatesByHost.clear();
|
||||||
}
|
}
|
||||||
@@ -4934,8 +4934,10 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
|
|||||||
// instances that are hosted by that app, and (b) all instances in other hosts
|
// instances that are hosted by that app, and (b) all instances in other hosts
|
||||||
// for which 'pkg' is the provider. We assume that we'll be restoring all of
|
// for which 'pkg' is the provider. We assume that we'll be restoring all of
|
||||||
// these hosts & providers, so will be reconstructing a correct live state.
|
// these hosts & providers, so will be reconstructing a correct live state.
|
||||||
|
@GuardedBy("mLock")
|
||||||
private void pruneWidgetStateLocked(String pkg, int userId) {
|
private void pruneWidgetStateLocked(String pkg, int userId) {
|
||||||
if (!mPrunedApps.contains(pkg)) {
|
final Set<String> prunedApps = getPrunedAppsLocked(userId);
|
||||||
|
if (!prunedApps.contains(pkg)) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.i(TAG, "pruning widget state for restoring package " + pkg);
|
Slog.i(TAG, "pruning widget state for restoring package " + pkg);
|
||||||
}
|
}
|
||||||
@@ -4958,7 +4960,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
|
|||||||
removeWidgetLocked(widget);
|
removeWidgetLocked(widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mPrunedApps.add(pkg);
|
prunedApps.add(pkg);
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.i(TAG, "already pruned " + pkg + ", continuing normally");
|
Slog.i(TAG, "already pruned " + pkg + ", continuing normally");
|
||||||
@@ -4966,6 +4968,15 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GuardedBy("mLock")
|
||||||
|
@NonNull
|
||||||
|
private Set<String> getPrunedAppsLocked(int userId) {
|
||||||
|
if (!mPrunedAppsPerUser.contains(userId)) {
|
||||||
|
mPrunedAppsPerUser.set(userId, new ArraySet<>());
|
||||||
|
}
|
||||||
|
return mPrunedAppsPerUser.get(userId);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isProviderAndHostInUser(Widget widget, int userId) {
|
private boolean isProviderAndHostInUser(Widget widget, int userId) {
|
||||||
// Backup only widgets hosted or provided by the owner profile.
|
// Backup only widgets hosted or provided by the owner profile.
|
||||||
return widget.host.getUserId() == userId && (widget.provider == null
|
return widget.host.getUserId() == userId && (widget.provider == null
|
||||||
|
|||||||
Reference in New Issue
Block a user