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

Commit e0d9846e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix SystemUI crash" into tm-dev

parents bf4e0558 975a3150
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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);
@@ -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 =
+26 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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()