Merge "Add getLastInteraction API to PeopleManager"
This commit is contained in:
@@ -39,4 +39,10 @@ interface IPeopleManager {
|
||||
|
||||
/** Removes all the recent conversations and uncaches their cached shortcuts. */
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -123,6 +123,12 @@ public class PeopleService extends SystemService {
|
||||
mDataManager.removeAllRecentConversations(
|
||||
Binder.getCallingUserHandle().getIdentifier());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastInteraction(String packageName, int userId, String shortcutId) {
|
||||
enforceSystemOrRoot("get last interaction");
|
||||
return mDataManager.getLastInteraction(packageName, userId, shortcutId);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -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. */
|
||||
public void reportShareTargetEvent(@NonNull AppTargetEvent event,
|
||||
@NonNull IntentFilter intentFilter) {
|
||||
|
||||
@@ -837,6 +837,30 @@ public final class DataManagerTest {
|
||||
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
|
||||
public void testNonCachedShortcutNotInRecentList() {
|
||||
mDataManager.onUserUnlocked(USER_ID_PRIMARY);
|
||||
|
||||
Reference in New Issue
Block a user