Disallow loading icon from content URI to PipMenu

Bug: 278246904
Test: manually, with the PoC app attached to the bug
Merged-In: Ib3f5b8b6b9ce644fdf1173548d9078e4d969ae2e 
Change-Id: Ib3f5b8b6b9ce644fdf1173548d9078e4d969ae2e
This commit is contained in:
Hongwei Wang
2023-05-25 12:18:44 -07:00
parent fb2739848a
commit 1aee65603e

View File

@@ -45,6 +45,7 @@ import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@@ -509,13 +510,19 @@ public class PipMenuView extends FrameLayout {
final boolean isCloseAction = mCloseAction != null && Objects.equals( final boolean isCloseAction = mCloseAction != null && Objects.equals(
mCloseAction.getActionIntent(), action.getActionIntent()); mCloseAction.getActionIntent(), action.getActionIntent());
// TODO: Check if the action drawable has changed before we reload it final int iconType = action.getIcon().getType();
action.getIcon().loadDrawableAsync(mContext, d -> { if (iconType == Icon.TYPE_URI || iconType == Icon.TYPE_URI_ADAPTIVE_BITMAP) {
if (d != null) { // Disallow loading icon from content URI
d.setTint(Color.WHITE); actionView.setImageDrawable(null);
actionView.setImageDrawable(d); } else {
} // TODO: Check if the action drawable has changed before we reload it
}, mMainHandler); action.getIcon().loadDrawableAsync(mContext, d -> {
if (d != null) {
d.setTint(Color.WHITE);
actionView.setImageDrawable(d);
}
}, mMainHandler);
}
actionView.setCustomCloseBackgroundVisibility( actionView.setCustomCloseBackgroundVisibility(
isCloseAction ? View.VISIBLE : View.GONE); isCloseAction ? View.VISIBLE : View.GONE);
actionView.setContentDescription(action.getContentDescription()); actionView.setContentDescription(action.getContentDescription());