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

Commit 9bc896f0 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8779833 from b8cbfd3f to tm-qpr1-release

Change-Id: I669a753f3e3e69c1dd80d4fe428ae65cd195bcbe
parents a3aebfd9 b8cbfd3f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -163,6 +163,13 @@ public interface AppStandbyInternal {
    int getAppStandbyBucketReason(@NonNull String packageName, @UserIdInt int userId,
            @ElapsedRealtimeLong long elapsedRealtime);

    /**
     * Puts the list of apps in the {@link android.app.usage.UsageStatsManager#STANDBY_BUCKET_RARE}
     * bucket.
     * @param restoredApps the list of restored apps
     */
    void restoreAppsToRare(@NonNull Set<String> restoredApps, int userId);

    /**
     * Put the specified app in the
     * {@link android.app.usage.UsageStatsManager#STANDBY_BUCKET_RESTRICTED}
+21 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.app.usage.UsageStatsManager.REASON_MAIN_MASK;
import static android.app.usage.UsageStatsManager.REASON_MAIN_PREDICTED;
import static android.app.usage.UsageStatsManager.REASON_MAIN_TIMEOUT;
import static android.app.usage.UsageStatsManager.REASON_MAIN_USAGE;
import static android.app.usage.UsageStatsManager.REASON_SUB_DEFAULT_APP_RESTORED;
import static android.app.usage.UsageStatsManager.REASON_SUB_DEFAULT_APP_UPDATE;
import static android.app.usage.UsageStatsManager.REASON_SUB_FORCED_SYSTEM_FLAG_BUGGY;
import static android.app.usage.UsageStatsManager.REASON_SUB_FORCED_USER_FLAG_INTERACTION;
@@ -1604,6 +1605,26 @@ public class AppStandbyController
        setAppStandbyBucket(packageName, userId, bucket, reason, nowElapsed, false);
    }

    @Override
    public void restoreAppsToRare(Set<String> restoredApps, int userId) {
        final int reason = REASON_MAIN_DEFAULT | REASON_SUB_DEFAULT_APP_RESTORED;
        final long nowElapsed = mInjector.elapsedRealtime();
        for (String packageName : restoredApps) {
            // If the package is not installed, don't allow the bucket to be set.
            if (!mInjector.isPackageInstalled(packageName, 0, userId)) {
                Slog.e(TAG, "Tried to restore bucket for uninstalled app: " + packageName);
                continue;
            }

            final int standbyBucket = getAppStandbyBucket(packageName, userId, nowElapsed, false);
            // Only update the standby bucket to RARE if the app is still in the NEVER bucket.
            if (standbyBucket == STANDBY_BUCKET_NEVER) {
                setAppStandbyBucket(packageName, userId, STANDBY_BUCKET_RARE, reason,
                        nowElapsed, false);
            }
        }
    }

    @Override
    public void setAppStandbyBucket(@NonNull String packageName, int bucket, int userId,
            int callingUid, int callingPid) {
+11 −0
Original line number Diff line number Diff line
@@ -292,6 +292,17 @@ public final class UsageStats implements Parcelable {
        return mLastTimeComponentUsed;
    }

    /**
     * Returns the last time the package was used - defined by the latest of
     * mLastTimeUsed, mLastTimeVisible, mLastTimeForegroundServiceUsed, or mLastTimeComponentUsed.
     * @hide
     */
    public long getLastTimePackageUsed() {
        return Math.max(mLastTimeUsed,
                        Math.max(mLastTimeVisible,
                                 Math.max(mLastTimeForegroundServiceUsed, mLastTimeComponentUsed)));
    }

    /**
     * Returns the number of times the app was launched as an activity from outside of the app.
     * Excludes intra-app activity transitions.
+8 −0
Original line number Diff line number Diff line
@@ -219,6 +219,11 @@ public final class UsageStatsManager {
     * @hide
     */
    public static final int REASON_SUB_DEFAULT_APP_UPDATE = 0x0001;
    /**
     * The app was restored.
     * @hide
     */
    public static final int REASON_SUB_DEFAULT_APP_RESTORED = 0x0002;
    /**
     * The app was interacted with in some way by the system.
     * @hide
@@ -1209,6 +1214,9 @@ public final class UsageStatsManager {
                    case REASON_SUB_DEFAULT_APP_UPDATE:
                        sb.append("-au");
                        break;
                    case REASON_SUB_DEFAULT_APP_RESTORED:
                        sb.append("-ar");
                        break;
                }
                break;
            case REASON_MAIN_FORCED_BY_SYSTEM:
+4 −1
Original line number Diff line number Diff line
@@ -542,14 +542,17 @@ public class ApkLiteParseUtils {

                int minVer = DEFAULT_MIN_SDK_VERSION;
                String minCode = null;
                boolean minAssigned = false;
                int targetVer = DEFAULT_TARGET_SDK_VERSION;
                String targetCode = null;

                if (!TextUtils.isEmpty(minSdkVersionString)) {
                    try {
                        minVer = Integer.parseInt(minSdkVersionString);
                        minAssigned = true;
                    } catch (NumberFormatException ignored) {
                        minCode = minSdkVersionString;
                        minAssigned = !TextUtils.isEmpty(minCode);
                    }
                }

@@ -558,7 +561,7 @@ public class ApkLiteParseUtils {
                        targetVer = Integer.parseInt(targetSdkVersionString);
                    } catch (NumberFormatException ignored) {
                        targetCode = targetSdkVersionString;
                        if (minCode == null) {
                        if (!minAssigned) {
                            minCode = targetCode;
                        }
                    }
Loading