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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user