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

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

Snap for 7723257 from 5d99f25c to sc-qpr1-release

Change-Id: I86f84569ad5b4d1cd32e340900f841cf35774f41
parents 8e7db7a7 5d99f25c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -794,6 +794,8 @@ bool BootAnimation::android() {
    // clear screen
    glDisable(GL_DITHER);
    glDisable(GL_SCISSOR_TEST);
    glUseProgram(mImageShader);

    glClearColor(0,0,0,1);
    glClear(GL_COLOR_BUFFER_BIT);
    eglSwapBuffers(mDisplay, mSurface);
+95 −31
Original line number Diff line number Diff line
@@ -1884,6 +1884,14 @@ public class Notification implements Parcelable
             * clicks. To launch an activity in those cases, provide a {@link PendingIntent} for the
             * activity itself.
             *
             * <p>How an Action is displayed, including whether the {@code icon}, {@code text}, or
             * both are displayed or required, depends on where and how the action is used, and the
             * {@link Style} applied to the Notification.
             *
             * <p>When the {@code title} is a {@link android.text.Spanned}, any colors set by a
             * {@link ForegroundColorSpan} or {@link TextAppearanceSpan} may be removed or displayed
             * with an altered in luminance to ensure proper contrast within the Notification.
             *
             * @param icon icon to show for this action
             * @param title the title of the action
             * @param intent the {@link PendingIntent} to fire when users trigger this action
@@ -6121,21 +6129,22 @@ public class Notification implements Parcelable
            if (emphasizedMode) {
                // change the background bgColor
                CharSequence title = action.title;
                ColorStateList[] outResultColor = new ColorStateList[1];
                int buttonFillColor = getColors(p).getSecondaryAccentColor();
                if (isLegacy()) {
                    title = ContrastColorUtil.clearColorSpans(title);
                } else {
                    // Check for a full-length span color to use as the button fill color.
                    Integer fullLengthColor = getFullLengthSpanColor(title);
                    if (fullLengthColor != null) {
                        // Ensure the custom button fill has 1.3:1 contrast w/ notification bg.
                        int notifBackgroundColor = getColors(p).getBackgroundColor();
                    title = ensureColorSpanContrast(title, notifBackgroundColor, outResultColor);
                        buttonFillColor = ensureButtonFillContrast(
                                fullLengthColor, notifBackgroundColor);
                    }
                button.setTextViewText(R.id.action0, processTextSpans(title));
                boolean hasColorOverride = outResultColor[0] != null;
                if (hasColorOverride) {
                    // There's a span spanning the full text, let's take it and use it as the
                    // background color
                    buttonFillColor = outResultColor[0].getDefaultColor();
                    // Remove full-length color spans and ensure text contrast with the button fill.
                    title = ensureColorSpanContrast(title, buttonFillColor);
                }
                button.setTextViewText(R.id.action0, processTextSpans(title));
                final int textColor = ContrastColorUtil.resolvePrimaryColor(mContext,
                        buttonFillColor, mInNightMode);
                button.setTextColor(R.id.action0, textColor);
@@ -6168,17 +6177,58 @@ public class Notification implements Parcelable
        }

        /**
         * Ensures contrast on color spans against a background color. also returns the color of the
         * text if a span was found that spans over the whole text.
         * Extract the color from a full-length span from the text.
         *
         * @param charSequence the charSequence containing spans
         * @return the raw color of the text's last full-length span containing a color, or null if
         * no full-length span sets the text color.
         * @hide
         */
        @VisibleForTesting
        @Nullable
        public static Integer getFullLengthSpanColor(CharSequence charSequence) {
            // NOTE: this method preserves the functionality that for a CharSequence with multiple
            // full-length spans, the color of the last one is used.
            Integer result = null;
            if (charSequence instanceof Spanned) {
                Spanned ss = (Spanned) charSequence;
                Object[] spans = ss.getSpans(0, ss.length(), Object.class);
                // First read through all full-length spans to get the button fill color, which will
                //  be used as the background color for ensuring contrast of non-full-length spans.
                for (Object span : spans) {
                    int spanStart = ss.getSpanStart(span);
                    int spanEnd = ss.getSpanEnd(span);
                    boolean fullLength = (spanEnd - spanStart) == charSequence.length();
                    if (!fullLength) {
                        continue;
                    }
                    if (span instanceof TextAppearanceSpan) {
                        TextAppearanceSpan originalSpan = (TextAppearanceSpan) span;
                        ColorStateList textColor = originalSpan.getTextColor();
                        if (textColor != null) {
                            result = textColor.getDefaultColor();
                        }
                    } else if (span instanceof ForegroundColorSpan) {
                        ForegroundColorSpan originalSpan = (ForegroundColorSpan) span;
                        result = originalSpan.getForegroundColor();
                    }
                }
            }
            return result;
        }

        /**
         * Ensures contrast on color spans against a background color.
         * Note that any full-length color spans will be removed instead of being contrasted.
         *
         * @param charSequence the charSequence on which the spans are
         * @param background the background color to ensure the contrast against
         * @param outResultColor an array in which a color will be returned as the first element if
         *                    there exists a full length color span.
         * @return the contrasted charSequence
         * @hide
         */
        private static CharSequence ensureColorSpanContrast(CharSequence charSequence,
                int background, ColorStateList[] outResultColor) {
        @VisibleForTesting
        public static CharSequence ensureColorSpanContrast(CharSequence charSequence,
                int background) {
            if (charSequence instanceof Spanned) {
                Spanned ss = (Spanned) charSequence;
                Object[] spans = ss.getSpans(0, ss.length(), Object.class);
@@ -6195,6 +6245,10 @@ public class Notification implements Parcelable
                        TextAppearanceSpan originalSpan = (TextAppearanceSpan) resultSpan;
                        ColorStateList textColor = originalSpan.getTextColor();
                        if (textColor != null) {
                            if (fullLength) {
                                // Let's drop the color from the span
                                textColor = null;
                            } else {
                                int[] colors = textColor.getColors();
                                int[] newColors = new int[colors.length];
                                for (int i = 0; i < newColors.length; i++) {
@@ -6204,10 +6258,6 @@ public class Notification implements Parcelable
                                }
                                textColor = new ColorStateList(textColor.getStates().clone(),
                                        newColors);
                            if (fullLength) {
                                outResultColor[0] = textColor;
                                // Let's drop the color from the span
                                textColor = null;
                            }
                            resultSpan = new TextAppearanceSpan(
                                    originalSpan.getFamily(),
@@ -6217,15 +6267,14 @@ public class Notification implements Parcelable
                                    originalSpan.getLinkTextColor());
                        }
                    } else if (resultSpan instanceof ForegroundColorSpan) {
                        if (fullLength) {
                            resultSpan = null;
                        } else {
                            ForegroundColorSpan originalSpan = (ForegroundColorSpan) resultSpan;
                            int foregroundColor = originalSpan.getForegroundColor();
                            boolean isBgDark = isColorDark(background);
                            foregroundColor = ContrastColorUtil.ensureLargeTextContrast(
                                    foregroundColor, background, isBgDark);
                        if (fullLength) {
                            outResultColor[0] = ColorStateList.valueOf(foregroundColor);
                            resultSpan = null;
                        } else {
                            resultSpan = new ForegroundColorSpan(foregroundColor);
                        }
                    } else {
@@ -6254,6 +6303,21 @@ public class Notification implements Parcelable
            return ContrastColorUtil.calculateLuminance(color) <= 0.17912878474;
        }

        /**
         * Finds a button fill color with sufficient contrast over bg (1.3:1) that has the same hue
         * as the original color, but is lightened or darkened depending on whether the background
         * is dark or light.
         *
         * @hide
         */
        @VisibleForTesting
        public static int ensureButtonFillContrast(int color, int bg) {
            return isColorDark(bg)
                    ? ContrastColorUtil.findContrastColorAgainstDark(color, bg, true, 1.3)
                    : ContrastColorUtil.findContrastColor(color, bg, true, 1.3);
        }


        /**
         * @return Whether we are currently building a notification from a legacy (an app that
         *         doesn't create material notifications by itself) app.
+3 −3
Original line number Diff line number Diff line
@@ -1749,12 +1749,12 @@ public class InputMethodService extends AbstractInputMethodService {
        if (config.orientation != Configuration.ORIENTATION_LANDSCAPE) {
            return false;
        }
        if ((mInputEditorInfo != null
                && (mInputEditorInfo.imeOptions & EditorInfo.IME_FLAG_NO_FULLSCREEN) != 0)
        if (mInputEditorInfo != null
                && ((mInputEditorInfo.imeOptions & EditorInfo.IME_FLAG_NO_FULLSCREEN) != 0
                // If app window has portrait orientation, regardless of what display orientation
                // is, IME shouldn't use fullscreen-mode.
                || (mInputEditorInfo.internalImeOptions
                        & EditorInfo.IME_INTERNAL_FLAG_APP_WINDOW_PORTRAIT) != 0) {
                        & EditorInfo.IME_INTERNAL_FLAG_APP_WINDOW_PORTRAIT) != 0)) {
            return false;
        }
        return true;
+74 −18
Original line number Diff line number Diff line
@@ -707,6 +707,10 @@ public class BatteryStatsImpl extends BatteryStats {
     * Mapping isolated uids to the actual owning app uid.
     */
    final SparseIntArray mIsolatedUids = new SparseIntArray();
    /**
     * Internal reference count of isolated uids.
     */
    final SparseIntArray mIsolatedUidRefCounts = new SparseIntArray();
    /**
     * The statistics we have collected organized by uids.
@@ -3897,6 +3901,7 @@ public class BatteryStatsImpl extends BatteryStats {
    public void addIsolatedUidLocked(int isolatedUid, int appUid,
            long elapsedRealtimeMs, long uptimeMs) {
        mIsolatedUids.put(isolatedUid, appUid);
        mIsolatedUidRefCounts.put(isolatedUid, 1);
        final Uid u = getUidStatsLocked(appUid, elapsedRealtimeMs, uptimeMs);
        u.addIsolatedUid(isolatedUid);
    }
@@ -3915,19 +3920,51 @@ public class BatteryStatsImpl extends BatteryStats {
    }
    /**
     * This should only be called after the cpu times have been read.
     * Isolated uid should only be removed after all wakelocks associated with the uid are stopped
     * and the cpu time-in-state has been read one last time for the uid.
     *
     * @see #scheduleRemoveIsolatedUidLocked(int, int)
     *
     * @return true if the isolated uid is actually removed.
     */
    @GuardedBy("this")
    public void removeIsolatedUidLocked(int isolatedUid, long elapsedRealtimeMs, long uptimeMs) {
    public boolean maybeRemoveIsolatedUidLocked(int isolatedUid, long elapsedRealtimeMs,
            long uptimeMs) {
        final int refCount = mIsolatedUidRefCounts.get(isolatedUid, 0) - 1;
        if (refCount > 0) {
            // Isolated uid is still being tracked
            mIsolatedUidRefCounts.put(isolatedUid, refCount);
            return false;
        }
        final int idx = mIsolatedUids.indexOfKey(isolatedUid);
        if (idx >= 0) {
            final int ownerUid = mIsolatedUids.valueAt(idx);
            final Uid u = getUidStatsLocked(ownerUid, elapsedRealtimeMs, uptimeMs);
            u.removeIsolatedUid(isolatedUid);
            mIsolatedUids.removeAt(idx);
            mIsolatedUidRefCounts.delete(isolatedUid);
        } else {
            Slog.w(TAG, "Attempted to remove untracked isolated uid (" + isolatedUid + ")");
        }
        mPendingRemovedUids.add(new UidToRemove(isolatedUid, elapsedRealtimeMs));
        return true;
    }
    /**
     * Increment the ref count for an isolated uid.
     * call #maybeRemoveIsolatedUidLocked to decrement.
     */
    public void incrementIsolatedUidRefCount(int uid) {
        final int refCount = mIsolatedUidRefCounts.get(uid, 0);
        if (refCount <= 0) {
            // Uid is not mapped or referenced
            Slog.w(TAG,
                    "Attempted to increment ref counted of untracked isolated uid (" + uid + ")");
            return;
        }
        mIsolatedUidRefCounts.put(uid, refCount + 1);
    }
    public int mapUid(int uid) {
@@ -4287,7 +4324,7 @@ public class BatteryStatsImpl extends BatteryStats {
    public void noteStartWakeLocked(int uid, int pid, WorkChain wc, String name, String historyName,
            int type, boolean unimportantForLogging, long elapsedRealtimeMs, long uptimeMs) {
        uid = mapUid(uid);
        final int mappedUid = mapUid(uid);
        if (type == WAKE_TYPE_PARTIAL) {
            // Only care about partial wake locks, since full wake locks
            // will be canceled when the user puts the screen to sleep.
@@ -4297,9 +4334,9 @@ public class BatteryStatsImpl extends BatteryStats {
            }
            if (mRecordAllHistory) {
                if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_START, historyName,
                        uid, 0)) {
                        mappedUid, 0)) {
                    addHistoryEventLocked(elapsedRealtimeMs, uptimeMs,
                            HistoryItem.EVENT_WAKE_LOCK_START, historyName, uid);
                            HistoryItem.EVENT_WAKE_LOCK_START, historyName, mappedUid);
                }
            }
            if (mWakeLockNesting == 0) {
@@ -4308,7 +4345,7 @@ public class BatteryStatsImpl extends BatteryStats {
                        + Integer.toHexString(mHistoryCur.states));
                mHistoryCur.wakelockTag = mHistoryCur.localWakelockTag;
                mHistoryCur.wakelockTag.string = mInitialAcquireWakeName = historyName;
                mHistoryCur.wakelockTag.uid = mInitialAcquireWakeUid = uid;
                mHistoryCur.wakelockTag.uid = mInitialAcquireWakeUid = mappedUid;
                mWakeLockImportant = !unimportantForLogging;
                addHistoryRecordLocked(elapsedRealtimeMs, uptimeMs);
            } else if (!mWakeLockImportant && !unimportantForLogging
@@ -4318,14 +4355,19 @@ public class BatteryStatsImpl extends BatteryStats {
                    mHistoryLastWritten.wakelockTag = null;
                    mHistoryCur.wakelockTag = mHistoryCur.localWakelockTag;
                    mHistoryCur.wakelockTag.string = mInitialAcquireWakeName = historyName;
                    mHistoryCur.wakelockTag.uid = mInitialAcquireWakeUid = uid;
                    mHistoryCur.wakelockTag.uid = mInitialAcquireWakeUid = mappedUid;
                    addHistoryRecordLocked(elapsedRealtimeMs, uptimeMs);
                }
                mWakeLockImportant = true;
            }
            mWakeLockNesting++;
        }
        if (uid >= 0) {
        if (mappedUid >= 0) {
            if (mappedUid != uid) {
                // Prevent the isolated uid mapping from being removed while the wakelock is
                // being held.
                incrementIsolatedUidRefCount(uid);
            }
            if (mOnBatteryScreenOffTimeBase.isRunning()) {
                // We only update the cpu time when a wake lock is acquired if the screen is off.
                // If the screen is on, we don't distribute the power amongst partial wakelocks.
@@ -4335,7 +4377,7 @@ public class BatteryStatsImpl extends BatteryStats {
                requestWakelockCpuUpdate();
            }
            getUidStatsLocked(uid, elapsedRealtimeMs, uptimeMs)
            getUidStatsLocked(mappedUid, elapsedRealtimeMs, uptimeMs)
                    .noteStartWakeLocked(pid, name, type, elapsedRealtimeMs);
            if (wc != null) {
@@ -4343,8 +4385,8 @@ public class BatteryStatsImpl extends BatteryStats {
                        wc.getTags(), getPowerManagerWakeLockLevel(type), name,
                        FrameworkStatsLog.WAKELOCK_STATE_CHANGED__STATE__ACQUIRE);
            } else {
                FrameworkStatsLog.write_non_chained(FrameworkStatsLog.WAKELOCK_STATE_CHANGED, uid,
                        null, getPowerManagerWakeLockLevel(type), name,
                FrameworkStatsLog.write_non_chained(FrameworkStatsLog.WAKELOCK_STATE_CHANGED,
                        mappedUid, null, getPowerManagerWakeLockLevel(type), name,
                        FrameworkStatsLog.WAKELOCK_STATE_CHANGED__STATE__ACQUIRE);
            }
        }
@@ -4358,7 +4400,7 @@ public class BatteryStatsImpl extends BatteryStats {
    public void noteStopWakeLocked(int uid, int pid, WorkChain wc, String name, String historyName,
            int type, long elapsedRealtimeMs, long uptimeMs) {
        uid = mapUid(uid);
        final int mappedUid = mapUid(uid);
        if (type == WAKE_TYPE_PARTIAL) {
            mWakeLockNesting--;
            if (mRecordAllHistory) {
@@ -4366,9 +4408,9 @@ public class BatteryStatsImpl extends BatteryStats {
                    historyName = name;
                }
                if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_FINISH, historyName,
                        uid, 0)) {
                        mappedUid, 0)) {
                    addHistoryEventLocked(elapsedRealtimeMs, uptimeMs,
                            HistoryItem.EVENT_WAKE_LOCK_FINISH, historyName, uid);
                            HistoryItem.EVENT_WAKE_LOCK_FINISH, historyName, mappedUid);
                }
            }
            if (mWakeLockNesting == 0) {
@@ -4380,7 +4422,7 @@ public class BatteryStatsImpl extends BatteryStats {
                addHistoryRecordLocked(elapsedRealtimeMs, uptimeMs);
            }
        }
        if (uid >= 0) {
        if (mappedUid >= 0) {
            if (mOnBatteryScreenOffTimeBase.isRunning()) {
                if (DEBUG_ENERGY_CPU) {
                    Slog.d(TAG, "Updating cpu time because of -wake_lock");
@@ -4388,17 +4430,22 @@ public class BatteryStatsImpl extends BatteryStats {
                requestWakelockCpuUpdate();
            }
            getUidStatsLocked(uid, elapsedRealtimeMs, uptimeMs)
            getUidStatsLocked(mappedUid, elapsedRealtimeMs, uptimeMs)
                    .noteStopWakeLocked(pid, name, type, elapsedRealtimeMs);
            if (wc != null) {
                FrameworkStatsLog.write(FrameworkStatsLog.WAKELOCK_STATE_CHANGED, wc.getUids(),
                        wc.getTags(), getPowerManagerWakeLockLevel(type), name,
                        FrameworkStatsLog.WAKELOCK_STATE_CHANGED__STATE__RELEASE);
            } else {
                FrameworkStatsLog.write_non_chained(FrameworkStatsLog.WAKELOCK_STATE_CHANGED, uid,
                        null, getPowerManagerWakeLockLevel(type), name,
                FrameworkStatsLog.write_non_chained(FrameworkStatsLog.WAKELOCK_STATE_CHANGED,
                        mappedUid, null, getPowerManagerWakeLockLevel(type), name,
                        FrameworkStatsLog.WAKELOCK_STATE_CHANGED__STATE__RELEASE);
            }
            if (mappedUid != uid) {
                // Decrement the ref count for the isolated uid and delete the mapping if uneeded.
                maybeRemoveIsolatedUidLocked(uid, elapsedRealtimeMs, uptimeMs);
            }
        }
    }
@@ -16761,6 +16808,15 @@ public class BatteryStatsImpl extends BatteryStats {
        pw.print("UIDs removed since the later of device start or stats reset: ");
        pw.println(mNumUidsRemoved);
        pw.println("Currently mapped isolated uids:");
        final int numIsolatedUids = mIsolatedUids.size();
        for (int i = 0; i < numIsolatedUids; i++) {
            final int isolatedUid = mIsolatedUids.keyAt(i);
            final int ownerUid = mIsolatedUids.valueAt(i);
            final int refCount = mIsolatedUidRefCounts.get(isolatedUid);
            pw.println("  " + isolatedUid + "->" + ownerUid + " (ref count = " + refCount + ")");
        }
        pw.println();
        dumpConstantsLocked(pw);
+170 −11

File changed.

Preview size limit exceeded, changes collapsed.

Loading