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

Commit 7560c256 authored by Christopher Tate's avatar Christopher Tate Committed by Android (Google) Code Review
Browse files

Merge "Add hidden API for querying available 'home' activities" into klp-dev

parents 0bf2ed90 a2a0850d
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1250,6 +1250,16 @@ final class ApplicationPackageManager extends PackageManager {
        return 0;
    }

    @Override
    public ComponentName getHomeActivities(List<ResolveInfo> outActivities) {
        try {
            return mPM.getHomeActivities(outActivities);
        } catch (RemoteException e) {
            // Should never happen!
        }
        return null;
    }

    @Override
    public void setComponentEnabledSetting(ComponentName componentName,
                                           int newState, int flags) {
+6 −0
Original line number Diff line number Diff line
@@ -233,6 +233,12 @@ interface IPackageManager {
    int getPreferredActivities(out List<IntentFilter> outFilters,
            out List<ComponentName> outActivities, String packageName);

    /**
     * Report the set of 'Home' activity candidates, plus (if any) which of them
     * is the current "always use this one" setting.
     */
     ComponentName getHomeActivities(out List<ResolveInfo> outHomeCandidates);

    /**
     * As per {@link android.content.pm.PackageManager#setComponentEnabledSetting}.
     */
+7 −0
Original line number Diff line number Diff line
@@ -3026,6 +3026,13 @@ public abstract class PackageManager {
    public abstract int getPreferredActivities(List<IntentFilter> outFilters,
            List<ComponentName> outActivities, String packageName);

    /**
     * Ask for the set of available 'home' activities and the current explicit
     * default, if any.
     * @hide
     */
    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);

    /**
     * Set the enabled setting for a package component (activity, receiver, service, provider).
     * This setting will override any enabled state which may have been set by the component in its
+10 −9
Original line number Diff line number Diff line
@@ -2466,10 +2466,17 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    String getHomePackageName() {
    Intent getHomeIntent() {
        Intent intent = new Intent(mTopAction, mTopData != null ? Uri.parse(mTopData) : null);
        intent.setComponent(mTopComponent);
        if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
            intent.addCategory(Intent.CATEGORY_HOME);
        }
        return intent;
    }
    String getHomePackageName() {
        Intent intent = getHomeIntent();
        ActivityInfo aInfo = resolveActivityInfo(intent, STOCK_PM_FLAGS, mCurrentUserId);
        if (aInfo != null) {
            final String homePackageName = aInfo.applicationInfo.packageName;
@@ -2495,13 +2502,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            // error message and don't try to start anything.
            return false;
        }
        Intent intent = new Intent(
            mTopAction,
            mTopData != null ? Uri.parse(mTopData) : null);
        intent.setComponent(mTopComponent);
        if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
            intent.addCategory(Intent.CATEGORY_HOME);
        }
        Intent intent = getHomeIntent();
        ActivityInfo aInfo =
            resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);
        if (aInfo != null) {
+27 −6
Original line number Diff line number Diff line
@@ -9716,10 +9716,6 @@ public class PackageManagerService extends IPackageManager.Stub {
            throw new IllegalArgumentException(
                    "replacePreferredActivity expects filter to have only 1 action.");
        }
        if (filter.countCategories() != 1) {
            throw new IllegalArgumentException(
                    "replacePreferredActivity expects filter to have only 1 category.");
        }
        if (filter.countDataAuthorities() != 0
                || filter.countDataPaths() != 0
                || filter.countDataSchemes() != 0
@@ -9756,10 +9752,13 @@ public class PackageManagerService extends IPackageManager.Stub {
                            removed = new ArrayList<PreferredActivity>();
                        }
                        removed.add(pa);
                        Log.i(TAG, "Removing preferred activity " + pa.mPref.mComponent + ":");
                        if (DEBUG_PREFERRED) {
                            Slog.i(TAG, "Removing preferred activity "
                                    + pa.mPref.mComponent + ":");
                            filter.dump(new LogPrinter(Log.INFO, TAG), "  ");
                        }
                    }
                }
                if (removed != null) {
                    for (int i=0; i<removed.size(); i++) {
                        PreferredActivity pa = removed.get(i);
@@ -9876,6 +9875,28 @@ public class PackageManagerService extends IPackageManager.Stub {
        return num;
    }

    @Override
    public ComponentName getHomeActivities(List<ResolveInfo> allHomeCandidates) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);

        final int callingUserId = UserHandle.getCallingUserId();
        List<ResolveInfo> list = queryIntentActivities(intent, null, 0, callingUserId);
        ResolveInfo preferred = findPreferredActivity(intent, null, 0, list, 0,
                true, false, callingUserId);

        allHomeCandidates.clear();
        if (list != null) {
            for (ResolveInfo ri : list) {
                allHomeCandidates.add(ri);
            }
        }
        return (preferred == null || preferred.activityInfo == null)
                ? null
                : new ComponentName(preferred.activityInfo.packageName,
                        preferred.activityInfo.name);
    }

    @Override
    public void setApplicationEnabledSetting(String appPackageName,
            int newState, int flags, int userId, String callingPackage) {
Loading