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

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

Snap for 11908474 from 328a9f17 to 24Q3-release

Change-Id: I78ccb7a71bbd9e03aae467c99e418e35c1efc0fc
parents 24c18093 328a9f17
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
[Builtin Hooks]
clang_format = true
bpfmt = true
ktfmt = true

[Builtin Hooks Options]
# Only turn on clang-format check for the following subfolders.
@@ -17,6 +18,7 @@ clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
               tests/
               tools/
bpfmt = -d
ktfmt = --kotlinlang-style --include-dirs=services/permission,packages/SystemUI

[Hook Scripts]
checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
@@ -25,9 +27,10 @@ hidden_api_txt_checksorted_hook = ${REPO_ROOT}/tools/platform-compat/hiddenapi/c

hidden_api_txt_exclude_hook = ${REPO_ROOT}/frameworks/base/tools/hiddenapi/exclude.sh ${PREUPLOAD_COMMIT} ${REPO_ROOT}

ktfmt_hook = ${REPO_ROOT}/external/ktfmt/ktfmt.py --check -i ${REPO_ROOT}/frameworks/base/ktfmt_includes.txt ${PREUPLOAD_FILES}

ktlint_hook = ${REPO_ROOT}/prebuilts/ktlint/ktlint.py --no-verify-format -f ${PREUPLOAD_FILES}

# This flag check hook runs only for "packages/SystemUI" subdirectory. If you want to include this check for other subdirectories, please modify flag_check.py.
flag_hook = ${REPO_ROOT}/frameworks/base/packages/SystemUI/flag_check.py --msg=${PREUPLOAD_COMMIT_MESSAGE} --files=${PREUPLOAD_FILES} --project=${REPO_PATH}

[Tool Paths]
ktfmt = ${REPO_ROOT}/prebuilts/build-tools/common/framework/ktfmt.jar
+7 −3
Original line number Diff line number Diff line
@@ -619,6 +619,7 @@ public class DeviceIdleController extends SystemService
     * List of end times for app-IDs that are temporarily marked as being allowed to access
     * the network and acquire wakelocks. Times are in milliseconds.
     */
    @GuardedBy("this")
    private final SparseArray<Pair<MutableLong, String>> mTempWhitelistAppIdEndTimes
            = new SparseArray<>();

@@ -5010,7 +5011,9 @@ public class DeviceIdleController extends SystemService
                if (!DumpUtils.checkDumpPermission(getContext(), TAG, pw)) {
                    return -1;
                }
                dumpTempWhitelistSchedule(pw, false);
                synchronized (this) {
                    dumpTempWhitelistScheduleLocked(pw, false);
                }
            }
        } else if ("except-idle-whitelist".equals(cmd)) {
            getContext().enforceCallingOrSelfPermission(
@@ -5294,7 +5297,7 @@ public class DeviceIdleController extends SystemService
                    pw.println();
                }
            }
            dumpTempWhitelistSchedule(pw, true);
            dumpTempWhitelistScheduleLocked(pw, true);

            size = mTempWhitelistAppIdArray != null ? mTempWhitelistAppIdArray.length : 0;
            if (size > 0) {
@@ -5422,7 +5425,8 @@ public class DeviceIdleController extends SystemService
        }
    }

    void dumpTempWhitelistSchedule(PrintWriter pw, boolean printTitle) {
    @GuardedBy("this")
    void dumpTempWhitelistScheduleLocked(PrintWriter pw, boolean printTitle) {
        final int size = mTempWhitelistAppIdEndTimes.size();
        if (size > 0) {
            String prefix = "";
+4 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public final class IdleController extends RestrictingController implements Idlen
    private static final String TAG = "JobScheduler.IdleController";
    // Policy: we decide that we're "idle" if the device has been unused /
    // screen off or dreaming or wireless charging dock idle for at least this long
    @GuardedBy("mLock")
    final ArraySet<JobStatus> mTrackedTasks = new ArraySet<>();
    IdlenessTracker mIdleTracker;
    private final FlexibilityController mFlexibilityController;
@@ -118,9 +119,11 @@ public final class IdleController extends RestrictingController implements Idlen
            for (int i = mTrackedTasks.size()-1; i >= 0; i--) {
                mTrackedTasks.valueAt(i).setIdleConstraintSatisfied(nowElapsed, isIdle);
            }
        }
            if (!mTrackedTasks.isEmpty()) {
                mStateChangedListener.onControllerStateChanged(mTrackedTasks);
            }
        }
    }

    /**
     * Idle state tracking, and messaging with the task manager when
+40 −8
Original line number Diff line number Diff line
@@ -1755,6 +1755,12 @@ public class ActivityManager {
        private int mNavigationBarColor;
        @Appearance
        private int mSystemBarsAppearance;
        /**
         * Similar to {@link TaskDescription#mSystemBarsAppearance}, but is taken from the topmost
         * fully opaque (i.e. non transparent) activity in the task.
         */
        @Appearance
        private int mTopOpaqueSystemBarsAppearance;
        private boolean mEnsureStatusBarContrastWhenTransparent;
        private boolean mEnsureNavigationBarContrastWhenTransparent;
        private int mResizeMode;
@@ -1855,7 +1861,7 @@ public class ActivityManager {
                final Icon icon = mIconRes == Resources.ID_NULL ? null :
                        Icon.createWithResource(ActivityThread.currentPackageName(), mIconRes);
                return new TaskDescription(mLabel, icon, mPrimaryColor, mBackgroundColor,
                        mStatusBarColor, mNavigationBarColor, 0, false, false,
                        mStatusBarColor, mNavigationBarColor, 0, 0, false, false,
                        RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            }
        }
@@ -1874,7 +1880,7 @@ public class ActivityManager {
        @Deprecated
        public TaskDescription(String label, @DrawableRes int iconRes, int colorPrimary) {
            this(label, Icon.createWithResource(ActivityThread.currentPackageName(), iconRes),
                    colorPrimary, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
                    colorPrimary, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            if ((colorPrimary != 0) && (Color.alpha(colorPrimary) != 255)) {
                throw new RuntimeException("A TaskDescription's primary color should be opaque");
            }
@@ -1892,7 +1898,7 @@ public class ActivityManager {
        @Deprecated
        public TaskDescription(String label, @DrawableRes int iconRes) {
            this(label, Icon.createWithResource(ActivityThread.currentPackageName(), iconRes),
                    0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
                    0, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
        }

        /**
@@ -1904,7 +1910,7 @@ public class ActivityManager {
         */
        @Deprecated
        public TaskDescription(String label) {
            this(label, null, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            this(label, null, 0, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
        }

        /**
@@ -1914,7 +1920,7 @@ public class ActivityManager {
         */
        @Deprecated
        public TaskDescription() {
            this(null, null, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            this(null, null, 0, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
        }

        /**
@@ -1930,7 +1936,7 @@ public class ActivityManager {
        @Deprecated
        public TaskDescription(String label, Bitmap icon, int colorPrimary) {
            this(label, icon != null ? Icon.createWithBitmap(icon) : null, colorPrimary, 0, 0, 0,
                    0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
                    0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            if ((colorPrimary != 0) && (Color.alpha(colorPrimary) != 255)) {
                throw new RuntimeException("A TaskDescription's primary color should be opaque");
            }
@@ -1946,7 +1952,7 @@ public class ActivityManager {
         */
        @Deprecated
        public TaskDescription(String label, Bitmap icon) {
            this(label, icon != null ? Icon.createWithBitmap(icon) : null, 0, 0, 0, 0, 0, false,
            this(label, icon != null ? Icon.createWithBitmap(icon) : null, 0, 0, 0, 0, 0, 0, false,
                    false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
        }

@@ -1955,6 +1961,7 @@ public class ActivityManager {
                int colorPrimary, int colorBackground,
                int statusBarColor, int navigationBarColor,
                @Appearance int systemBarsAppearance,
                @Appearance int topOpaqueSystemBarsAppearance,
                boolean ensureStatusBarContrastWhenTransparent,
                boolean ensureNavigationBarContrastWhenTransparent, int resizeMode, int minWidth,
                int minHeight, int colorBackgroundFloating) {
@@ -1965,6 +1972,7 @@ public class ActivityManager {
            mStatusBarColor = statusBarColor;
            mNavigationBarColor = navigationBarColor;
            mSystemBarsAppearance = systemBarsAppearance;
            mTopOpaqueSystemBarsAppearance = topOpaqueSystemBarsAppearance;
            mEnsureStatusBarContrastWhenTransparent = ensureStatusBarContrastWhenTransparent;
            mEnsureNavigationBarContrastWhenTransparent =
                    ensureNavigationBarContrastWhenTransparent;
@@ -1994,6 +2002,7 @@ public class ActivityManager {
            mStatusBarColor = other.mStatusBarColor;
            mNavigationBarColor = other.mNavigationBarColor;
            mSystemBarsAppearance = other.mSystemBarsAppearance;
            mTopOpaqueSystemBarsAppearance = other.mTopOpaqueSystemBarsAppearance;
            mEnsureStatusBarContrastWhenTransparent = other.mEnsureStatusBarContrastWhenTransparent;
            mEnsureNavigationBarContrastWhenTransparent =
                    other.mEnsureNavigationBarContrastWhenTransparent;
@@ -2026,6 +2035,9 @@ public class ActivityManager {
            if (other.mSystemBarsAppearance != 0) {
                mSystemBarsAppearance = other.mSystemBarsAppearance;
            }
            if (other.mTopOpaqueSystemBarsAppearance != 0) {
                mTopOpaqueSystemBarsAppearance = other.mTopOpaqueSystemBarsAppearance;
            }

            mEnsureStatusBarContrastWhenTransparent = other.mEnsureStatusBarContrastWhenTransparent;
            mEnsureNavigationBarContrastWhenTransparent =
@@ -2302,6 +2314,14 @@ public class ActivityManager {
            return mSystemBarsAppearance;
        }

        /**
         * @hide
         */
        @Appearance
        public int getTopOpaqueSystemBarsAppearance() {
            return mTopOpaqueSystemBarsAppearance;
        }

        /**
         * @hide
         */
@@ -2317,6 +2337,13 @@ public class ActivityManager {
            mSystemBarsAppearance = systemBarsAppearance;
        }

        /**
         * @hide
         */
        public void setTopOpaqueSystemBarsAppearance(int topOpaqueSystemBarsAppearance) {
            mTopOpaqueSystemBarsAppearance = topOpaqueSystemBarsAppearance;
        }

        /**
         * @hide
         */
@@ -2442,6 +2469,7 @@ public class ActivityManager {
            dest.writeInt(mStatusBarColor);
            dest.writeInt(mNavigationBarColor);
            dest.writeInt(mSystemBarsAppearance);
            dest.writeInt(mTopOpaqueSystemBarsAppearance);
            dest.writeBoolean(mEnsureStatusBarContrastWhenTransparent);
            dest.writeBoolean(mEnsureNavigationBarContrastWhenTransparent);
            dest.writeInt(mResizeMode);
@@ -2466,6 +2494,7 @@ public class ActivityManager {
            mStatusBarColor = source.readInt();
            mNavigationBarColor = source.readInt();
            mSystemBarsAppearance = source.readInt();
            mTopOpaqueSystemBarsAppearance = source.readInt();
            mEnsureStatusBarContrastWhenTransparent = source.readBoolean();
            mEnsureNavigationBarContrastWhenTransparent = source.readBoolean();
            mResizeMode = source.readInt();
@@ -2498,7 +2527,8 @@ public class ActivityManager {
                    + " resizeMode: " + ActivityInfo.resizeModeToString(mResizeMode)
                    + " minWidth: " + mMinWidth + " minHeight: " + mMinHeight
                    + " colorBackgrounFloating: " + mColorBackgroundFloating
                    + " systemBarsAppearance: " + mSystemBarsAppearance;
                    + " systemBarsAppearance: " + mSystemBarsAppearance
                    + " topOpaqueSystemBarsAppearance: " + mTopOpaqueSystemBarsAppearance;
        }

        @Override
@@ -2519,6 +2549,7 @@ public class ActivityManager {
            result = result * 31 + mStatusBarColor;
            result = result * 31 + mNavigationBarColor;
            result = result * 31 + mSystemBarsAppearance;
            result = result * 31 + mTopOpaqueSystemBarsAppearance;
            result = result * 31 + (mEnsureStatusBarContrastWhenTransparent ? 1 : 0);
            result = result * 31 + (mEnsureNavigationBarContrastWhenTransparent ? 1 : 0);
            result = result * 31 + mResizeMode;
@@ -2542,6 +2573,7 @@ public class ActivityManager {
                    && mStatusBarColor == other.mStatusBarColor
                    && mNavigationBarColor == other.mNavigationBarColor
                    && mSystemBarsAppearance == other.mSystemBarsAppearance
                    && mTopOpaqueSystemBarsAppearance == other.mTopOpaqueSystemBarsAppearance
                    && mEnsureStatusBarContrastWhenTransparent
                            == other.mEnsureStatusBarContrastWhenTransparent
                    && mEnsureNavigationBarContrastWhenTransparent
+160 −21
Original line number Diff line number Diff line
@@ -1632,6 +1632,10 @@ public class Notification implements Parcelable
    private Icon mSmallIcon;
    @UnsupportedAppUsage
    private Icon mLargeIcon;
    private Icon mAppIcon;
    /** Cache for whether the notification was posted by a headless system app. */
    private Boolean mBelongsToHeadlessSystemApp = null;
    @UnsupportedAppUsage
    private String mChannelId;
@@ -3079,24 +3083,16 @@ public class Notification implements Parcelable
                    return name.toString();
                }
            }
            // If not, try getting the app info from extras.
            // If not, try getting the name from the app info.
            if (context == null) {
                return null;
            }
            final PackageManager pm = context.getPackageManager();
            if (TextUtils.isEmpty(name)) {
                if (extras.containsKey(EXTRA_BUILDER_APPLICATION_INFO)) {
                    final ApplicationInfo info = extras.getParcelable(
                            EXTRA_BUILDER_APPLICATION_INFO,
                            ApplicationInfo.class);
                ApplicationInfo info = getApplicationInfo(context);
                if (info != null) {
                        name = pm.getApplicationLabel(info);
                    }
                }
                    final PackageManager pm = context.getPackageManager();
                    name = pm.getApplicationLabel(getApplicationInfo(context));
                }
            // If that's still empty, use the one from the context directly.
            if (TextUtils.isEmpty(name)) {
                name = pm.getApplicationLabel(context.getApplicationInfo());
            }
            // If there's still nothing, ¯\_(ツ)_/¯
            if (TextUtils.isEmpty(name)) {
@@ -3109,9 +3105,89 @@ public class Notification implements Parcelable
    }
    /**
     * Whether this notification was posted by a headless system app.
     *
     * If we don't have enough information to figure this out, this will return false. Therefore,
     * false negatives are possible, but false positives should not be.
     *
     * @hide
     */
    public boolean belongsToHeadlessSystemApp(Context context) {
        Trace.beginSection("Notification#belongsToHeadlessSystemApp");
        try {
            if (mBelongsToHeadlessSystemApp != null) {
                return mBelongsToHeadlessSystemApp;
            }
            if (context == null) {
                // Without a valid context, we don't know exactly. Let's assume it doesn't belong to
                // a system app, but not cache the value.
                return false;
            }
            ApplicationInfo info = getApplicationInfo(context);
            if (info != null) {
                if ((info.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
                    // It's not a system app at all.
                    mBelongsToHeadlessSystemApp = false;
                } else {
                    // If there's no launch intent, it's probably a headless app.
                    final PackageManager pm = context.getPackageManager();
                    mBelongsToHeadlessSystemApp = pm.getLaunchIntentForPackage(info.packageName)
                            == null;
                }
            } else {
                // If for some reason we don't have the app info, we don't know; best assume it's
                // not a system app.
                return false;
            }
            return mBelongsToHeadlessSystemApp;
        } finally {
            Trace.endSection();
        }
    }
    /**
     * Get the resource ID of the app icon from application info.
     * @hide
     */
    public int loadHeaderAppIconRes(Context context) {
    public int getHeaderAppIconRes(Context context) {
        ApplicationInfo info = getApplicationInfo(context);
        if (info != null) {
            return info.icon;
        }
        return 0;
    }
    /**
     * Load the app icon drawable from the package manager. This could result in a binder call.
     * @hide
     */
    public Drawable loadHeaderAppIcon(Context context) {
        Trace.beginSection("Notification#loadHeaderAppIcon");
        try {
            if (context == null) {
                Log.e(TAG, "Cannot load the app icon drawable with a null context");
                return null;
            }
            final PackageManager pm = context.getPackageManager();
            ApplicationInfo info = getApplicationInfo(context);
            if (info == null) {
                Log.e(TAG, "Cannot load the app icon drawable: no application info");
                return null;
            }
            return pm.getApplicationIcon(info);
        } finally {
            Trace.endSection();
        }
    }
    /**
     * Fetch the application info from the notification, or the context if that isn't available.
     */
    private ApplicationInfo getApplicationInfo(Context context) {
        ApplicationInfo info = null;
        if (extras.containsKey(EXTRA_BUILDER_APPLICATION_INFO)) {
            info = extras.getParcelable(
@@ -3119,12 +3195,12 @@ public class Notification implements Parcelable
                    ApplicationInfo.class);
        }
        if (info == null) {
            info = context.getApplicationInfo();
            if (context == null) {
                return null;
            }
        if (info != null) {
            return info.icon;
            info = context.getApplicationInfo();
        }
        return 0;
        return info;
    }
    /**
@@ -4123,6 +4199,55 @@ public class Notification implements Parcelable
        mSmallIcon = icon;
    }
    /**
     * The colored app icon that can replace the small icon in the notification starting in V.
     *
     * Before using this value, you should first check whether it's actually being used by the
     * notification by calling {@link Notification#shouldUseAppIcon()}.
     *
     * @hide
     */
    public Icon getAppIcon() {
        if (mAppIcon != null) {
            return mAppIcon;
        }
        // If the app icon hasn't been loaded yet, check if we can load it without a context.
        if (extras.containsKey(EXTRA_BUILDER_APPLICATION_INFO)) {
            final ApplicationInfo info = extras.getParcelable(
                    EXTRA_BUILDER_APPLICATION_INFO,
                    ApplicationInfo.class);
            if (info != null) {
                int appIconRes = info.icon;
                if (appIconRes == 0) {
                    Log.w(TAG, "Failed to get the app icon: no icon in application info");
                    return null;
                }
                mAppIcon = Icon.createWithResource(info.packageName, appIconRes);
                return mAppIcon;
            } else {
                Log.e(TAG, "Failed to get the app icon: "
                        + "there's an EXTRA_BUILDER_APPLICATION_INFO in extras but it's null");
            }
        } else {
            Log.w(TAG, "Failed to get the app icon: no application info in extras");
        }
        return null;
    }
    /**
     * Whether the notification is using the app icon instead of the small icon.
     * @hide
     */
    public boolean shouldUseAppIcon() {
        if (Flags.notificationsUseAppIconInRow()) {
            if (belongsToHeadlessSystemApp(/* context = */ null)) {
                return false;
            }
            return getAppIcon() != null;
        }
        return false;
    }
    /**
     * The large icon shown in this notification's content view.
     * @see Builder#getLargeIcon()
@@ -6116,16 +6241,30 @@ public class Notification implements Parcelable
            if (Flags.notificationsUseAppIcon()) {
                // Override small icon with app icon
                mN.mSmallIcon = Icon.createWithResource(mContext,
                        mN.loadHeaderAppIconRes(mContext));
                        mN.getHeaderAppIconRes(mContext));
            } else if (mN.mSmallIcon == null && mN.icon != 0) {
                mN.mSmallIcon = Icon.createWithResource(mContext, mN.icon);
            }
            boolean usingAppIcon = false;
            if (Flags.notificationsUseAppIconInRow() && !mN.belongsToHeadlessSystemApp(mContext)) {
                // Use the app icon in the view
                int appIconRes = mN.getHeaderAppIconRes(mContext);
                if (appIconRes != 0) {
                    mN.mAppIcon = Icon.createWithResource(mContext, appIconRes);
                    contentView.setImageViewIcon(R.id.icon, mN.mAppIcon);
                    usingAppIcon = true;
                } else {
                    Log.w(TAG, "bindSmallIcon: could not get the app icon");
                }
            }
            if (!usingAppIcon) {
                contentView.setImageViewIcon(R.id.icon, mN.mSmallIcon);
            }
            contentView.setInt(R.id.icon, "setImageLevel", mN.iconLevel);
            // Don't change color if we're using the app icon.
            if (!Flags.notificationsUseAppIcon()) {
            if (!Flags.notificationsUseAppIcon() && !usingAppIcon) {
                processSmallIconColor(mN.mSmallIcon, contentView, p);
            }
        }
Loading