diff options
| author | 2016-06-16 14:57:00 +0100 | |
|---|---|---|
| committer | 2016-06-16 14:57:00 +0100 | |
| commit | 63966b3e120fe8a0fff729a9508341d53f9daafc (patch) | |
| tree | c7ed41677ec574db9625bdf61a95fc70041b1a87 | |
| parent | 627bca6e80ce7539273f084b4f1694d7433e2791 (diff) | |
Allow stopping user to access AppWidgetService API
We now have isUserRunning && isUserKeyUnlockedisUserUnlocked instead of
having isUserUnlockingOrUnlocked. The difference is
we now allow stopping unlocked user to access the API.
Testing:
Write a simple widget which keep calling AppWidgetManager API in a loop.
1. In non-FBE mode, place the widget to launcher.
Turn off work mode. No crash is observed.
2. Repeat 1 in FBE mode with separated work challenge.
3. Repeat 1 in FBE mode with no separated work challenge
4. Repeat 2 and reboot the device. Unlock work profile, widget is shown
5. Repeat 3, reboot device, widget is shown after rebot
Change-Id: I2fa9f602dcb0befff41fc6b145e9855e82d8d7a8
Fix: 29264823
| -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 4e0ddd6a75cb..2a3022962d45 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; @@ -66,6 +67,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; @@ -647,7 +649,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"); } @@ -692,6 +694,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, @@ -3358,7 +3364,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; } } |