Loading packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java +2 −2 Original line number Diff line number Diff line Loading @@ -706,7 +706,7 @@ public class PeopleTileViewHelper { Drawable drawable = resolveImage(imageUri, mContext); Bitmap bitmap = convertDrawableToBitmap(drawable); views.setImageViewBitmap(R.id.image, bitmap); } catch (IOException e) { } catch (IOException | SecurityException e) { Log.e(TAG, "Could not decode image: " + e); // If we couldn't load the image, show text that we have a new image. views.setTextViewText(R.id.text_content, newImageDescription); Loading Loading @@ -754,7 +754,7 @@ public class PeopleTileViewHelper { return views; } private Drawable resolveImage(Uri uri, Context context) throws IOException { Drawable resolveImage(Uri uri, Context context) throws IOException { final ImageDecoder.Source source = ImageDecoder.createSource(context.getContentResolver(), uri); final Drawable drawable = Loading packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java +26 −0 Original line number Diff line number Diff line Loading @@ -33,8 +33,12 @@ import static com.android.systemui.people.PeopleSpaceUtils.VALID_CONTACT; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.app.people.ConversationStatus; Loading @@ -44,6 +48,7 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Icon; import android.net.Uri; import android.os.UserHandle; Loading Loading @@ -580,6 +585,27 @@ public class PeopleTileViewHelperTest extends SysuiTestCase { assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout); } @Test public void testCreateRemoteViewsWithNotificationContent() throws Exception { PeopleTileViewHelper helper = spy(getPeopleTileViewHelper(PERSON_TILE)); doReturn(new BitmapDrawable()).when(helper).resolveImage(any(), any()); RemoteViews views = helper.getViews(); View result = views.apply(mContext, null); assertEquals(View.VISIBLE, result.findViewById(R.id.image).getVisibility()); } @Test public void testCreateRemoteViewsWithInvalidNotificationContent() throws Exception { PeopleTileViewHelper helper = spy(getPeopleTileViewHelper(PERSON_TILE)); doThrow(SecurityException.class).when(helper).resolveImage(any(), any()); RemoteViews views = helper.getViews(); View result = views.apply(mContext, null); assertEquals(View.GONE, result.findViewById(R.id.image).getVisibility()); assertEquals(View.VISIBLE, result.findViewById(R.id.text_content).getVisibility()); } @Test public void testCreateRemoteViewsWithUserQuieted() { PeopleSpaceTile tile = PERSON_TILE.toBuilder() Loading Loading
packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java +2 −2 Original line number Diff line number Diff line Loading @@ -706,7 +706,7 @@ public class PeopleTileViewHelper { Drawable drawable = resolveImage(imageUri, mContext); Bitmap bitmap = convertDrawableToBitmap(drawable); views.setImageViewBitmap(R.id.image, bitmap); } catch (IOException e) { } catch (IOException | SecurityException e) { Log.e(TAG, "Could not decode image: " + e); // If we couldn't load the image, show text that we have a new image. views.setTextViewText(R.id.text_content, newImageDescription); Loading Loading @@ -754,7 +754,7 @@ public class PeopleTileViewHelper { return views; } private Drawable resolveImage(Uri uri, Context context) throws IOException { Drawable resolveImage(Uri uri, Context context) throws IOException { final ImageDecoder.Source source = ImageDecoder.createSource(context.getContentResolver(), uri); final Drawable drawable = Loading
packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java +26 −0 Original line number Diff line number Diff line Loading @@ -33,8 +33,12 @@ import static com.android.systemui.people.PeopleSpaceUtils.VALID_CONTACT; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.app.people.ConversationStatus; Loading @@ -44,6 +48,7 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Icon; import android.net.Uri; import android.os.UserHandle; Loading Loading @@ -580,6 +585,27 @@ public class PeopleTileViewHelperTest extends SysuiTestCase { assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout); } @Test public void testCreateRemoteViewsWithNotificationContent() throws Exception { PeopleTileViewHelper helper = spy(getPeopleTileViewHelper(PERSON_TILE)); doReturn(new BitmapDrawable()).when(helper).resolveImage(any(), any()); RemoteViews views = helper.getViews(); View result = views.apply(mContext, null); assertEquals(View.VISIBLE, result.findViewById(R.id.image).getVisibility()); } @Test public void testCreateRemoteViewsWithInvalidNotificationContent() throws Exception { PeopleTileViewHelper helper = spy(getPeopleTileViewHelper(PERSON_TILE)); doThrow(SecurityException.class).when(helper).resolveImage(any(), any()); RemoteViews views = helper.getViews(); View result = views.apply(mContext, null); assertEquals(View.GONE, result.findViewById(R.id.image).getVisibility()); assertEquals(View.VISIBLE, result.findViewById(R.id.text_content).getVisibility()); } @Test public void testCreateRemoteViewsWithUserQuieted() { PeopleSpaceTile tile = PERSON_TILE.toBuilder() Loading