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

Commit 8c7bfcd5 authored by Songchun Fan's avatar Songchun Fan Committed by Android (Google) Code Review
Browse files

Merge "Revert "Revert "[incremental/pm] LauncherApps APIs for loading state and progress"""

parents 1cd62933 56838fba
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -11718,7 +11718,10 @@ package android.content.pm {
    method public android.graphics.drawable.Drawable getIcon(int);
    method public CharSequence getLabel();
    method public String getName();
    method public float getProgress();
    method public android.os.UserHandle getUser();
    method public boolean isLoading();
    method public boolean isStartable();
  }
  public class LauncherApps {
@@ -11758,6 +11761,7 @@ package android.content.pm {
    ctor public LauncherApps.Callback();
    method public abstract void onPackageAdded(String, android.os.UserHandle);
    method public abstract void onPackageChanged(String, android.os.UserHandle);
    method public void onPackageProgressChanged(@NonNull String, @NonNull android.os.UserHandle, float);
    method public abstract void onPackageRemoved(String, android.os.UserHandle);
    method public abstract void onPackagesAvailable(String[], android.os.UserHandle, boolean);
    method public void onPackagesSuspended(String[], android.os.UserHandle);
+2 −2
Original line number Diff line number Diff line
@@ -21,9 +21,9 @@ import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentSender;
import android.content.LocusId;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.IOnAppsChangedListener;
import android.content.pm.LauncherActivityInfoInternal;
import android.content.pm.LauncherApps;
import android.content.pm.ShortcutQueryWrapper;
import android.content.pm.IPackageInstallerCallback;
@@ -47,7 +47,7 @@ interface ILauncherApps {
    void removeOnAppsChangedListener(in IOnAppsChangedListener listener);
    ParceledListSlice getLauncherActivities(
            String callingPackage, String packageName, in UserHandle user);
    ActivityInfo resolveActivity(
    LauncherActivityInfoInternal resolveLauncherActivityInternal(
            String callingPackage, in ComponentName component, in UserHandle user);
    void startSessionDetailsActivityAsUser(in IApplicationThread caller, String callingPackage,
                String callingFeatureId, in PackageInstaller.SessionInfo sessionInfo,
+1 −0
Original line number Diff line number Diff line
@@ -33,4 +33,5 @@ oneway interface IOnAppsChangedListener {
            in Bundle launcherExtras);
    void onPackagesUnsuspended(in UserHandle user, in String[] packageNames);
    void onShortcutChanged(in UserHandle user, String packageName, in ParceledListSlice shortcuts);
    void onPackageProgressChanged(in UserHandle user, String packageName, float progress);
}
+0 −1
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.content.pm.IPackageInstaller;
import android.content.pm.IPackageDeleteObserver;
import android.content.pm.IPackageDeleteObserver2;
import android.content.pm.IPackageDataObserver;
import android.content.pm.IPackageLoadingProgressCallback;
import android.content.pm.IPackageMoveObserver;
import android.content.pm.IPackageStatsObserver;
import android.content.pm.IntentFilterVerificationInfo;
+36 −25
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.content.pm;

import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -35,28 +34,19 @@ public class LauncherActivityInfo {
    private static final String TAG = "LauncherActivityInfo";

    private final PackageManager mPm;

    @UnsupportedAppUsage
    private ActivityInfo mActivityInfo;
    private ComponentName mComponentName;
    private UserHandle mUser;
    private final LauncherActivityInfoInternal mInternal;

    /**
     * Create a launchable activity object for a given ResolveInfo and user.
     *
     * @param context The context for fetching resources.
     * @param info ResolveInfo from which to create the LauncherActivityInfo.
     * @param user The UserHandle of the profile to which this activity belongs.
     */
    LauncherActivityInfo(Context context, ActivityInfo info, UserHandle user) {
        this(context);
        mActivityInfo = info;
        mComponentName =  new ComponentName(info.packageName, info.name);
        mUser = user;
    }

    LauncherActivityInfo(Context context) {
     */
    LauncherActivityInfo(Context context, UserHandle user, LauncherActivityInfoInternal internal) {
        mPm = context.getPackageManager();
        mUser = user;
        mInternal = internal;
    }

    /**
@@ -65,7 +55,7 @@ public class LauncherActivityInfo {
     * @return ComponentName of the activity
     */
    public ComponentName getComponentName() {
        return mComponentName;
        return mInternal.getComponentName();
    }

    /**
@@ -90,7 +80,28 @@ public class LauncherActivityInfo {
     */
    public CharSequence getLabel() {
        // TODO: Go through LauncherAppsService
        return mActivityInfo.loadLabel(mPm);
        return mInternal.getActivityInfo().loadLabel(mPm);
    }

    /**
     * @return whether the package is startable.
     */
    public boolean isStartable() {
        return mInternal.getIncrementalStatesInfo().isStartable();
    }

    /**
     * @return whether the package is still loading.
     */
    public boolean isLoading() {
        return mInternal.getIncrementalStatesInfo().isLoading();
    }

    /**
     * @return Package loading progress
     */
    public float getProgress() {
        return mInternal.getIncrementalStatesInfo().getProgress();
    }

    /**
@@ -103,20 +114,20 @@ public class LauncherActivityInfo {
     */
    public Drawable getIcon(int density) {
        // TODO: Go through LauncherAppsService
        final int iconRes = mActivityInfo.getIconResource();
        final int iconRes = mInternal.getActivityInfo().getIconResource();
        Drawable icon = null;
        // Get the preferred density icon from the app's resources
        if (density != 0 && iconRes != 0) {
            try {
                final Resources resources
                        = mPm.getResourcesForApplication(mActivityInfo.applicationInfo);
                final Resources resources = mPm.getResourcesForApplication(
                        mInternal.getActivityInfo().applicationInfo);
                icon = resources.getDrawableForDensity(iconRes, density);
            } catch (NameNotFoundException | Resources.NotFoundException exc) {
            }
        }
        // Get the default density icon
        if (icon == null) {
            icon = mActivityInfo.loadIcon(mPm);
            icon = mInternal.getActivityInfo().loadIcon(mPm);
        }
        return icon;
    }
@@ -128,7 +139,7 @@ public class LauncherActivityInfo {
     * @hide remove before shipping
     */
    public int getApplicationFlags() {
        return mActivityInfo.applicationInfo.flags;
        return mInternal.getActivityInfo().flags;
    }

    /**
@@ -136,7 +147,7 @@ public class LauncherActivityInfo {
     * @return
     */
    public ApplicationInfo getApplicationInfo() {
        return mActivityInfo.applicationInfo;
        return mInternal.getActivityInfo().applicationInfo;
    }

    /**
@@ -147,7 +158,7 @@ public class LauncherActivityInfo {
    public long getFirstInstallTime() {
        try {
            // TODO: Go through LauncherAppsService
            return mPm.getPackageInfo(mActivityInfo.packageName,
            return mPm.getPackageInfo(mInternal.getActivityInfo().packageName,
                    PackageManager.MATCH_UNINSTALLED_PACKAGES).firstInstallTime;
        } catch (NameNotFoundException nnfe) {
            // Sorry, can't find package
@@ -160,7 +171,7 @@ public class LauncherActivityInfo {
     * @return the name from android:name for the acitivity.
     */
    public String getName() {
        return mActivityInfo.name;
        return mInternal.getActivityInfo().name;
    }

    /**
Loading