Loading PREUPLOAD.cfg +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ hidden_api_txt_checksorted_hook = ${REPO_ROOT}/tools/platform-compat/hiddenapi/c hidden_api_txt_exclude_hook = ${REPO_ROOT}/frameworks/base/tools/hiddenapi/exclude.sh ${PREUPLOAD_COMMIT} ${REPO_ROOT} ktfmt_hook = ${REPO_ROOT}/external/ktfmt/ktfmt.py --check -i ${REPO_ROOT}/frameworks/base/ktfmt_includes.txt ${PREUPLOAD_FILES} ktfmt_hook = ${REPO_ROOT}/external/ktfmt/ktfmt.py --check -i ${REPO_ROOT}/frameworks/base/packages/SystemUI/ktfmt_includes.txt ${PREUPLOAD_FILES} ktlint_hook = ${REPO_ROOT}/prebuilts/ktlint/ktlint.py -f ${PREUPLOAD_FILES} Loading core/java/android/app/ambientcontext/AmbientContextManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ public final class AmbientContextManager { * eventTypes.add(AmbientContextEvent.EVENT_SNORE); * * // Create Consumer * Consumer<Integer> statusConsumer = response -> { * Consumer<Integer> statusConsumer = status -> { * int status = status.getStatusCode(); * if (status == AmbientContextManager.STATUS_SUCCESS) { * // Show user it's enabled Loading core/java/android/util/FeatureFlagUtils.java +7 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,12 @@ public class FeatureFlagUtils { public static final String SETTINGS_APP_LOCALE_OPT_IN_ENABLED = "settings_app_locale_opt_in_enabled"; /** * Launch the Volume panel in SystemUI. * @hide */ public static final String SETTINGS_VOLUME_PANEL_IN_SYSTEMUI = "settings_volume_panel_in_systemui"; /** @hide */ public static final String SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS = Loading Loading @@ -105,6 +111,7 @@ public class FeatureFlagUtils { DEFAULT_FLAGS.put(SETTINGS_SUPPORT_LARGE_SCREEN, "true"); DEFAULT_FLAGS.put("settings_search_always_expand", "true"); DEFAULT_FLAGS.put(SETTINGS_APP_LOCALE_OPT_IN_ENABLED, "true"); DEFAULT_FLAGS.put(SETTINGS_VOLUME_PANEL_IN_SYSTEMUI, "false"); DEFAULT_FLAGS.put(SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS, "true"); DEFAULT_FLAGS.put(SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME, "true"); DEFAULT_FLAGS.put(SETTINGS_HIDE_SECOND_LAYER_PAGE_NAVIGATE_UP_BUTTON_IN_TWO_PANE, "true"); Loading core/java/com/android/internal/widget/LocalImageResolver.java +61 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.internal.widget; import android.annotation.DrawableRes; import android.annotation.Nullable; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.ImageDecoder; Loading Loading @@ -109,13 +111,13 @@ public class LocalImageResolver { } break; case Icon.TYPE_RESOURCE: if (!(TextUtils.isEmpty(icon.getResPackage()) || context.getPackageName().equals(icon.getResPackage()))) { // We can't properly resolve icons from other packages here, so fall back. Resources res = resolveResourcesForIcon(context, icon); if (res == null) { // We couldn't resolve resources properly, fall back to icon loading. return icon.loadDrawable(context); } Drawable result = resolveImage(icon.getResId(), context, maxWidth, maxHeight); Drawable result = resolveImage(res, icon.getResId(), maxWidth, maxHeight); if (result != null) { return tintDrawable(icon, result); } Loading Loading @@ -158,6 +160,13 @@ public class LocalImageResolver { return resolveImage(source, maxWidth, maxHeight); } @Nullable private static Drawable resolveImage(Resources res, @DrawableRes int resId, int maxWidth, int maxHeight) { final ImageDecoder.Source source = ImageDecoder.createSource(res, resId); return resolveImage(source, maxWidth, maxHeight); } @Nullable private static Drawable resolveBitmapImage(Icon icon, Context context, int maxWidth, int maxHeight) { Loading Loading @@ -259,4 +268,52 @@ public class LocalImageResolver { } return icon.getUri(); } /** * Resolves the correct resources package for a given Icon - it may come from another * package. * * @see Icon#loadDrawableInner(Context) * @hide * * @return resources instance if the operation succeeded, null otherwise */ @Nullable @VisibleForTesting public static Resources resolveResourcesForIcon(Context context, Icon icon) { if (icon.getType() != Icon.TYPE_RESOURCE) { return null; } // Icons cache resolved resources, use cache if available. Resources res = icon.getResources(); if (res != null) { return res; } String resPackage = icon.getResPackage(); // No package means we try to use current context. if (TextUtils.isEmpty(resPackage) || context.getPackageName().equals(resPackage)) { return context.getResources(); } if ("android".equals(resPackage)) { return Resources.getSystem(); } final PackageManager pm = context.getPackageManager(); try { ApplicationInfo ai = pm.getApplicationInfo(resPackage, PackageManager.MATCH_UNINSTALLED_PACKAGES | PackageManager.GET_SHARED_LIBRARY_FILES); if (ai != null) { return pm.getResourcesForApplication(ai); } } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, String.format("Unable to resolve package %s for icon %s", resPackage, icon)); return null; } return null; } } core/tests/coretests/src/com/android/internal/widget/LocalImageResolverTest.java +47 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.internal.widget; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.BitmapFactory; import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.BitmapDrawable; Loading Loading @@ -279,4 +281,49 @@ public class LocalImageResolverTest { // This drawable must not be loaded - if it was, the code ignored the package specification. assertThat(d).isNull(); } @Test public void resolveResourcesForIcon_notAResourceIcon_returnsNull() { Icon icon = Icon.createWithContentUri(Uri.parse("some_uri")); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon)).isNull(); } @Test public void resolveResourcesForIcon_localPackageIcon_returnsPackageResources() { Icon icon = Icon.createWithResource(mContext, R.drawable.test32x24); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon)) .isSameInstanceAs(mContext.getResources()); } @Test public void resolveResourcesForIcon_iconWithoutPackageSpecificed_returnsPackageResources() { Icon icon = Icon.createWithResource("", R.drawable.test32x24); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon)) .isSameInstanceAs(mContext.getResources()); } @Test public void resolveResourcesForIcon_systemPackageSpecified_returnsSystemPackage() { Icon icon = Icon.createWithResource("android", R.drawable.test32x24); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon)).isSameInstanceAs( Resources.getSystem()); } @Test public void resolveResourcesForIcon_differentPackageSpecified_returnsPackageResources() throws PackageManager.NameNotFoundException { String pkg = "com.android.settings"; Resources res = mContext.getPackageManager().getResourcesForApplication(pkg); int resId = res.getIdentifier("ic_android", "drawable", pkg); Icon icon = Icon.createWithResource(pkg, resId); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon).getDrawable(resId, mContext.getTheme())).isNotNull(); } @Test public void resolveResourcesForIcon_invalidPackageSpecified_returnsNull() { Icon icon = Icon.createWithResource("invalid.package", R.drawable.test32x24); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon)).isNull(); } } Loading
PREUPLOAD.cfg +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ hidden_api_txt_checksorted_hook = ${REPO_ROOT}/tools/platform-compat/hiddenapi/c hidden_api_txt_exclude_hook = ${REPO_ROOT}/frameworks/base/tools/hiddenapi/exclude.sh ${PREUPLOAD_COMMIT} ${REPO_ROOT} ktfmt_hook = ${REPO_ROOT}/external/ktfmt/ktfmt.py --check -i ${REPO_ROOT}/frameworks/base/ktfmt_includes.txt ${PREUPLOAD_FILES} ktfmt_hook = ${REPO_ROOT}/external/ktfmt/ktfmt.py --check -i ${REPO_ROOT}/frameworks/base/packages/SystemUI/ktfmt_includes.txt ${PREUPLOAD_FILES} ktlint_hook = ${REPO_ROOT}/prebuilts/ktlint/ktlint.py -f ${PREUPLOAD_FILES} Loading
core/java/android/app/ambientcontext/AmbientContextManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ public final class AmbientContextManager { * eventTypes.add(AmbientContextEvent.EVENT_SNORE); * * // Create Consumer * Consumer<Integer> statusConsumer = response -> { * Consumer<Integer> statusConsumer = status -> { * int status = status.getStatusCode(); * if (status == AmbientContextManager.STATUS_SUCCESS) { * // Show user it's enabled Loading
core/java/android/util/FeatureFlagUtils.java +7 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,12 @@ public class FeatureFlagUtils { public static final String SETTINGS_APP_LOCALE_OPT_IN_ENABLED = "settings_app_locale_opt_in_enabled"; /** * Launch the Volume panel in SystemUI. * @hide */ public static final String SETTINGS_VOLUME_PANEL_IN_SYSTEMUI = "settings_volume_panel_in_systemui"; /** @hide */ public static final String SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS = Loading Loading @@ -105,6 +111,7 @@ public class FeatureFlagUtils { DEFAULT_FLAGS.put(SETTINGS_SUPPORT_LARGE_SCREEN, "true"); DEFAULT_FLAGS.put("settings_search_always_expand", "true"); DEFAULT_FLAGS.put(SETTINGS_APP_LOCALE_OPT_IN_ENABLED, "true"); DEFAULT_FLAGS.put(SETTINGS_VOLUME_PANEL_IN_SYSTEMUI, "false"); DEFAULT_FLAGS.put(SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS, "true"); DEFAULT_FLAGS.put(SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME, "true"); DEFAULT_FLAGS.put(SETTINGS_HIDE_SECOND_LAYER_PAGE_NAVIGATE_UP_BUTTON_IN_TWO_PANE, "true"); Loading
core/java/com/android/internal/widget/LocalImageResolver.java +61 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.internal.widget; import android.annotation.DrawableRes; import android.annotation.Nullable; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.ImageDecoder; Loading Loading @@ -109,13 +111,13 @@ public class LocalImageResolver { } break; case Icon.TYPE_RESOURCE: if (!(TextUtils.isEmpty(icon.getResPackage()) || context.getPackageName().equals(icon.getResPackage()))) { // We can't properly resolve icons from other packages here, so fall back. Resources res = resolveResourcesForIcon(context, icon); if (res == null) { // We couldn't resolve resources properly, fall back to icon loading. return icon.loadDrawable(context); } Drawable result = resolveImage(icon.getResId(), context, maxWidth, maxHeight); Drawable result = resolveImage(res, icon.getResId(), maxWidth, maxHeight); if (result != null) { return tintDrawable(icon, result); } Loading Loading @@ -158,6 +160,13 @@ public class LocalImageResolver { return resolveImage(source, maxWidth, maxHeight); } @Nullable private static Drawable resolveImage(Resources res, @DrawableRes int resId, int maxWidth, int maxHeight) { final ImageDecoder.Source source = ImageDecoder.createSource(res, resId); return resolveImage(source, maxWidth, maxHeight); } @Nullable private static Drawable resolveBitmapImage(Icon icon, Context context, int maxWidth, int maxHeight) { Loading Loading @@ -259,4 +268,52 @@ public class LocalImageResolver { } return icon.getUri(); } /** * Resolves the correct resources package for a given Icon - it may come from another * package. * * @see Icon#loadDrawableInner(Context) * @hide * * @return resources instance if the operation succeeded, null otherwise */ @Nullable @VisibleForTesting public static Resources resolveResourcesForIcon(Context context, Icon icon) { if (icon.getType() != Icon.TYPE_RESOURCE) { return null; } // Icons cache resolved resources, use cache if available. Resources res = icon.getResources(); if (res != null) { return res; } String resPackage = icon.getResPackage(); // No package means we try to use current context. if (TextUtils.isEmpty(resPackage) || context.getPackageName().equals(resPackage)) { return context.getResources(); } if ("android".equals(resPackage)) { return Resources.getSystem(); } final PackageManager pm = context.getPackageManager(); try { ApplicationInfo ai = pm.getApplicationInfo(resPackage, PackageManager.MATCH_UNINSTALLED_PACKAGES | PackageManager.GET_SHARED_LIBRARY_FILES); if (ai != null) { return pm.getResourcesForApplication(ai); } } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, String.format("Unable to resolve package %s for icon %s", resPackage, icon)); return null; } return null; } }
core/tests/coretests/src/com/android/internal/widget/LocalImageResolverTest.java +47 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.internal.widget; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.BitmapFactory; import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.BitmapDrawable; Loading Loading @@ -279,4 +281,49 @@ public class LocalImageResolverTest { // This drawable must not be loaded - if it was, the code ignored the package specification. assertThat(d).isNull(); } @Test public void resolveResourcesForIcon_notAResourceIcon_returnsNull() { Icon icon = Icon.createWithContentUri(Uri.parse("some_uri")); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon)).isNull(); } @Test public void resolveResourcesForIcon_localPackageIcon_returnsPackageResources() { Icon icon = Icon.createWithResource(mContext, R.drawable.test32x24); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon)) .isSameInstanceAs(mContext.getResources()); } @Test public void resolveResourcesForIcon_iconWithoutPackageSpecificed_returnsPackageResources() { Icon icon = Icon.createWithResource("", R.drawable.test32x24); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon)) .isSameInstanceAs(mContext.getResources()); } @Test public void resolveResourcesForIcon_systemPackageSpecified_returnsSystemPackage() { Icon icon = Icon.createWithResource("android", R.drawable.test32x24); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon)).isSameInstanceAs( Resources.getSystem()); } @Test public void resolveResourcesForIcon_differentPackageSpecified_returnsPackageResources() throws PackageManager.NameNotFoundException { String pkg = "com.android.settings"; Resources res = mContext.getPackageManager().getResourcesForApplication(pkg); int resId = res.getIdentifier("ic_android", "drawable", pkg); Icon icon = Icon.createWithResource(pkg, resId); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon).getDrawable(resId, mContext.getTheme())).isNotNull(); } @Test public void resolveResourcesForIcon_invalidPackageSpecified_returnsNull() { Icon icon = Icon.createWithResource("invalid.package", R.drawable.test32x24); assertThat(LocalImageResolver.resolveResourcesForIcon(mContext, icon)).isNull(); } }