Rebind assistant services on user unlocked.

Change-Id: I25daeaffee282df3b2e3819a29db6c3117b163f5
Fixes: 72453895
Test: manual
This commit is contained in:
Julia Reynolds
2018-02-01 14:39:17 -05:00
parent 099267f323
commit ef934fdd48
4 changed files with 10 additions and 4 deletions

View File

@@ -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) {

View File

@@ -325,7 +325,8 @@ public class AssistantTest extends ServiceTestCase<Assistant> {
int dismiss2 = 777;
String key2 = mAssistant.getKey("pkg2", 2, "channel2");
String xml = "<assistant version=\"1\">\n"
String xml = "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>"
+ "<assistant version=\"1\">\n"
+ "<impression-set key=\"" + key1 + "\" "
+ "dismisses=\"" + dismiss1 + "\" views=\"" + views1
+ "\" streak=\"" + streak1 + "\"/>\n"
@@ -377,7 +378,6 @@ public class AssistantTest extends ServiceTestCase<Assistant> {
mAssistant.insertImpressions(key2, ci2);
mAssistant.insertImpressions(key3, ci3);
XmlSerializer serializer = new FastXmlSerializer();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
serializer.setOutput(new BufferedOutputStream(baos), "utf-8");

View File

@@ -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;

View File

@@ -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);