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

Commit 0173a44f authored by Songchun Fan's avatar Songchun Fan
Browse files

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

Exposing package state changes and progress changes via LauncherApps
and LauncherActivityInfo as public APIs.

BUG: 165841645
Test: builds (will add CTS tests)
CTS-Coverage-Bug: 168925573
Change-Id: I2b5ea698799f9a762b7d9c79d62636d3db187c1f
parent ab69244d
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -11707,7 +11707,10 @@ package android.content.pm {
    method public android.graphics.drawable.Drawable getIcon(int);
    method public android.graphics.drawable.Drawable getIcon(int);
    method public CharSequence getLabel();
    method public CharSequence getLabel();
    method public String getName();
    method public String getName();
    method public float getProgress();
    method public android.os.UserHandle getUser();
    method public android.os.UserHandle getUser();
    method public boolean isLoading();
    method public boolean isStartable();
  }
  }
  public class LauncherApps {
  public class LauncherApps {
@@ -11747,6 +11750,7 @@ package android.content.pm {
    ctor public LauncherApps.Callback();
    ctor public LauncherApps.Callback();
    method public abstract void onPackageAdded(String, android.os.UserHandle);
    method public abstract void onPackageAdded(String, android.os.UserHandle);
    method public abstract void onPackageChanged(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 onPackageRemoved(String, android.os.UserHandle);
    method public abstract void onPackagesAvailable(String[], android.os.UserHandle, boolean);
    method public abstract void onPackagesAvailable(String[], android.os.UserHandle, boolean);
    method public void onPackagesSuspended(String[], android.os.UserHandle);
    method public void onPackagesSuspended(String[], android.os.UserHandle);
+2 −2
Original line number Original line Diff line number Diff line
@@ -21,9 +21,9 @@ import android.content.ComponentName;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentSender;
import android.content.IntentSender;
import android.content.LocusId;
import android.content.LocusId;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.IOnAppsChangedListener;
import android.content.pm.IOnAppsChangedListener;
import android.content.pm.LauncherActivityInfoInternal;
import android.content.pm.LauncherApps;
import android.content.pm.LauncherApps;
import android.content.pm.ShortcutQueryWrapper;
import android.content.pm.ShortcutQueryWrapper;
import android.content.pm.IPackageInstallerCallback;
import android.content.pm.IPackageInstallerCallback;
@@ -47,7 +47,7 @@ interface ILauncherApps {
    void removeOnAppsChangedListener(in IOnAppsChangedListener listener);
    void removeOnAppsChangedListener(in IOnAppsChangedListener listener);
    ParceledListSlice getLauncherActivities(
    ParceledListSlice getLauncherActivities(
            String callingPackage, String packageName, in UserHandle user);
            String callingPackage, String packageName, in UserHandle user);
    ActivityInfo resolveActivity(
    LauncherActivityInfoInternal resolveLauncherActivityInternal(
            String callingPackage, in ComponentName component, in UserHandle user);
            String callingPackage, in ComponentName component, in UserHandle user);
    void startSessionDetailsActivityAsUser(in IApplicationThread caller, String callingPackage,
    void startSessionDetailsActivityAsUser(in IApplicationThread caller, String callingPackage,
                String callingFeatureId, in PackageInstaller.SessionInfo sessionInfo,
                String callingFeatureId, in PackageInstaller.SessionInfo sessionInfo,
+1 −0
Original line number Original line Diff line number Diff line
@@ -33,4 +33,5 @@ oneway interface IOnAppsChangedListener {
            in Bundle launcherExtras);
            in Bundle launcherExtras);
    void onPackagesUnsuspended(in UserHandle user, in String[] packageNames);
    void onPackagesUnsuspended(in UserHandle user, in String[] packageNames);
    void onShortcutChanged(in UserHandle user, String packageName, in ParceledListSlice shortcuts);
    void onShortcutChanged(in UserHandle user, String packageName, in ParceledListSlice shortcuts);
    void onPackageProgressChanged(in UserHandle user, String packageName, float progress);
}
}
+0 −1
Original line number Original line Diff line number Diff line
@@ -31,7 +31,6 @@ import android.content.pm.IPackageInstaller;
import android.content.pm.IPackageDeleteObserver;
import android.content.pm.IPackageDeleteObserver;
import android.content.pm.IPackageDeleteObserver2;
import android.content.pm.IPackageDeleteObserver2;
import android.content.pm.IPackageDataObserver;
import android.content.pm.IPackageDataObserver;
import android.content.pm.IPackageLoadingProgressCallback;
import android.content.pm.IPackageMoveObserver;
import android.content.pm.IPackageMoveObserver;
import android.content.pm.IPackageStatsObserver;
import android.content.pm.IPackageStatsObserver;
import android.content.pm.IntentFilterVerificationInfo;
import android.content.pm.IntentFilterVerificationInfo;
+36 −25
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package android.content.pm;
package android.content.pm;


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


    private final PackageManager mPm;
    private final PackageManager mPm;

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


    /**
    /**
     * Create a launchable activity object for a given ResolveInfo and user.
     * Create a launchable activity object for a given ResolveInfo and user.
     *
     *
     * @param context The context for fetching resources.
     * @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();
        mPm = context.getPackageManager();
        mUser = user;
        mInternal = internal;
    }
    }


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


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


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


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


    /**
    /**
Loading