Merge "Don\'t load profile widgets until parent is unlocked." into nyc-dev

am: 0a6909cdfd

* commit '0a6909cdfd105a64b1ff51a64621b4c5778a2cc0':
  Don't load profile widgets until parent is unlocked.
This commit is contained in:
Kenny Guy
2016-02-23 15:13:06 +00:00
committed by android-build-merger

View File

@@ -353,7 +353,10 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
}
private void onPackageBroadcastReceived(Intent intent, int userId) {
if (!mUserManager.isUserUnlocked(userId)) return;
if (!mUserManager.isUserUnlocked(userId) ||
isProfileWithLockedParent(userId)) {
return;
}
final String action = intent.getAction();
boolean added = false;
@@ -435,7 +438,10 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
* due to user not being available and package suspension.
*/
private void reloadWidgetsMaskedStateForUser(int userId) {
if (!mUserManager.isUserUnlocked(userId)) return;
if (!mUserManager.isUserUnlocked(userId) ||
isProfileWithLockedParent(userId)) {
return;
}
synchronized (mLock) {
reloadWidgetPackageSuspensionMaskedStateLocked(userId);
List<UserInfo> profiles = mUserManager.getEnabledProfiles(userId);
@@ -606,7 +612,10 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
throw new IllegalStateException(
"User " + userId + " must be unlocked for widgets to be available");
}
if (isProfileWithLockedParent(userId)) {
throw new IllegalStateException(
"Profile " + userId + " must have unlocked parent");
}
final int[] profileIds = mSecurityPolicy.getEnabledGroupProfileIds(userId);
// Careful lad, we may have already loaded the state for some
@@ -2458,6 +2467,9 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
}
private void onUserUnlocked(int userId) {
if (isProfileWithLockedParent(userId)) {
return;
}
synchronized (mLock) {
ensureGroupStateLoadedLocked(userId);
reloadWidgetsMaskedStateForUser(userId);
@@ -3306,6 +3318,23 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
}
}
private boolean isProfileWithLockedParent(int userId) {
long token = Binder.clearCallingIdentity();
try {
UserInfo userInfo = mUserManager.getUserInfo(userId);
if (userInfo != null && userInfo.isManagedProfile()) {
UserInfo parentInfo = mUserManager.getProfileParent(userId);
if (parentInfo != null
&& !mUserManager.isUserUnlocked(parentInfo.getUserHandle())) {
return true;
}
}
} finally {
Binder.restoreCallingIdentity(token);
}
return false;
}
private boolean isProfileWithUnlockedParent(int userId) {
UserInfo userInfo = mUserManager.getUserInfo(userId);
if (userInfo != null && userInfo.isManagedProfile()) {