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

Commit c4788e1f authored by Roberto Perez's avatar Roberto Perez Committed by Android (Google) Code Review
Browse files

Merge "Adding a new category to mark car-optimized launcher activity"

parents 7e004f96 7ee1a7ac
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -222,9 +222,18 @@ public class ApplicationPackageManager extends PackageManager {

    @Override
    public Intent getLeanbackLaunchIntentForPackage(String packageName) {
        // Try to find a main leanback_launcher activity.
        return getLaunchIntentForPackageAndCategory(packageName, Intent.CATEGORY_LEANBACK_LAUNCHER);
    }

    @Override
    public Intent getCarLaunchIntentForPackage(String packageName) {
        return getLaunchIntentForPackageAndCategory(packageName, Intent.CATEGORY_CAR_LAUNCHER);
    }

    private Intent getLaunchIntentForPackageAndCategory(String packageName, String category) {
        // Try to find a main launcher activity for the given categories.
        Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
        intentToResolve.addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER);
        intentToResolve.addCategory(category);
        intentToResolve.setPackage(packageName);
        List<ResolveInfo> ris = queryIntentActivities(intentToResolve, 0);

+8 −0
Original line number Diff line number Diff line
@@ -3929,6 +3929,14 @@ public class Intent implements Parcelable, Cloneable {
     */
    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
    public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
    /**
     * Indicates the preferred entry-point activity when an application is launched from a Car
     * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
     * fallback, or exclude the application entirely.
     * @hide
     */
    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
    public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
    /**
     * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
     * @hide
+15 −0
Original line number Diff line number Diff line
@@ -3043,6 +3043,21 @@ public abstract class PackageManager {
     */
    public abstract @Nullable Intent getLeanbackLaunchIntentForPackage(@NonNull String packageName);

    /**
     * Return a "good" intent to launch a front-door Car activity in a
     * package, for use for example to implement an "open" button when browsing
     * through packages. The current implementation will look for a main
     * activity in the category {@link Intent#CATEGORY_CAR_LAUNCHER}, or
     * return null if no main car activities are found.
     *
     * @param packageName The name of the package to inspect.
     * @return Returns either a fully-qualified Intent that can be used to launch
     *         the main Car activity in the package, or null if the package
     *         does not contain such an activity.
     * @hide
     */
    public abstract @Nullable Intent getCarLaunchIntentForPackage(@NonNull String packageName);

    /**
     * Return an array of all of the POSIX secondary group IDs that have been
     * assigned to the given package.
+5 −0
Original line number Diff line number Diff line
@@ -86,6 +86,11 @@ public class PackageManagerStub extends PackageManager {
        return null;
    }

    @Override
    public Intent getCarLaunchIntentForPackage(String packageName) {
        return null;
    }

    @Override
    public int[] getPackageGids(String packageName) throws NameNotFoundException {
        return new int[0];
+6 −0
Original line number Diff line number Diff line
@@ -108,6 +108,12 @@ public class MockPackageManager extends PackageManager {
        throw new UnsupportedOperationException();
    }

    /** @hide */
    @Override
    public Intent getCarLaunchIntentForPackage(String packageName) {
        throw new UnsupportedOperationException();
    }

    @Override
    public int[] getPackageGids(String packageName) throws NameNotFoundException {
        throw new UnsupportedOperationException();