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

Commit 91726f4e authored by Jose Lima's avatar Jose Lima Committed by Android (Google) Code Review
Browse files

Merge "Add banner attribute to app manifest" into klp-modular-dev

parents aaaeb6a2 f78e312d
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -311,6 +311,7 @@ package android {
    field public static final int backgroundSplit = 16843659; // 0x101038b
    field public static final int backgroundStacked = 16843658; // 0x101038a
    field public static final int backupAgent = 16843391; // 0x101027f
    field public static final int banner = 16843762; // 0x10103f2
    field public static final int baseline = 16843548; // 0x101031c
    field public static final int baselineAlignBottom = 16843042; // 0x1010122
    field public static final int baselineAligned = 16843046; // 0x1010126
@@ -7079,6 +7080,7 @@ package android.content.pm {
    ctor public ComponentInfo();
    ctor public ComponentInfo(android.content.pm.ComponentInfo);
    ctor protected ComponentInfo(android.os.Parcel);
    method public final int getBannerResource();
    method public final int getIconResource();
    method public final int getLogoResource();
    method public boolean isEnabled();
@@ -7182,11 +7184,13 @@ package android.content.pm {
    ctor protected PackageItemInfo(android.os.Parcel);
    method protected void dumpBack(android.util.Printer, java.lang.String);
    method protected void dumpFront(android.util.Printer, java.lang.String);
    method public android.graphics.drawable.Drawable loadBanner(android.content.pm.PackageManager);
    method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager);
    method public java.lang.CharSequence loadLabel(android.content.pm.PackageManager);
    method public android.graphics.drawable.Drawable loadLogo(android.content.pm.PackageManager);
    method public android.content.res.XmlResourceParser loadXmlMetaData(android.content.pm.PackageManager, java.lang.String);
    method public void writeToParcel(android.os.Parcel, int);
    field public int banner;
    field public int icon;
    field public int labelRes;
    field public int logo;
@@ -7214,12 +7218,16 @@ package android.content.pm {
    method public abstract void clearPackagePreferredActivities(java.lang.String);
    method public abstract java.lang.String[] currentToCanonicalPackageNames(java.lang.String[]);
    method public abstract void extendVerificationTimeout(int, int, long);
    method public abstract android.graphics.drawable.Drawable getActivityBanner(android.content.ComponentName) throws android.content.pm.PackageManager.NameNotFoundException;
    method public abstract android.graphics.drawable.Drawable getActivityBanner(android.content.Intent) throws android.content.pm.PackageManager.NameNotFoundException;
    method public abstract android.graphics.drawable.Drawable getActivityIcon(android.content.ComponentName) throws android.content.pm.PackageManager.NameNotFoundException;
    method public abstract android.graphics.drawable.Drawable getActivityIcon(android.content.Intent) throws android.content.pm.PackageManager.NameNotFoundException;
    method public abstract android.content.pm.ActivityInfo getActivityInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
    method public abstract android.graphics.drawable.Drawable getActivityLogo(android.content.ComponentName) throws android.content.pm.PackageManager.NameNotFoundException;
    method public abstract android.graphics.drawable.Drawable getActivityLogo(android.content.Intent) throws android.content.pm.PackageManager.NameNotFoundException;
    method public abstract java.util.List<android.content.pm.PermissionGroupInfo> getAllPermissionGroups(int);
    method public abstract android.graphics.drawable.Drawable getApplicationBanner(android.content.pm.ApplicationInfo);
    method public abstract android.graphics.drawable.Drawable getApplicationBanner(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
    method public abstract int getApplicationEnabledSetting(java.lang.String);
    method public abstract android.graphics.drawable.Drawable getApplicationIcon(android.content.pm.ApplicationInfo);
    method public abstract android.graphics.drawable.Drawable getApplicationIcon(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
@@ -24069,12 +24077,16 @@ package android.test.mock {
    method public void clearPackagePreferredActivities(java.lang.String);
    method public java.lang.String[] currentToCanonicalPackageNames(java.lang.String[]);
    method public void extendVerificationTimeout(int, int, long);
    method public android.graphics.drawable.Drawable getActivityBanner(android.content.ComponentName) throws android.content.pm.PackageManager.NameNotFoundException;
    method public android.graphics.drawable.Drawable getActivityBanner(android.content.Intent) throws android.content.pm.PackageManager.NameNotFoundException;
    method public android.graphics.drawable.Drawable getActivityIcon(android.content.ComponentName) throws android.content.pm.PackageManager.NameNotFoundException;
    method public android.graphics.drawable.Drawable getActivityIcon(android.content.Intent) throws android.content.pm.PackageManager.NameNotFoundException;
    method public android.content.pm.ActivityInfo getActivityInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
    method public android.graphics.drawable.Drawable getActivityLogo(android.content.ComponentName) throws android.content.pm.PackageManager.NameNotFoundException;
    method public android.graphics.drawable.Drawable getActivityLogo(android.content.Intent) throws android.content.pm.PackageManager.NameNotFoundException;
    method public java.util.List<android.content.pm.PermissionGroupInfo> getAllPermissionGroups(int);
    method public android.graphics.drawable.Drawable getApplicationBanner(android.content.pm.ApplicationInfo);
    method public android.graphics.drawable.Drawable getApplicationBanner(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
    method public int getApplicationEnabledSetting(java.lang.String);
    method public android.graphics.drawable.Drawable getApplicationIcon(android.content.pm.ApplicationInfo);
    method public android.graphics.drawable.Drawable getApplicationIcon(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
+33 −0
Original line number Diff line number Diff line
@@ -728,6 +728,39 @@ final class ApplicationPackageManager extends PackageManager {
        return getApplicationIcon(getApplicationInfo(packageName, 0));
    }

    @Override
    public Drawable getActivityBanner(ComponentName activityName)
            throws NameNotFoundException {
        return getActivityInfo(activityName, 0).loadBanner(this);
    }

    @Override
    public Drawable getActivityBanner(Intent intent)
            throws NameNotFoundException {
        if (intent.getComponent() != null) {
            return getActivityBanner(intent.getComponent());
        }

        ResolveInfo info = resolveActivity(
                intent, PackageManager.MATCH_DEFAULT_ONLY);
        if (info != null) {
            return info.activityInfo.loadBanner(this);
        }

        throw new NameNotFoundException(intent.toUri(0));
    }

    @Override
    public Drawable getApplicationBanner(ApplicationInfo info) {
        return info.loadBanner(this);
    }

    @Override
    public Drawable getApplicationBanner(String packageName)
            throws NameNotFoundException {
        return getApplicationBanner(getApplicationInfo(packageName, 0));
    }

    @Override
    public Drawable getActivityLogo(ComponentName activityName)
            throws NameNotFoundException {
+18 −0
Original line number Diff line number Diff line
@@ -128,6 +128,17 @@ public class ComponentInfo extends PackageItemInfo {
        return logo != 0 ? logo : applicationInfo.logo;
    }
    
    /**
     * Return the banner resource identifier to use for this component. If the
     * component defines a banner, that is used; else, the application banner is
     * used.
     *
     * @return The banner associated with this component.
     */
    public final int getBannerResource() {
        return banner != 0 ? banner : applicationInfo.banner;
    }

    protected void dumpFront(Printer pw, String prefix) {
        super.dumpFront(pw, prefix);
        pw.println(prefix + "enabled=" + enabled + " exported=" + exported
@@ -172,6 +183,13 @@ public class ComponentInfo extends PackageItemInfo {
        return applicationInfo.loadIcon(pm);
    }
    
    /**
     * @hide
     */
    @Override protected Drawable loadDefaultBanner(PackageManager pm) {
        return applicationInfo.loadBanner(pm);
    }

    /**
     * @hide
     */
+49 −3
Original line number Diff line number Diff line
@@ -66,6 +66,12 @@ public class PackageItemInfo {
     */
    public int icon;
    
    /**
     * A drawable resource identifier (in the package's resources) of this
     * component's banner.  From the "banner" attribute or, if not set, 0.
     */
    public int banner;

    /**
     * A drawable resource identifier (in the package's resources) of this
     * component's logo. Logos may be larger/wider than icons and are
@@ -92,6 +98,7 @@ public class PackageItemInfo {
        nonLocalizedLabel = orig.nonLocalizedLabel;
        if (nonLocalizedLabel != null) nonLocalizedLabel = nonLocalizedLabel.toString().trim();
        icon = orig.icon;
        banner = orig.banner;
        logo = orig.logo;
        metaData = orig.metaData;
    }
@@ -145,6 +152,27 @@ public class PackageItemInfo {
        return loadDefaultIcon(pm);
    }
    
    /**
     * Retrieve the current graphical banner associated with this item.  This
     * will call back on the given PackageManager to load the banner from
     * the application.
     *
     * @param pm A PackageManager from which the banner can be loaded; usually
     * the PackageManager from which you originally retrieved this item.
     *
     * @return Returns a Drawable containing the item's banner.  If the item
     * does not have a banner, this method will return null.
     */
    public Drawable loadBanner(PackageManager pm) {
        if (banner != 0) {
            Drawable dr = pm.getDrawable(packageName, banner, getApplicationInfo());
            if (dr != null) {
                return dr;
            }
        }
        return loadDefaultBanner(pm);
    }

    /**
     * Retrieve the default graphical icon associated with this item.
     * 
@@ -160,6 +188,21 @@ public class PackageItemInfo {
        return pm.getDefaultActivityIcon();
    }

    /**
     * Retrieve the default graphical banner associated with this item.
     *
     * @param pm A PackageManager from which the banner can be loaded; usually
     * the PackageManager from which you originally retrieved this item.
     *
     * @return Returns a Drawable containing the item's default banner
     * or null if no default logo is available.
     *
     * @hide
     */
    protected Drawable loadDefaultBanner(PackageManager pm) {
        return null;
    }

    /**
     * Retrieve the current graphical logo associated with this item. This
     * will call back on the given PackageManager to load the logo from
@@ -224,10 +267,11 @@ public class PackageItemInfo {
            pw.println(prefix + "name=" + name);
        }
        pw.println(prefix + "packageName=" + packageName);
        if (labelRes != 0 || nonLocalizedLabel != null || icon != 0) {
        if (labelRes != 0 || nonLocalizedLabel != null || icon != 0 || banner != 0) {
            pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
                    + " nonLocalizedLabel=" + nonLocalizedLabel
                    + " icon=0x" + Integer.toHexString(icon));
                    + " icon=0x" + Integer.toHexString(icon)
                    + " banner=0x" + Integer.toHexString(banner));
        }
    }
    
@@ -243,6 +287,7 @@ public class PackageItemInfo {
        dest.writeInt(icon);
        dest.writeInt(logo);
        dest.writeBundle(metaData);
        dest.writeInt(banner);
    }
    
    protected PackageItemInfo(Parcel source) {
@@ -254,6 +299,7 @@ public class PackageItemInfo {
        icon = source.readInt();
        logo = source.readInt();
        metaData = source.readBundle();
        banner = source.readInt();
    }

    /**
+68 −10
Original line number Diff line number Diff line
@@ -2391,6 +2391,40 @@ public abstract class PackageManager {
    public abstract Drawable getActivityIcon(Intent intent)
            throws NameNotFoundException;

    /**
     * Retrieve the banner associated with an activity. Given the full name of
     * an activity, retrieves the information about it and calls
     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
     * banner. If the activity cannot be found, NameNotFoundException is thrown.
     *
     * @param activityName Name of the activity whose banner is to be retrieved.
     * @return Returns the image of the banner, or null if the activity has no
     *         banner specified.
     * @throws NameNotFoundException Thrown if the resources for the given
     *             activity could not be loaded.
     * @see #getActivityBanner(Intent)
     */
    public abstract Drawable getActivityBanner(ComponentName activityName)
            throws NameNotFoundException;

    /**
     * Retrieve the banner associated with an Intent. If intent.getClassName()
     * is set, this simply returns the result of
     * getActivityBanner(intent.getClassName()). Otherwise it resolves the
     * intent's component and returns the banner associated with the resolved
     * component. If intent.getClassName() cannot be found or the Intent cannot
     * be resolved to a component, NameNotFoundException is thrown.
     *
     * @param intent The intent for which you would like to retrieve a banner.
     * @return Returns the image of the banner, or null if the activity has no
     *         banner specified.
     * @throws NameNotFoundException Thrown if the resources for application
     *             matching the given intent could not be loaded.
     * @see #getActivityBanner(ComponentName)
     */
    public abstract Drawable getActivityBanner(Intent intent)
            throws NameNotFoundException;

    /**
     * Return the generic icon for an activity that is used when no specific
     * icon is defined.
@@ -2432,19 +2466,43 @@ public abstract class PackageManager {
            throws NameNotFoundException;

    /**
     * Retrieve the logo associated with an activity.  Given the full name of
     * an activity, retrieves the information about it and calls
     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its logo.
     * If the activity cannot be found, NameNotFoundException is thrown.
     * Retrieve the banner associated with an application.
     *
     * @param activityName Name of the activity whose logo is to be retrieved.
     * @param info Information about application being queried.
     * @return Returns the image of the banner or null if the application has no
     *         banner specified.
     * @see #getApplicationBanner(String)
     */
    public abstract Drawable getApplicationBanner(ApplicationInfo info);

    /**
     * Retrieve the banner associated with an application. Given the name of the
     * application's package, retrieves the information about it and calls
     * getApplicationIcon() to return its banner. If the application cannot be
     * found, NameNotFoundException is thrown.
     *
     * @return Returns the image of the logo or null if the activity has no
     * logo specified.
     * @param packageName Name of the package whose application banner is to be
     *            retrieved.
     * @return Returns the image of the banner or null if the application has no
     *         banner specified.
     * @throws NameNotFoundException Thrown if the resources for the given
     *             application could not be loaded.
     * @see #getApplicationBanner(ApplicationInfo)
     */
    public abstract Drawable getApplicationBanner(String packageName)
            throws NameNotFoundException;

    /**
     * Retrieve the logo associated with an activity. Given the full name of an
     * activity, retrieves the information about it and calls
     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
     * logo. If the activity cannot be found, NameNotFoundException is thrown.
     *
     * @param activityName Name of the activity whose logo is to be retrieved.
     * @return Returns the image of the logo or null if the activity has no logo
     *         specified.
     * @throws NameNotFoundException Thrown if the resources for the given
     *             activity could not be loaded.
     *
     * @see #getActivityLogo(Intent)
     */
    public abstract Drawable getActivityLogo(ComponentName activityName)
Loading