Loading core/java/com/android/internal/app/ResolverActivity.java +51 −18 Original line number Diff line number Diff line Loading @@ -42,6 +42,8 @@ import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; Loading @@ -49,6 +51,7 @@ import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.os.PatternMatcher; import android.os.Process; import android.os.RemoteException; import android.os.StrictMode; import android.os.UserHandle; Loading @@ -56,7 +59,6 @@ import android.os.UserManager; import android.provider.MediaStore; import android.provider.Settings; import android.text.TextUtils; import android.util.IconDrawableFactory; import android.util.Log; import android.util.Slog; import android.view.LayoutInflater; Loading Loading @@ -131,7 +133,7 @@ public class ResolverActivity extends Activity { /** See {@link #setRetainInOnStop}. */ private boolean mRetainInOnStop; IconDrawableFactory mIconFactory; SimpleIconFactory mSimpleIconFactory; private final PackageMonitor mPackageMonitor = new PackageMonitor() { @Override public void onSomePackagesChanged() { Loading Loading @@ -309,7 +311,11 @@ public class ResolverActivity extends Activity { // as to mitigate Intent Capturing vulnerability mSupportsAlwaysUseOption = supportsAlwaysUseOption && !mUseLayoutForBrowsables; mIconFactory = IconDrawableFactory.newInstance(this, true); final int iconSize = getResources().getDimensionPixelSize(R.dimen.resolver_icon_size); final int badgeSize = getResources().getDimensionPixelSize(R.dimen.resolver_badge_size); mSimpleIconFactory = new SimpleIconFactory(this, mIconDpi, iconSize, badgeSize); mSimpleIconFactory.setWrapperBackgroundColor(Color.WHITE); if (configureContentView(mIntents, initialIntents, rList)) { return; } Loading Loading @@ -494,6 +500,7 @@ public class ResolverActivity extends Activity { } } @Nullable Drawable getIcon(Resources res, int resId) { Drawable result; try { Loading @@ -505,26 +512,52 @@ public class ResolverActivity extends Activity { return result; } /** * Loads the icon for the provided ResolveInfo. Defaults to using the application icon over * any IntentFilter or Activity icon to increase user understanding, with an exception for * applications that hold the right permission. Always attempts to use icon resources over * PackageManager loading mechanisms so badging can be done by iconloader. */ Drawable loadIconForResolveInfo(ResolveInfo ri) { Drawable dr; Drawable dr = null; // Allow for app icon override given the right permission if (PackageManager.PERMISSION_GRANTED == mPm.checkPermission( android.Manifest.permission.SUBSTITUTE_SHARE_TARGET_APP_NAME_AND_ICON, ri.activityInfo.applicationInfo.packageName)) { try { if (ri.resolvePackageName != null && ri.icon != 0) { dr = getIcon(mPm.getResourcesForApplication(ri.resolvePackageName), ri.icon); if (dr != null) { return mIconFactory.getShadowedIcon(dr); } } if (dr == null) { final int iconRes = ri.getIconResource(); if (iconRes != 0) { dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.packageName), iconRes); if (dr != null) { return mIconFactory.getShadowedIcon(dr); dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.packageName), iconRes); } } } catch (NameNotFoundException e) { Log.e(TAG, "Couldn't find resources for package", e); Log.e(TAG, "SUBSTITUTE_SHARE_TARGET_APP_NAME_AND_ICON permission granted but " + "couldn't find resources for package", e); } } return mIconFactory.getBadgedIcon(ri.activityInfo.applicationInfo); // Use app icons for better user association if (dr == null) { try { dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.applicationInfo), ri.activityInfo.applicationInfo.icon); } catch (NameNotFoundException ignore) { } } // Fall back to ApplicationInfo#loadIcon if nothing has been loaded if (dr == null) { dr = ri.activityInfo.applicationInfo.loadIcon(mPm); } return new BitmapDrawable(this.getResources(), mSimpleIconFactory.createUserBadgedIconBitmap(dr, Process.myUserHandle())); } @Override Loading core/java/com/android/internal/app/SimpleIconFactory.java 0 → 100644 +609 −0 File added.Preview size limit exceeded, changes collapsed. Show changes core/res/res/drawable/iconfactory_adaptive_icon_drawable_wrapper.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2019 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License --> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <background android:drawable="@color/white"/> <foreground> <drawable class="com.android.internal.app.SimpleIconFactory$FixedScaleDrawable"/> </foreground> </adaptive-icon> No newline at end of file core/res/res/layout/resolve_list_item.xml +2 −2 Original line number Diff line number Diff line Loading @@ -29,8 +29,8 @@ <!-- Activity icon when presenting dialog Size will be filled in by ResolverActivity --> <ImageView android:id="@+id/icon" android:layout_width="24dp" android:layout_height="24dp" android:layout_width="@dimen/resolver_icon_size" android:layout_height="@dimen/resolver_icon_size" android:layout_gravity="start|center_vertical" android:layout_marginStart="?attr/listPreferredItemPaddingStart" android:layout_marginTop="12dp" Loading core/res/res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -723,4 +723,6 @@ <dimen name="chooser_edge_margin_normal">24dp</dimen> <dimen name="chooser_preview_image_font_size">20sp</dimen> <dimen name="chooser_preview_width">-1px</dimen> <dimen name="resolver_icon_size">42dp</dimen> <dimen name="resolver_badge_size">18dp</dimen> </resources> Loading
core/java/com/android/internal/app/ResolverActivity.java +51 −18 Original line number Diff line number Diff line Loading @@ -42,6 +42,8 @@ import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; Loading @@ -49,6 +51,7 @@ import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.os.PatternMatcher; import android.os.Process; import android.os.RemoteException; import android.os.StrictMode; import android.os.UserHandle; Loading @@ -56,7 +59,6 @@ import android.os.UserManager; import android.provider.MediaStore; import android.provider.Settings; import android.text.TextUtils; import android.util.IconDrawableFactory; import android.util.Log; import android.util.Slog; import android.view.LayoutInflater; Loading Loading @@ -131,7 +133,7 @@ public class ResolverActivity extends Activity { /** See {@link #setRetainInOnStop}. */ private boolean mRetainInOnStop; IconDrawableFactory mIconFactory; SimpleIconFactory mSimpleIconFactory; private final PackageMonitor mPackageMonitor = new PackageMonitor() { @Override public void onSomePackagesChanged() { Loading Loading @@ -309,7 +311,11 @@ public class ResolverActivity extends Activity { // as to mitigate Intent Capturing vulnerability mSupportsAlwaysUseOption = supportsAlwaysUseOption && !mUseLayoutForBrowsables; mIconFactory = IconDrawableFactory.newInstance(this, true); final int iconSize = getResources().getDimensionPixelSize(R.dimen.resolver_icon_size); final int badgeSize = getResources().getDimensionPixelSize(R.dimen.resolver_badge_size); mSimpleIconFactory = new SimpleIconFactory(this, mIconDpi, iconSize, badgeSize); mSimpleIconFactory.setWrapperBackgroundColor(Color.WHITE); if (configureContentView(mIntents, initialIntents, rList)) { return; } Loading Loading @@ -494,6 +500,7 @@ public class ResolverActivity extends Activity { } } @Nullable Drawable getIcon(Resources res, int resId) { Drawable result; try { Loading @@ -505,26 +512,52 @@ public class ResolverActivity extends Activity { return result; } /** * Loads the icon for the provided ResolveInfo. Defaults to using the application icon over * any IntentFilter or Activity icon to increase user understanding, with an exception for * applications that hold the right permission. Always attempts to use icon resources over * PackageManager loading mechanisms so badging can be done by iconloader. */ Drawable loadIconForResolveInfo(ResolveInfo ri) { Drawable dr; Drawable dr = null; // Allow for app icon override given the right permission if (PackageManager.PERMISSION_GRANTED == mPm.checkPermission( android.Manifest.permission.SUBSTITUTE_SHARE_TARGET_APP_NAME_AND_ICON, ri.activityInfo.applicationInfo.packageName)) { try { if (ri.resolvePackageName != null && ri.icon != 0) { dr = getIcon(mPm.getResourcesForApplication(ri.resolvePackageName), ri.icon); if (dr != null) { return mIconFactory.getShadowedIcon(dr); } } if (dr == null) { final int iconRes = ri.getIconResource(); if (iconRes != 0) { dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.packageName), iconRes); if (dr != null) { return mIconFactory.getShadowedIcon(dr); dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.packageName), iconRes); } } } catch (NameNotFoundException e) { Log.e(TAG, "Couldn't find resources for package", e); Log.e(TAG, "SUBSTITUTE_SHARE_TARGET_APP_NAME_AND_ICON permission granted but " + "couldn't find resources for package", e); } } return mIconFactory.getBadgedIcon(ri.activityInfo.applicationInfo); // Use app icons for better user association if (dr == null) { try { dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.applicationInfo), ri.activityInfo.applicationInfo.icon); } catch (NameNotFoundException ignore) { } } // Fall back to ApplicationInfo#loadIcon if nothing has been loaded if (dr == null) { dr = ri.activityInfo.applicationInfo.loadIcon(mPm); } return new BitmapDrawable(this.getResources(), mSimpleIconFactory.createUserBadgedIconBitmap(dr, Process.myUserHandle())); } @Override Loading
core/java/com/android/internal/app/SimpleIconFactory.java 0 → 100644 +609 −0 File added.Preview size limit exceeded, changes collapsed. Show changes
core/res/res/drawable/iconfactory_adaptive_icon_drawable_wrapper.xml 0 → 100644 +24 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2019 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License --> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <background android:drawable="@color/white"/> <foreground> <drawable class="com.android.internal.app.SimpleIconFactory$FixedScaleDrawable"/> </foreground> </adaptive-icon> No newline at end of file
core/res/res/layout/resolve_list_item.xml +2 −2 Original line number Diff line number Diff line Loading @@ -29,8 +29,8 @@ <!-- Activity icon when presenting dialog Size will be filled in by ResolverActivity --> <ImageView android:id="@+id/icon" android:layout_width="24dp" android:layout_height="24dp" android:layout_width="@dimen/resolver_icon_size" android:layout_height="@dimen/resolver_icon_size" android:layout_gravity="start|center_vertical" android:layout_marginStart="?attr/listPreferredItemPaddingStart" android:layout_marginTop="12dp" Loading
core/res/res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -723,4 +723,6 @@ <dimen name="chooser_edge_margin_normal">24dp</dimen> <dimen name="chooser_preview_image_font_size">20sp</dimen> <dimen name="chooser_preview_width">-1px</dimen> <dimen name="resolver_icon_size">42dp</dimen> <dimen name="resolver_badge_size">18dp</dimen> </resources>