Loading services/people/java/com/android/server/people/data/ConversationInfo.java +8 −0 Original line number Diff line number Diff line Loading @@ -274,6 +274,10 @@ public class ConversationInfo { } protoOutputStream.write(ConversationInfoProto.SHORTCUT_FLAGS, mShortcutFlags); protoOutputStream.write(ConversationInfoProto.CONVERSATION_FLAGS, mConversationFlags); if (mContactPhoneNumber != null) { protoOutputStream.write(ConversationInfoProto.CONTACT_PHONE_NUMBER, mContactPhoneNumber); } } /** Reads from {@link ProtoInputStream} and constructs a {@link ConversationInfo}. */ Loading Loading @@ -315,6 +319,10 @@ public class ConversationInfo { builder.setConversationFlags(protoInputStream.readInt( ConversationInfoProto.CONVERSATION_FLAGS)); break; case (int) ConversationInfoProto.CONTACT_PHONE_NUMBER: builder.setContactPhoneNumber(protoInputStream.readString( ConversationInfoProto.CONTACT_PHONE_NUMBER)); break; default: Slog.w(TAG, "Could not read undefined field: " + protoInputStream.getFieldNumber()); Loading services/people/java/com/android/server/people/data/ConversationStore.java +1 −25 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.annotation.Nullable; import android.annotation.WorkerThread; import android.content.LocusId; import android.net.Uri; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Slog; import android.util.proto.ProtoInputStream; Loading Loading @@ -71,16 +70,13 @@ class ConversationStore { private final ScheduledExecutorService mScheduledExecutorService; private final File mPackageDir; private final ContactsQueryHelper mHelper; private ConversationInfosProtoDiskReadWriter mConversationInfosProtoDiskReadWriter; ConversationStore(@NonNull File packageDir, @NonNull ScheduledExecutorService scheduledExecutorService, @NonNull ContactsQueryHelper helper) { @NonNull ScheduledExecutorService scheduledExecutorService) { mScheduledExecutorService = scheduledExecutorService; mPackageDir = packageDir; mHelper = helper; } /** Loading @@ -102,7 +98,6 @@ class ConversationStore { return; } for (ConversationInfo conversationInfo : conversationsOnDisk) { conversationInfo = restoreConversationPhoneNumber(conversationInfo); updateConversationsInMemory(conversationInfo); } } Loading Loading @@ -250,25 +245,6 @@ class ConversationStore { return mConversationInfosProtoDiskReadWriter; } /** * Conversation's phone number is not saved on disk, so it has to be fetched. */ @WorkerThread private ConversationInfo restoreConversationPhoneNumber( @NonNull ConversationInfo conversationInfo) { if (conversationInfo.getContactUri() != null) { if (mHelper.query(conversationInfo.getContactUri().toString())) { String phoneNumber = mHelper.getPhoneNumber(); if (!TextUtils.isEmpty(phoneNumber)) { conversationInfo = new ConversationInfo.Builder( conversationInfo).setContactPhoneNumber( phoneNumber).build(); } } } return conversationInfo; } /** Reads and writes {@link ConversationInfo}s on disk. */ private static class ConversationInfosProtoDiskReadWriter extends AbstractProtoDiskReadWriter<List<ConversationInfo>> { Loading services/people/java/com/android/server/people/data/DataManager.java +1 −2 Original line number Diff line number Diff line Loading @@ -133,8 +133,7 @@ public class DataManager { public void onUserUnlocked(int userId) { UserData userData = mUserDataArray.get(userId); if (userData == null) { userData = new UserData(userId, mDiskReadWriterExecutor, mInjector.createContactsQueryHelper(mContext)); userData = new UserData(userId, mDiskReadWriterExecutor); mUserDataArray.put(userId, userData); } userData.setUserUnlocked(); Loading services/people/java/com/android/server/people/data/PackageData.java +4 −7 Original line number Diff line number Diff line Loading @@ -59,16 +59,14 @@ public class PackageData { @NonNull Predicate<String> isDefaultDialerPredicate, @NonNull Predicate<String> isDefaultSmsAppPredicate, @NonNull ScheduledExecutorService scheduledExecutorService, @NonNull File perUserPeopleDataDir, @NonNull ContactsQueryHelper helper) { @NonNull File perUserPeopleDataDir) { mPackageName = packageName; mUserId = userId; mPackageDataDir = new File(perUserPeopleDataDir, mPackageName); mPackageDataDir.mkdirs(); mConversationStore = new ConversationStore(mPackageDataDir, scheduledExecutorService, helper); mConversationStore = new ConversationStore(mPackageDataDir, scheduledExecutorService); mEventStore = new EventStore(mPackageDataDir, scheduledExecutorService); mIsDefaultDialerPredicate = isDefaultDialerPredicate; mIsDefaultSmsAppPredicate = isDefaultSmsAppPredicate; Loading @@ -83,8 +81,7 @@ public class PackageData { @NonNull Predicate<String> isDefaultDialerPredicate, @NonNull Predicate<String> isDefaultSmsAppPredicate, @NonNull ScheduledExecutorService scheduledExecutorService, @NonNull File perUserPeopleDataDir, @NonNull ContactsQueryHelper helper) { @NonNull File perUserPeopleDataDir) { Map<String, PackageData> results = new ArrayMap<>(); File[] packageDirs = perUserPeopleDataDir.listFiles(File::isDirectory); if (packageDirs == null) { Loading @@ -93,7 +90,7 @@ public class PackageData { for (File packageDir : packageDirs) { PackageData packageData = new PackageData(packageDir.getName(), userId, isDefaultDialerPredicate, isDefaultSmsAppPredicate, scheduledExecutorService, perUserPeopleDataDir, helper); perUserPeopleDataDir); packageData.loadFromDisk(); results.put(packageDir.getName(), packageData); } Loading services/people/java/com/android/server/people/data/UserData.java +3 −7 Original line number Diff line number Diff line Loading @@ -37,8 +37,6 @@ class UserData { private final ScheduledExecutorService mScheduledExecutorService; private final ContactsQueryHelper mHelper; private boolean mIsUnlocked; private Map<String, PackageData> mPackageDataMap = new ArrayMap<>(); Loading @@ -49,12 +47,10 @@ class UserData { @Nullable private String mDefaultSmsApp; UserData(@UserIdInt int userId, @NonNull ScheduledExecutorService scheduledExecutorService, ContactsQueryHelper helper) { UserData(@UserIdInt int userId, @NonNull ScheduledExecutorService scheduledExecutorService) { mUserId = userId; mPerUserPeopleDataDir = new File(Environment.getDataSystemCeDirectory(mUserId), "people"); mScheduledExecutorService = scheduledExecutorService; mHelper = helper; } @UserIdInt int getUserId() { Loading @@ -74,7 +70,7 @@ class UserData { // data from disk. mPerUserPeopleDataDir.mkdirs(); mPackageDataMap.putAll(PackageData.packagesDataFromDisk(mUserId, this::isDefaultDialer, this::isDefaultSmsApp, mScheduledExecutorService, mPerUserPeopleDataDir, mHelper)); this::isDefaultSmsApp, mScheduledExecutorService, mPerUserPeopleDataDir)); } void setUserStopped() { Loading Loading @@ -131,7 +127,7 @@ class UserData { private PackageData createPackageData(String packageName) { return new PackageData(packageName, mUserId, this::isDefaultDialer, this::isDefaultSmsApp, mScheduledExecutorService, mPerUserPeopleDataDir, mHelper); mScheduledExecutorService, mPerUserPeopleDataDir); } private boolean isDefaultDialer(String packageName) { Loading Loading
services/people/java/com/android/server/people/data/ConversationInfo.java +8 −0 Original line number Diff line number Diff line Loading @@ -274,6 +274,10 @@ public class ConversationInfo { } protoOutputStream.write(ConversationInfoProto.SHORTCUT_FLAGS, mShortcutFlags); protoOutputStream.write(ConversationInfoProto.CONVERSATION_FLAGS, mConversationFlags); if (mContactPhoneNumber != null) { protoOutputStream.write(ConversationInfoProto.CONTACT_PHONE_NUMBER, mContactPhoneNumber); } } /** Reads from {@link ProtoInputStream} and constructs a {@link ConversationInfo}. */ Loading Loading @@ -315,6 +319,10 @@ public class ConversationInfo { builder.setConversationFlags(protoInputStream.readInt( ConversationInfoProto.CONVERSATION_FLAGS)); break; case (int) ConversationInfoProto.CONTACT_PHONE_NUMBER: builder.setContactPhoneNumber(protoInputStream.readString( ConversationInfoProto.CONTACT_PHONE_NUMBER)); break; default: Slog.w(TAG, "Could not read undefined field: " + protoInputStream.getFieldNumber()); Loading
services/people/java/com/android/server/people/data/ConversationStore.java +1 −25 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.annotation.Nullable; import android.annotation.WorkerThread; import android.content.LocusId; import android.net.Uri; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Slog; import android.util.proto.ProtoInputStream; Loading Loading @@ -71,16 +70,13 @@ class ConversationStore { private final ScheduledExecutorService mScheduledExecutorService; private final File mPackageDir; private final ContactsQueryHelper mHelper; private ConversationInfosProtoDiskReadWriter mConversationInfosProtoDiskReadWriter; ConversationStore(@NonNull File packageDir, @NonNull ScheduledExecutorService scheduledExecutorService, @NonNull ContactsQueryHelper helper) { @NonNull ScheduledExecutorService scheduledExecutorService) { mScheduledExecutorService = scheduledExecutorService; mPackageDir = packageDir; mHelper = helper; } /** Loading @@ -102,7 +98,6 @@ class ConversationStore { return; } for (ConversationInfo conversationInfo : conversationsOnDisk) { conversationInfo = restoreConversationPhoneNumber(conversationInfo); updateConversationsInMemory(conversationInfo); } } Loading Loading @@ -250,25 +245,6 @@ class ConversationStore { return mConversationInfosProtoDiskReadWriter; } /** * Conversation's phone number is not saved on disk, so it has to be fetched. */ @WorkerThread private ConversationInfo restoreConversationPhoneNumber( @NonNull ConversationInfo conversationInfo) { if (conversationInfo.getContactUri() != null) { if (mHelper.query(conversationInfo.getContactUri().toString())) { String phoneNumber = mHelper.getPhoneNumber(); if (!TextUtils.isEmpty(phoneNumber)) { conversationInfo = new ConversationInfo.Builder( conversationInfo).setContactPhoneNumber( phoneNumber).build(); } } } return conversationInfo; } /** Reads and writes {@link ConversationInfo}s on disk. */ private static class ConversationInfosProtoDiskReadWriter extends AbstractProtoDiskReadWriter<List<ConversationInfo>> { Loading
services/people/java/com/android/server/people/data/DataManager.java +1 −2 Original line number Diff line number Diff line Loading @@ -133,8 +133,7 @@ public class DataManager { public void onUserUnlocked(int userId) { UserData userData = mUserDataArray.get(userId); if (userData == null) { userData = new UserData(userId, mDiskReadWriterExecutor, mInjector.createContactsQueryHelper(mContext)); userData = new UserData(userId, mDiskReadWriterExecutor); mUserDataArray.put(userId, userData); } userData.setUserUnlocked(); Loading
services/people/java/com/android/server/people/data/PackageData.java +4 −7 Original line number Diff line number Diff line Loading @@ -59,16 +59,14 @@ public class PackageData { @NonNull Predicate<String> isDefaultDialerPredicate, @NonNull Predicate<String> isDefaultSmsAppPredicate, @NonNull ScheduledExecutorService scheduledExecutorService, @NonNull File perUserPeopleDataDir, @NonNull ContactsQueryHelper helper) { @NonNull File perUserPeopleDataDir) { mPackageName = packageName; mUserId = userId; mPackageDataDir = new File(perUserPeopleDataDir, mPackageName); mPackageDataDir.mkdirs(); mConversationStore = new ConversationStore(mPackageDataDir, scheduledExecutorService, helper); mConversationStore = new ConversationStore(mPackageDataDir, scheduledExecutorService); mEventStore = new EventStore(mPackageDataDir, scheduledExecutorService); mIsDefaultDialerPredicate = isDefaultDialerPredicate; mIsDefaultSmsAppPredicate = isDefaultSmsAppPredicate; Loading @@ -83,8 +81,7 @@ public class PackageData { @NonNull Predicate<String> isDefaultDialerPredicate, @NonNull Predicate<String> isDefaultSmsAppPredicate, @NonNull ScheduledExecutorService scheduledExecutorService, @NonNull File perUserPeopleDataDir, @NonNull ContactsQueryHelper helper) { @NonNull File perUserPeopleDataDir) { Map<String, PackageData> results = new ArrayMap<>(); File[] packageDirs = perUserPeopleDataDir.listFiles(File::isDirectory); if (packageDirs == null) { Loading @@ -93,7 +90,7 @@ public class PackageData { for (File packageDir : packageDirs) { PackageData packageData = new PackageData(packageDir.getName(), userId, isDefaultDialerPredicate, isDefaultSmsAppPredicate, scheduledExecutorService, perUserPeopleDataDir, helper); perUserPeopleDataDir); packageData.loadFromDisk(); results.put(packageDir.getName(), packageData); } Loading
services/people/java/com/android/server/people/data/UserData.java +3 −7 Original line number Diff line number Diff line Loading @@ -37,8 +37,6 @@ class UserData { private final ScheduledExecutorService mScheduledExecutorService; private final ContactsQueryHelper mHelper; private boolean mIsUnlocked; private Map<String, PackageData> mPackageDataMap = new ArrayMap<>(); Loading @@ -49,12 +47,10 @@ class UserData { @Nullable private String mDefaultSmsApp; UserData(@UserIdInt int userId, @NonNull ScheduledExecutorService scheduledExecutorService, ContactsQueryHelper helper) { UserData(@UserIdInt int userId, @NonNull ScheduledExecutorService scheduledExecutorService) { mUserId = userId; mPerUserPeopleDataDir = new File(Environment.getDataSystemCeDirectory(mUserId), "people"); mScheduledExecutorService = scheduledExecutorService; mHelper = helper; } @UserIdInt int getUserId() { Loading @@ -74,7 +70,7 @@ class UserData { // data from disk. mPerUserPeopleDataDir.mkdirs(); mPackageDataMap.putAll(PackageData.packagesDataFromDisk(mUserId, this::isDefaultDialer, this::isDefaultSmsApp, mScheduledExecutorService, mPerUserPeopleDataDir, mHelper)); this::isDefaultSmsApp, mScheduledExecutorService, mPerUserPeopleDataDir)); } void setUserStopped() { Loading Loading @@ -131,7 +127,7 @@ class UserData { private PackageData createPackageData(String packageName) { return new PackageData(packageName, mUserId, this::isDefaultDialer, this::isDefaultSmsApp, mScheduledExecutorService, mPerUserPeopleDataDir, mHelper); mScheduledExecutorService, mPerUserPeopleDataDir); } private boolean isDefaultDialer(String packageName) { Loading