From ef934fdd482b73c6bfb84ede3900bb45e24f3bfc Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Thu, 1 Feb 2018 14:39:17 -0500 Subject: [PATCH] Rebind assistant services on user unlocked. Change-Id: I25daeaffee282df3b2e3819a29db6c3117b163f5 Fixes: 72453895 Test: manual --- .../src/android/ext/services/notification/Assistant.java | 2 +- .../android/ext/services/notification/AssistantTest.java | 4 ++-- .../com/android/server/notification/ManagedServices.java | 2 +- .../server/notification/NotificationManagerService.java | 6 ++++++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/ExtServices/src/android/ext/services/notification/Assistant.java b/packages/ExtServices/src/android/ext/services/notification/Assistant.java index 6fe8975577a47..9a66b07fb74f1 100644 --- a/packages/ExtServices/src/android/ext/services/notification/Assistant.java +++ b/packages/ExtServices/src/android/ext/services/notification/Assistant.java @@ -94,7 +94,7 @@ public class Assistant extends NotificationAssistantService { infile = mFile.openRead(); readXml(infile); } catch (FileNotFoundException e) { - // No data yet + Log.d(TAG, "File doesn't exist or isn't readable yet"); } catch (IOException e) { Log.e(TAG, "Unable to read channel impressions", e); } catch (NumberFormatException | XmlPullParserException e) { diff --git a/packages/ExtServices/tests/src/android/ext/services/notification/AssistantTest.java b/packages/ExtServices/tests/src/android/ext/services/notification/AssistantTest.java index 7c35b48310f2d..db48f610471da 100644 --- a/packages/ExtServices/tests/src/android/ext/services/notification/AssistantTest.java +++ b/packages/ExtServices/tests/src/android/ext/services/notification/AssistantTest.java @@ -325,7 +325,8 @@ public class AssistantTest extends ServiceTestCase { int dismiss2 = 777; String key2 = mAssistant.getKey("pkg2", 2, "channel2"); - String xml = "\n" + String xml = "" + + "\n" + "\n" @@ -377,7 +378,6 @@ public class AssistantTest extends ServiceTestCase { mAssistant.insertImpressions(key2, ci2); mAssistant.insertImpressions(key3, ci3); - XmlSerializer serializer = new FastXmlSerializer(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); serializer.setOutput(new BufferedOutputStream(baos), "utf-8"); diff --git a/services/core/java/com/android/server/notification/ManagedServices.java b/services/core/java/com/android/server/notification/ManagedServices.java index 502760a2cfc4c..fd435f952c109 100644 --- a/services/core/java/com/android/server/notification/ManagedServices.java +++ b/services/core/java/com/android/server/notification/ManagedServices.java @@ -771,7 +771,7 @@ abstract public class ManagedServices { * Called whenever packages change, the user switches, or the secure setting * is altered. (For example in response to USER_SWITCHED in our broadcast receiver) */ - private void rebindServices(boolean forceRebind) { + protected void rebindServices(boolean forceRebind) { if (DEBUG) Slog.d(TAG, "rebindServices"); final int[] userIds = mUserProfiles.getCurrentProfileIds(); final int nUserIds = userIds.length; diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 727e7ee2ac18a..1013d4e54d0fe 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -5687,6 +5687,12 @@ public class NotificationManagerService extends SystemService { mListeners.unregisterService(removed.service, removed.userid); } + @Override + public void onUserUnlocked(int user) { + if (DEBUG) Slog.d(TAG, "onUserUnlocked u=" + user); + rebindServices(true); + } + public void onNotificationEnqueued(final NotificationRecord r) { final StatusBarNotification sbn = r.sbn; TrimCache trimCache = new TrimCache(sbn);