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

Commit 0736e201 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Fetching firstInstallTime on demand

Change-Id: I96442aaf119553ffb0ea94ff06713752e4490e0b
parent bfeaa0ae
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ public class LauncherActivityInfo {
    private ComponentName mComponentName;
    private ResolveInfo mResolveInfo;
    private UserHandle mUser;
    private long mFirstInstallTime;

    /**
     * Create a launchable activity object for a given ResolveInfo and user.
@@ -50,14 +49,12 @@ public class LauncherActivityInfo {
     * @param info ResolveInfo from which to create the LauncherActivityInfo.
     * @param user The UserHandle of the profile to which this activity belongs.
     */
    LauncherActivityInfo(Context context, ResolveInfo info, UserHandle user,
            long firstInstallTime) {
    LauncherActivityInfo(Context context, ResolveInfo info, UserHandle user) {
        this(context);
        mResolveInfo = info;
        mActivityInfo = info.activityInfo;
        mComponentName = LauncherApps.getComponentName(info);
        mUser = user;
        mFirstInstallTime = firstInstallTime;
    }

    LauncherActivityInfo(Context context) {
@@ -136,7 +133,7 @@ public class LauncherActivityInfo {

    /**
     * Returns the drawable for this activity, without any badging for the profile.
     * @param resource id of the drawable.
     * @param iconRes id of the drawable.
     * @param density The preferred density of the icon, zero for default density. Use
     * density DPI values from {@link DisplayMetrics}.
     * @see DisplayMetrics
@@ -179,7 +176,13 @@ public class LauncherActivityInfo {
     * @return The time of installation of the package, in milliseconds.
     */
    public long getFirstInstallTime() {
        return mFirstInstallTime;
        try {
            return mPm.getPackageInfo(mActivityInfo.packageName,
                    PackageManager.GET_UNINSTALLED_PACKAGES).firstInstallTime;
        } catch (NameNotFoundException nnfe) {
            // Sorry, can't find package
            return 0;
        }
    }

    /**
+2 −18
Original line number Diff line number Diff line
@@ -155,15 +155,7 @@ public class LauncherApps {
        final int count = activities.size();
        for (int i = 0; i < count; i++) {
            ResolveInfo ri = activities.get(i);
            long firstInstallTime = 0;
            try {
                firstInstallTime = mPm.getPackageInfo(ri.activityInfo.packageName,
                    PackageManager.GET_UNINSTALLED_PACKAGES).firstInstallTime;
            } catch (NameNotFoundException nnfe) {
                // Sorry, can't find package
            }
            LauncherActivityInfo lai = new LauncherActivityInfo(mContext, ri, user,
                    firstInstallTime);
            LauncherActivityInfo lai = new LauncherActivityInfo(mContext, ri, user);
            if (DEBUG) {
                Log.v(TAG, "Returning activity for profile " + user + " : "
                        + lai.getComponentName());
@@ -189,15 +181,7 @@ public class LauncherApps {
        try {
            ResolveInfo ri = mService.resolveActivity(intent, user);
            if (ri != null) {
                long firstInstallTime = 0;
                try {
                    firstInstallTime = mPm.getPackageInfo(ri.activityInfo.packageName,
                            PackageManager.GET_UNINSTALLED_PACKAGES).firstInstallTime;
                } catch (NameNotFoundException nnfe) {
                    // Sorry, can't find package
                }
                LauncherActivityInfo info = new LauncherActivityInfo(mContext, ri, user,
                        firstInstallTime);
                LauncherActivityInfo info = new LauncherActivityInfo(mContext, ri, user);
                return info;
            }
        } catch (RemoteException re) {