Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3f85212 authored by Danning Chen's avatar Danning Chen
Browse files

Fix the NPE when reading the call log or SMS if a device has multiple user profiles

Change-Id: Iec6485653367f2f005c2b7e17f23ab611e39e13b
Bug: 148918224
Test: atest com.android.server.people.data.DataManagerTest
parent 098584d2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -299,7 +299,8 @@ public class DataManager {

    private void forAllUnlockedUsers(Consumer<UserData> consumer) {
        for (int i = 0; i < mUserDataArray.size(); i++) {
            UserData userData = mUserDataArray.get(i);
            int userId = mUserDataArray.keyAt(i);
            UserData userData = mUserDataArray.get(userId);
            if (userData.isUnlocked()) {
                consumer.accept(userData);
            }
+4 −0
Original line number Diff line number Diff line
@@ -263,6 +263,7 @@ public final class DataManagerTest {
    @Test
    public void testContactsChanged() {
        mDataManager.onUserUnlocked(USER_ID_PRIMARY);
        mDataManager.onUserUnlocked(USER_ID_SECONDARY);

        ShortcutInfo shortcut = buildShortcutInfo(TEST_PKG_NAME, USER_ID_PRIMARY, TEST_SHORTCUT_ID,
                buildPerson());
@@ -289,6 +290,7 @@ public final class DataManagerTest {
    @Test
    public void testNotificationListener() {
        mDataManager.onUserUnlocked(USER_ID_PRIMARY);
        mDataManager.onUserUnlocked(USER_ID_SECONDARY);

        ShortcutInfo shortcut = buildShortcutInfo(TEST_PKG_NAME, USER_ID_PRIMARY, TEST_SHORTCUT_ID,
                buildPerson());
@@ -341,6 +343,7 @@ public final class DataManagerTest {
    @Test
    public void testCallLogContentObserver() {
        mDataManager.onUserUnlocked(USER_ID_PRIMARY);
        mDataManager.onUserUnlocked(USER_ID_SECONDARY);

        ShortcutInfo shortcut = buildShortcutInfo(TEST_PKG_NAME, USER_ID_PRIMARY, TEST_SHORTCUT_ID,
                buildPerson());
@@ -368,6 +371,7 @@ public final class DataManagerTest {
    @Test
    public void testMmsSmsContentObserver() {
        mDataManager.onUserUnlocked(USER_ID_PRIMARY);
        mDataManager.onUserUnlocked(USER_ID_SECONDARY);

        ShortcutInfo shortcut = buildShortcutInfo(TEST_PKG_NAME, USER_ID_PRIMARY, TEST_SHORTCUT_ID,
                buildPerson());