From 57c9e16d041c9047a1618aab9c52be5608fae1cf Mon Sep 17 00:00:00 2001 From: Winson Date: Fri, 20 May 2016 18:21:11 -0700 Subject: Process user events from service lifecycle callbacks. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Instead of waiting for the broadcast to start loading the user’s widgets, handle them in the service callbacks to ensure the app widget update broadcasts are enqueued earlier. Bug: 27262341 Change-Id: I095abe5e15fe46412d00438986f7a9aee50872ca --- .../android/server/appwidget/AppWidgetService.java | 15 +++++++++++++++ .../server/appwidget/AppWidgetServiceImpl.java | 19 +++---------------- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'services/appwidget/java') diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetService.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetService.java index 3f9542731ad3..de2c58c6dae7 100644 --- a/services/appwidget/java/com/android/server/appwidget/AppWidgetService.java +++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetService.java @@ -44,4 +44,19 @@ public class AppWidgetService extends SystemService { mImpl.setSafeMode(isSafeMode()); } } + + @Override + public void onUnlockUser(int userHandle) { + mImpl.onUserUnlocked(userHandle); + } + + @Override + public void onStopUser(int userHandle) { + mImpl.onUserStopped(userHandle); + } + + @Override + public void onSwitchUser(int userHandle) { + mImpl.reloadWidgetsMaskedStateForGroup(userHandle); + } } diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java index ac2dda3492ca..4e0ddd6a75cb 100644 --- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java +++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java @@ -158,12 +158,6 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { onConfigurationChanged(); - } else if (Intent.ACTION_USER_UNLOCKED.equals(action)) { - onUserUnlocked(userId); - } else if (Intent.ACTION_USER_STOPPED.equals(action)) { - onUserStopped(userId); - } else if (Intent.ACTION_USER_SWITCHED.equals(action)) { - reloadWidgetsMaskedStateForGroup(userId); } else if (Intent.ACTION_MANAGED_PROFILE_AVAILABLE.equals(action) || Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE.equals(action)) { synchronized (mLock) { @@ -281,13 +275,6 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku mContext.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, sdFilter, null, null); - IntentFilter userFilter = new IntentFilter(); - userFilter.addAction(Intent.ACTION_USER_UNLOCKED); - userFilter.addAction(Intent.ACTION_USER_STOPPED); - userFilter.addAction(Intent.ACTION_USER_SWITCHED); - mContext.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, - userFilter, null, null); - IntentFilter offModeFilter = new IntentFilter(); offModeFilter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE); offModeFilter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE); @@ -454,7 +441,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku * due to user not being available and package suspension. * userId must be the group parent. */ - private void reloadWidgetsMaskedStateForGroup(int userId) { + void reloadWidgetsMaskedStateForGroup(int userId) { if (!mUserManager.isUserUnlockingOrUnlocked(userId)) { return; } @@ -2525,7 +2512,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku } } - private void onUserUnlocked(int userId) { + void onUserUnlocked(int userId) { if (isProfileWithLockedParent(userId)) { return; } @@ -3072,7 +3059,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku return new AtomicFile(settingsFile); } - private void onUserStopped(int userId) { + void onUserStopped(int userId) { synchronized (mLock) { boolean crossProfileWidgetsChanged = false; -- cgit v1.2.3-59-g8ed1b