Loading core/java/android/app/people/IPeopleManager.aidl +6 −0 Original line number Original line Diff line number Diff line Loading @@ -39,4 +39,10 @@ interface IPeopleManager { /** Removes all the recent conversations and uncaches their cached shortcuts. */ /** Removes all the recent conversations and uncaches their cached shortcuts. */ void removeAllRecentConversations(); void removeAllRecentConversations(); /** * Returns the last interaction with the specified conversation. If the * conversation can't be found or no interactions have been recorded, returns 0L. */ long getLastInteraction(in String packageName, int userId, in String shortcutId); } } services/people/java/com/android/server/people/PeopleService.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -123,6 +123,12 @@ public class PeopleService extends SystemService { mDataManager.removeAllRecentConversations( mDataManager.removeAllRecentConversations( Binder.getCallingUserHandle().getIdentifier()); Binder.getCallingUserHandle().getIdentifier()); } } @Override public long getLastInteraction(String packageName, int userId, String shortcutId) { enforceSystemOrRoot("get last interaction"); return mDataManager.getLastInteraction(packageName, userId, shortcutId); } } } @VisibleForTesting @VisibleForTesting Loading services/people/java/com/android/server/people/data/DataManager.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -275,6 +275,21 @@ public class DataManager { }); }); } } /** * Returns the last notification interaction with the specified conversation. If the * conversation can't be found or no interactions have been recorded, returns 0L. */ public long getLastInteraction(String packageName, int userId, String shortcutId) { final PackageData packageData = getPackage(packageName, userId); if (packageData != null) { final ConversationInfo conversationInfo = packageData.getConversationInfo(shortcutId); if (conversationInfo != null) { return conversationInfo.getLastEventTimestamp(); } } return 0L; } /** Reports the sharing related {@link AppTargetEvent} from App Prediction Manager. */ /** Reports the sharing related {@link AppTargetEvent} from App Prediction Manager. */ public void reportShareTargetEvent(@NonNull AppTargetEvent event, public void reportShareTargetEvent(@NonNull AppTargetEvent event, @NonNull IntentFilter intentFilter) { @NonNull IntentFilter intentFilter) { Loading services/tests/servicestests/src/com/android/server/people/data/DataManagerTest.java +24 −0 Original line number Original line Diff line number Diff line Loading @@ -837,6 +837,30 @@ public final class DataManagerTest { assertTrue(result.get(0).hasActiveNotifications()); assertTrue(result.get(0).hasActiveNotifications()); } } @Test public void testGetLastInteraction() { mDataManager.onUserUnlocked(USER_ID_PRIMARY); ShortcutInfo shortcut = buildShortcutInfo(TEST_PKG_NAME, USER_ID_PRIMARY, TEST_SHORTCUT_ID, buildPerson()); mDataManager.addOrUpdateConversationInfo(shortcut); NotificationListenerService listenerService = mDataManager.getNotificationListenerServiceForTesting(USER_ID_PRIMARY); listenerService.onNotificationPosted(mStatusBarNotification); assertEquals(mStatusBarNotification.getPostTime(), mDataManager.getLastInteraction(TEST_PKG_NAME, USER_ID_PRIMARY, TEST_SHORTCUT_ID)); assertEquals(0L, mDataManager.getLastInteraction("not_test_pkg", USER_ID_PRIMARY, TEST_SHORTCUT_ID)); assertEquals(0L, mDataManager.getLastInteraction(TEST_PKG_NAME, USER_ID_PRIMARY_MANAGED, TEST_SHORTCUT_ID)); assertEquals(0L, mDataManager.getLastInteraction(TEST_PKG_NAME, USER_ID_SECONDARY, TEST_SHORTCUT_ID)); } @Test @Test public void testNonCachedShortcutNotInRecentList() { public void testNonCachedShortcutNotInRecentList() { mDataManager.onUserUnlocked(USER_ID_PRIMARY); mDataManager.onUserUnlocked(USER_ID_PRIMARY); Loading Loading
core/java/android/app/people/IPeopleManager.aidl +6 −0 Original line number Original line Diff line number Diff line Loading @@ -39,4 +39,10 @@ interface IPeopleManager { /** Removes all the recent conversations and uncaches their cached shortcuts. */ /** Removes all the recent conversations and uncaches their cached shortcuts. */ void removeAllRecentConversations(); void removeAllRecentConversations(); /** * Returns the last interaction with the specified conversation. If the * conversation can't be found or no interactions have been recorded, returns 0L. */ long getLastInteraction(in String packageName, int userId, in String shortcutId); } }
services/people/java/com/android/server/people/PeopleService.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -123,6 +123,12 @@ public class PeopleService extends SystemService { mDataManager.removeAllRecentConversations( mDataManager.removeAllRecentConversations( Binder.getCallingUserHandle().getIdentifier()); Binder.getCallingUserHandle().getIdentifier()); } } @Override public long getLastInteraction(String packageName, int userId, String shortcutId) { enforceSystemOrRoot("get last interaction"); return mDataManager.getLastInteraction(packageName, userId, shortcutId); } } } @VisibleForTesting @VisibleForTesting Loading
services/people/java/com/android/server/people/data/DataManager.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -275,6 +275,21 @@ public class DataManager { }); }); } } /** * Returns the last notification interaction with the specified conversation. If the * conversation can't be found or no interactions have been recorded, returns 0L. */ public long getLastInteraction(String packageName, int userId, String shortcutId) { final PackageData packageData = getPackage(packageName, userId); if (packageData != null) { final ConversationInfo conversationInfo = packageData.getConversationInfo(shortcutId); if (conversationInfo != null) { return conversationInfo.getLastEventTimestamp(); } } return 0L; } /** Reports the sharing related {@link AppTargetEvent} from App Prediction Manager. */ /** Reports the sharing related {@link AppTargetEvent} from App Prediction Manager. */ public void reportShareTargetEvent(@NonNull AppTargetEvent event, public void reportShareTargetEvent(@NonNull AppTargetEvent event, @NonNull IntentFilter intentFilter) { @NonNull IntentFilter intentFilter) { Loading
services/tests/servicestests/src/com/android/server/people/data/DataManagerTest.java +24 −0 Original line number Original line Diff line number Diff line Loading @@ -837,6 +837,30 @@ public final class DataManagerTest { assertTrue(result.get(0).hasActiveNotifications()); assertTrue(result.get(0).hasActiveNotifications()); } } @Test public void testGetLastInteraction() { mDataManager.onUserUnlocked(USER_ID_PRIMARY); ShortcutInfo shortcut = buildShortcutInfo(TEST_PKG_NAME, USER_ID_PRIMARY, TEST_SHORTCUT_ID, buildPerson()); mDataManager.addOrUpdateConversationInfo(shortcut); NotificationListenerService listenerService = mDataManager.getNotificationListenerServiceForTesting(USER_ID_PRIMARY); listenerService.onNotificationPosted(mStatusBarNotification); assertEquals(mStatusBarNotification.getPostTime(), mDataManager.getLastInteraction(TEST_PKG_NAME, USER_ID_PRIMARY, TEST_SHORTCUT_ID)); assertEquals(0L, mDataManager.getLastInteraction("not_test_pkg", USER_ID_PRIMARY, TEST_SHORTCUT_ID)); assertEquals(0L, mDataManager.getLastInteraction(TEST_PKG_NAME, USER_ID_PRIMARY_MANAGED, TEST_SHORTCUT_ID)); assertEquals(0L, mDataManager.getLastInteraction(TEST_PKG_NAME, USER_ID_SECONDARY, TEST_SHORTCUT_ID)); } @Test @Test public void testNonCachedShortcutNotInRecentList() { public void testNonCachedShortcutNotInRecentList() { mDataManager.onUserUnlocked(USER_ID_PRIMARY); mDataManager.onUserUnlocked(USER_ID_PRIMARY); Loading