diff options
| author | 2016-06-17 17:09:22 +0000 | |
|---|---|---|
| committer | 2016-06-17 17:09:22 +0000 | |
| commit | 95d0d631ba2773e79d5349f3a27fc3ec3fb663e6 (patch) | |
| tree | 4ee99e2556d64a3dc3efbaa42f52047849d1e47b /services/appwidget/java | |
| parent | 9caec9ff638f2e494da557a7fb181c0ae92f446f (diff) | |
| parent | ab8d4cf6450779fbb352c100370f8ca647166e97 (diff) | |
Merge \"Allow stopping user to access AppWidgetService API\" into nyc-dev
am: ab8d4cf645
Change-Id: I2280fae9d85594ad0fde5d552ff07b0d4e0c6158
Diffstat (limited to 'services/appwidget/java')
| -rw-r--r-- | services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java index 04a09900aeef..feceb149ae3f 100644 --- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java +++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java @@ -20,6 +20,7 @@ import static android.content.Context.KEYGUARD_SERVICE; import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; +import android.annotation.UserIdInt; import android.app.AlarmManager; import android.app.AppGlobals; import android.app.AppOpsManager; @@ -67,6 +68,7 @@ import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.os.UserManager; +import android.os.storage.StorageManager; import android.text.TextUtils; import android.util.ArraySet; import android.util.AtomicFile; @@ -650,7 +652,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku } private void ensureGroupStateLoadedLocked(int userId, boolean enforceUserUnlockingOrUnlocked) { - if (enforceUserUnlockingOrUnlocked && !mUserManager.isUserUnlockingOrUnlocked(userId)) { + if (enforceUserUnlockingOrUnlocked && !isUserRunningAndUnlocked(userId)) { throw new IllegalStateException( "User " + userId + " must be unlocked for widgets to be available"); } @@ -695,6 +697,10 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku loadGroupStateLocked(newProfileIds); } + private boolean isUserRunningAndUnlocked(@UserIdInt int userId) { + return mUserManager.isUserRunning(userId) && StorageManager.isUserKeyUnlocked(userId); + } + @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, @@ -3381,7 +3387,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku if (userInfo != null && userInfo.isManagedProfile()) { UserInfo parentInfo = mUserManager.getProfileParent(userId); if (parentInfo != null - && !mUserManager.isUserUnlockingOrUnlocked(parentInfo.getUserHandle())) { + && !isUserRunningAndUnlocked(parentInfo.getUserHandle().getIdentifier())) { return true; } } |