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

Commit f21b13fb authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6479434 from 83ebcd43 to mainline-release

Change-Id: I37e4d979cc751c758e52ce04eb6e68faa39c25b6
parents e7ccf5e2 83ebcd43
Loading
Loading
Loading
Loading
+37 −3
Original line number Diff line number Diff line
@@ -293,6 +293,13 @@ public class AppStandbyController implements AppStandbyInternal {
     * {@link #setAppStandbyBucket(String, int, int, int, int)} will not be propagated.
     */
    boolean mLinkCrossProfileApps;
    /**
     * Whether we should allow apps into the
     * {@link android.app.usage.UsageStatsManager#STANDBY_BUCKET_RESTRICTED} bucket or not.
     * If false, any attempts to put an app into the bucket will put the app into the
     * {@link android.app.usage.UsageStatsManager#STANDBY_BUCKET_RARE} bucket instead.
     */
    private boolean mAllowRestrictedBucket;

    private volatile boolean mAppIdleEnabled;
    private boolean mIsCharging;
@@ -688,6 +695,10 @@ public class AppStandbyController implements AppStandbyInternal {
                    return;
                }
                final int oldBucket = app.currentBucket;
                if (oldBucket == STANDBY_BUCKET_NEVER) {
                    // None of this should bring an app out of the NEVER bucket.
                    return;
                }
                int newBucket = Math.max(oldBucket, STANDBY_BUCKET_ACTIVE); // Undo EXEMPTED
                boolean predictionLate = predictionTimedOut(app, elapsedRealtime);
                // Compute age-based bucket
@@ -743,11 +754,18 @@ public class AppStandbyController implements AppStandbyInternal {
                        Slog.d(TAG, "Bringing down to RESTRICTED due to timeout");
                    }
                }
                if (newBucket == STANDBY_BUCKET_RESTRICTED && !mAllowRestrictedBucket) {
                    newBucket = STANDBY_BUCKET_RARE;
                    // Leave the reason alone.
                    if (DEBUG) {
                        Slog.d(TAG, "Bringing up from RESTRICTED to RARE due to off switch");
                    }
                }
                if (DEBUG) {
                    Slog.d(TAG, "     Old bucket=" + oldBucket
                            + ", newBucket=" + newBucket);
                }
                if (oldBucket < newBucket || predictionLate) {
                if (oldBucket != newBucket || predictionLate) {
                    mAppIdleHistory.setAppStandbyBucket(packageName, userId,
                            elapsedRealtime, newBucket, reason);
                    maybeInformListeners(packageName, userId, elapsedRealtime,
@@ -1197,8 +1215,8 @@ public class AppStandbyController implements AppStandbyInternal {

        final int reason = REASON_MAIN_FORCED_BY_SYSTEM | (REASON_SUB_MASK & restrictReason);
        final long nowElapsed = mInjector.elapsedRealtime();
        setAppStandbyBucket(packageName, userId, STANDBY_BUCKET_RESTRICTED, reason,
                nowElapsed, false);
        final int bucket = mAllowRestrictedBucket ? STANDBY_BUCKET_RESTRICTED : STANDBY_BUCKET_RARE;
        setAppStandbyBucket(packageName, userId, bucket, reason, nowElapsed, false);
    }

    @Override
@@ -1268,6 +1286,9 @@ public class AppStandbyController implements AppStandbyInternal {
                Slog.e(TAG, "Tried to set bucket of uninstalled app: " + packageName);
                return;
            }
            if (newBucket == STANDBY_BUCKET_RESTRICTED && !mAllowRestrictedBucket) {
                newBucket = STANDBY_BUCKET_RARE;
            }
            AppIdleHistory.AppUsageHistory app = mAppIdleHistory.getAppUsageHistory(packageName,
                    userId, elapsedRealtime);
            boolean predicted = (reason & REASON_MAIN_MASK) == REASON_MAIN_PREDICTED;
@@ -1386,6 +1407,7 @@ public class AppStandbyController implements AppStandbyInternal {
                        Slog.d(TAG, "    Keeping at WORKING_SET due to min timeout");
                    }
                } else if (newBucket == STANDBY_BUCKET_RARE
                        && mAllowRestrictedBucket
                        && getBucketForLocked(packageName, userId, elapsedRealtime)
                        == STANDBY_BUCKET_RESTRICTED) {
                    // Prediction doesn't think the app will be used anytime soon and
@@ -1727,6 +1749,8 @@ public class AppStandbyController implements AppStandbyInternal {

        pw.println();
        pw.print("mAppIdleEnabled="); pw.print(mAppIdleEnabled);
        pw.print(" mAllowRestrictedBucket=");
        pw.print(mAllowRestrictedBucket);
        pw.print(" mIsCharging=");
        pw.print(mIsCharging);
        pw.println();
@@ -1828,6 +1852,12 @@ public class AppStandbyController implements AppStandbyInternal {
            return mPowerWhitelistManager.isWhitelisted(packageName, false);
        }

        boolean isRestrictedBucketEnabled() {
            return Global.getInt(mContext.getContentResolver(),
                    Global.ENABLE_RESTRICTED_BUCKET,
                    Global.DEFAULT_ENABLE_RESTRICTED_BUCKET) == 1;
        }

        File getDataSystemDirectory() {
            return Environment.getDataSystemDirectory();
        }
@@ -2066,6 +2096,8 @@ public class AppStandbyController implements AppStandbyInternal {
            final ContentResolver cr = mContext.getContentResolver();
            cr.registerContentObserver(Global.getUriFor(Global.APP_IDLE_CONSTANTS), false, this);
            cr.registerContentObserver(Global.getUriFor(Global.APP_STANDBY_ENABLED), false, this);
            cr.registerContentObserver(Global.getUriFor(Global.ENABLE_RESTRICTED_BUCKET),
                    false, this);
            cr.registerContentObserver(Global.getUriFor(Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED),
                    false, this);
        }
@@ -2164,6 +2196,8 @@ public class AppStandbyController implements AppStandbyInternal {
                mLinkCrossProfileApps = mParser.getBoolean(
                        KEY_CROSS_PROFILE_APPS_SHARE_STANDBY_BUCKETS,
                        DEFAULT_CROSS_PROFILE_APPS_SHARE_STANDBY_BUCKETS);

                mAllowRestrictedBucket = mInjector.isRestrictedBucketEnabled();
            }

            // Check if app_idle_enabled has changed. Do this after getting the rest of the settings
+17 −0
Original line number Diff line number Diff line
@@ -428,6 +428,7 @@ message Atom {
            266 [(module) = "framework"];
        AccessibilityServiceReported accessibility_service_reported = 267 [(module) = "settings"];
        DocsUIDragAndDropReported docs_ui_drag_and_drop_reported = 268 [(module) = "docsui"];
        AppUsageEventOccurred app_usage_event_occurred = 269 [(module) = "framework"];
        SdkExtensionStatus sdk_extension_status = 354;

        // StatsdStats tracks platform atoms with ids upto 500.
@@ -9528,3 +9529,19 @@ message AccessibilityServiceReported {
    // From frameworks/base/core/proto/android/stats/accessibility/accessibility_enums.proto.
    optional android.stats.accessibility.ServiceStatus service_status = 2;
}

/**
 * Logs app usage events.
 */
message AppUsageEventOccurred {
    optional int32 uid = 1 [(is_uid) = true];
    optional string package_name = 2;
    optional string class_name = 3;

    enum EventType {
        NONE = 0;
        MOVE_TO_FOREGROUND = 1;
        MOVE_TO_BACKGROUND = 2;
    }
    optional EventType event_type = 4;
}
+8 −3
Original line number Diff line number Diff line
@@ -396,8 +396,13 @@ public class ParsingPackageUtils {
                }
            }

            pkg.setVolumeUuid(volumeUuid)
                    .setSigningDetails(SigningDetails.UNKNOWN);
            pkg.setVolumeUuid(volumeUuid);

            if ((flags & PackageParser.PARSE_COLLECT_CERTIFICATES) != 0) {
                pkg.setSigningDetails(getSigningDetails(pkg, false));
            } else {
                pkg.setSigningDetails(SigningDetails.UNKNOWN);
            }

            return input.success(pkg);
        } catch (Exception e) {
@@ -449,7 +454,7 @@ public class ParsingPackageUtils {
     */
    private ParseResult<ParsingPackage> parseBaseApk(ParseInput input, String apkPath,
            String codePath, Resources res, XmlResourceParser parser, int flags)
            throws XmlPullParserException, IOException {
            throws XmlPullParserException, IOException, PackageParserException {
        final String splitName;
        final String pkgName;

+67 −18
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.util.SparseArray;
@@ -74,6 +73,8 @@ public final class DisplayManagerGlobal {
    @UnsupportedAppUsage
    private static DisplayManagerGlobal sInstance;

    // Guarded by mLock
    private boolean mDispatchNativeCallbacks = false;
    private final Object mLock = new Object();

    @UnsupportedAppUsage
@@ -143,6 +144,15 @@ public final class DisplayManagerGlobal {
    @UnsupportedAppUsage
    public DisplayInfo getDisplayInfo(int displayId) {
        synchronized (mLock) {
            return getDisplayInfoLocked(displayId);
        }
    }

    /**
     * Gets information about a particular logical display
     * See {@link getDisplayInfo}, but assumes that {@link mLock} is held
     */
    private @Nullable DisplayInfo getDisplayInfoLocked(int displayId) {
        DisplayInfo info = null;
        if (mDisplayCache != null) {
            info = mDisplayCache.query(displayId);
@@ -164,7 +174,6 @@ public final class DisplayManagerGlobal {
        }
        return info;
    }
    }

    /**
     * Gets all currently valid logical display ids.
@@ -341,6 +350,20 @@ public final class DisplayManagerGlobal {
            for (int i = 0; i < numListeners; i++) {
                mDisplayListeners.get(i).sendDisplayEvent(displayId, event);
            }
            if (event == EVENT_DISPLAY_CHANGED && mDispatchNativeCallbacks) {
                // Choreographer only supports a single display, so only dispatch refresh rate
                // changes for the default display.
                if (displayId == Display.DEFAULT_DISPLAY) {
                    // We can likely save a binder hop if we attach the refresh rate onto the
                    // listener.
                    DisplayInfo display = getDisplayInfoLocked(displayId);
                    if (display != null) {
                        float refreshRate = display.getMode().getRefreshRate();
                        // Signal native callbacks if we ever set a refresh rate.
                        nSignalNativeCallbacks(refreshRate);
                    }
                }
            }
        }
    }

@@ -800,4 +823,30 @@ public final class DisplayManagerGlobal {
    public void disableLocalDisplayInfoCaches() {
        mDisplayCache = null;
    }

    private static native void nSignalNativeCallbacks(float refreshRate);

    // Called from AChoreographer via JNI.
    // Registers AChoreographer so that refresh rate callbacks can be dispatched from DMS.
    private void registerNativeChoreographerForRefreshRateCallbacks() {
        synchronized (mLock) {
            registerCallbackIfNeededLocked();
            mDispatchNativeCallbacks = true;
            DisplayInfo display = getDisplayInfoLocked(Display.DEFAULT_DISPLAY);
            if (display != null) {
                // We need to tell AChoreographer instances the current refresh rate so that apps
                // can get it for free once a callback first registers.
                float refreshRate = display.getMode().getRefreshRate();
                nSignalNativeCallbacks(refreshRate);
            }
        }
    }

    // Called from AChoreographer via JNI.
    // Unregisters AChoreographer from receiving refresh rate callbacks.
    private void unregisterNativeChoreographerForRefreshRateCallbacks() {
        synchronized (mLock) {
            mDispatchNativeCallbacks = false;
        }
    }
}
+4 −3
Original line number Diff line number Diff line
@@ -550,11 +550,12 @@ public final class MessageQueue {
        if (msg.target == null) {
            throw new IllegalArgumentException("Message must have a target.");
        }

        synchronized (this) {
            if (msg.isInUse()) {
                throw new IllegalStateException(msg + " This message is already in use.");
            }

        synchronized (this) {
            if (mQuitting) {
                IllegalStateException e = new IllegalStateException(
                        msg.target + " sending message to a Handler on a dead thread");
Loading