Merge "Fix people widget crash" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2c9783b3f0
@@ -775,10 +775,14 @@ public class PeopleSpaceWidgetManager {
|
|||||||
NotificationChannel channel,
|
NotificationChannel channel,
|
||||||
int modificationType) {
|
int modificationType) {
|
||||||
if (channel.isConversation()) {
|
if (channel.isConversation()) {
|
||||||
|
mBgExecutor.execute(() -> {
|
||||||
|
if (mUserManager.isUserUnlocked(user)) {
|
||||||
updateWidgets(mAppWidgetManager.getAppWidgetIds(
|
updateWidgets(mAppWidgetManager.getAppWidgetIds(
|
||||||
new ComponentName(mContext, PeopleSpaceWidgetProvider.class)
|
new ComponentName(mContext, PeopleSpaceWidgetProvider.class)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -481,6 +481,8 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase {
|
|||||||
int[] widgetIdsArray = {1};
|
int[] widgetIdsArray = {1};
|
||||||
when(mAppWidgetManager.getAppWidgetIds(any())).thenReturn(widgetIdsArray);
|
when(mAppWidgetManager.getAppWidgetIds(any())).thenReturn(widgetIdsArray);
|
||||||
|
|
||||||
|
when(mUserManager.isUserUnlocked(any())).thenReturn(true);
|
||||||
|
|
||||||
NotificationChannel channel =
|
NotificationChannel channel =
|
||||||
new NotificationChannel(TEST_CHANNEL_ID, TEST_CHANNEL_NAME, IMPORTANCE_DEFAULT);
|
new NotificationChannel(TEST_CHANNEL_ID, TEST_CHANNEL_NAME, IMPORTANCE_DEFAULT);
|
||||||
channel.setConversationId(TEST_PARENT_CHANNEL_ID, TEST_CONVERSATION_ID);
|
channel.setConversationId(TEST_PARENT_CHANNEL_ID, TEST_CONVERSATION_ID);
|
||||||
@@ -489,8 +491,25 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase {
|
|||||||
UserHandle.getUserHandleForUid(0), channel, IMPORTANCE_HIGH);
|
UserHandle.getUserHandleForUid(0), channel, IMPORTANCE_HIGH);
|
||||||
mClock.advanceTime(MIN_LINGER_DURATION);
|
mClock.advanceTime(MIN_LINGER_DURATION);
|
||||||
|
|
||||||
verify(mAppWidgetManager, times(1)).updateAppWidget(anyInt(),
|
verify(mAppWidgetManager, times(1)).updateAppWidget(anyInt(), any());
|
||||||
any());
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOnNotificationChannelModified_userLocked() {
|
||||||
|
int[] widgetIdsArray = {1};
|
||||||
|
when(mAppWidgetManager.getAppWidgetIds(any())).thenReturn(widgetIdsArray);
|
||||||
|
|
||||||
|
when(mUserManager.isUserUnlocked(any())).thenReturn(false);
|
||||||
|
|
||||||
|
NotificationChannel channel =
|
||||||
|
new NotificationChannel(TEST_CHANNEL_ID, TEST_CHANNEL_NAME, IMPORTANCE_DEFAULT);
|
||||||
|
channel.setConversationId(TEST_PARENT_CHANNEL_ID, TEST_CONVERSATION_ID);
|
||||||
|
|
||||||
|
mNoMan.issueChannelModification(TEST_PACKAGE_A,
|
||||||
|
UserHandle.getUserHandleForUid(0), channel, IMPORTANCE_HIGH);
|
||||||
|
mClock.advanceTime(MIN_LINGER_DURATION);
|
||||||
|
|
||||||
|
verify(mAppWidgetManager, never()).updateAppWidget(anyInt(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user