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

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

Snap for 12397640 from ab431b16 to 24Q4-release

Change-Id: I3770eebed9b7bb5e575eaffe4463283a516bc434
parents c6db9d92 ab431b16
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.WorkerThread;

import com.android.launcher3.Flags;
import com.android.launcher3.icons.BaseIconFactory;
import com.android.launcher3.icons.BaseIconFactory.IconOptions;
import com.android.launcher3.icons.BitmapInfo;
@@ -381,8 +382,8 @@ public abstract class BaseIconCache {
        entry.contentDescription = getUserBadgedLabel(entry.title, user);
        if (cachingLogic.addToMemCache()) mCache.put(key, entry);

        ContentValues values = newContentValues(entry.bitmap, entry.title.toString(),
                componentName.getPackageName(), cachingLogic.getKeywords(object, mLocaleList));
        ContentValues values = newContentValues(
                entry.bitmap, entry.title.toString(), componentName.getPackageName());
        addIconToDB(values, componentName, info, userSerial,
                cachingLogic.getLastUpdatedTime(object, info));
    }
@@ -644,7 +645,7 @@ public abstract class BaseIconCache {
                    // Add the icon in the DB here, since these do not get written during
                    // package updates.
                    ContentValues values = newContentValues(
                            iconInfo, entry.title.toString(), packageName, null);
                            iconInfo, entry.title.toString(), packageName);
                    addIconToDB(values, cacheKey.componentName, info, getSerialNumberForUser(user),
                            info.lastUpdateTime);

@@ -750,7 +751,9 @@ public abstract class BaseIconCache {
     * Cache class to store the actual entries on disk
     */
    public static final class IconDB extends SQLiteCacheHelper {
        private static final int RELEASE_VERSION = 34;
        // Ensures archived app icons are invalidated after flag is flipped.
        // TODO: Remove conditional with FLAG_USE_NEW_ICON_FOR_ARCHIVED_APPS
        private static final int RELEASE_VERSION = Flags.useNewIconForArchivedApps() ? 35 : 34;

        public static final String TABLE_NAME = "icons";
        public static final String COLUMN_ROWID = "rowid";
@@ -764,7 +767,6 @@ public abstract class BaseIconCache {
        public static final String COLUMN_FLAGS = "flags";
        public static final String COLUMN_LABEL = "label";
        public static final String COLUMN_SYSTEM_STATE = "system_state";
        public static final String COLUMN_KEYWORDS = "keywords";

        public static final String[] COLUMNS_LOW_RES = new String[]{
                COLUMN_COMPONENT,
@@ -803,7 +805,6 @@ public abstract class BaseIconCache {
                    + COLUMN_FLAGS + " INTEGER NOT NULL DEFAULT 0, "
                    + COLUMN_LABEL + " TEXT, "
                    + COLUMN_SYSTEM_STATE + " TEXT, "
                    + COLUMN_KEYWORDS + " TEXT, "
                    + "PRIMARY KEY (" + COLUMN_COMPONENT + ", " + COLUMN_USER + ") "
                    + ");");
        }
@@ -811,8 +812,7 @@ public abstract class BaseIconCache {

    @NonNull
    private ContentValues newContentValues(@NonNull final BitmapInfo bitmapInfo,
            @NonNull final String label, @NonNull final String packageName,
            @Nullable final String keywords) {
            @NonNull final String label, @NonNull final String packageName) {
        ContentValues values = new ContentValues();
        if (bitmapInfo.canPersist()) {
            values.put(IconDB.COLUMN_ICON, flattenBitmap(bitmapInfo.icon));
@@ -837,7 +837,6 @@ public abstract class BaseIconCache {

        values.put(IconDB.COLUMN_LABEL, label);
        values.put(IconDB.COLUMN_SYSTEM_STATE, getIconSystemState(packageName));
        values.put(IconDB.COLUMN_KEYWORDS, keywords);
        return values;
    }

+0 −9
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.launcher3.icons.cache;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.os.LocaleList;
import android.os.UserHandle;

import androidx.annotation.NonNull;
@@ -49,14 +48,6 @@ public interface CachingLogic<T> {
    @NonNull
    BitmapInfo loadIcon(@NonNull Context context, @NonNull BaseIconCache cache, @NonNull T object);

    /**
     * Provides a option list of keywords to associate with this object
     */
    @Nullable
    default String getKeywords(@NonNull final T object, @NonNull final LocaleList localeList) {
        return null;
    }

    /**
     * Returns the timestamp the entry was last updated in cache.
     */
+8 −8
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@ import android.platform.test.flag.junit.SetFlagsRule
import android.platform.test.rule.EnsureDeviceSettingsRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.app.tracing.coroutines.TraceContextElement
import com.android.app.tracing.coroutines.launch
import com.android.app.tracing.coroutines.createCoroutineTracingContext
import com.android.app.tracing.coroutines.nameCoroutine
import com.android.app.tracing.coroutines.traceCoroutine
import com.android.systemui.Flags
import kotlinx.coroutines.delay
@@ -74,7 +74,7 @@ class TraceContextMicroBenchmark {
    @Test
    fun testSingleTraceSection() {
        val state = perfStatusReporter.benchmarkState
        runBlocking(TraceContextElement()) {
        runBlocking(createCoroutineTracingContext("root")) {
            while (state.keepRunning()) {
                traceCoroutine("hello-world") { ensureSuspend(state) }
            }
@@ -86,8 +86,8 @@ class TraceContextMicroBenchmark {
    fun testNestedContext() {
        val state = perfStatusReporter.benchmarkState

        val context1 = TraceContextElement()
        val context2 = TraceContextElement()
        val context1 = createCoroutineTracingContext("scope1")
        val context2 = nameCoroutine("scope2")
        runBlocking {
            while (state.keepRunning()) {
                withContext(context1) {
@@ -113,9 +113,9 @@ class TraceContextMicroBenchmark {
    fun testInterleavedLaunch() {
        val state = perfStatusReporter.benchmarkState

        runBlocking(TraceContextElement()) {
        runBlocking(createCoroutineTracingContext("root")) {
            val job1 =
                launch(TraceContextElement()) {
                launch(nameCoroutine("scope1")) {
                    while (true) {
                        traceCoroutine("hello") {
                            traceCoroutine("world") { yield() }
@@ -124,7 +124,7 @@ class TraceContextMicroBenchmark {
                    }
                }
            val job2 =
                launch(TraceContextElement()) {
                launch(nameCoroutine("scope2")) {
                    while (true) {
                        traceCoroutine("hallo") {
                            traceCoroutine("welt") { yield() }
+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ java_library {
    static_libs: [
        "kotlinx_coroutines_android",
        "com_android_systemui_flags_lib",
        "//frameworks/libs/systemui:compilelib",
    ],
    libs: [
        "androidx.annotation_annotation",
+31 −45
Original line number Diff line number Diff line
@@ -16,15 +16,14 @@

package com.android.app.tracing.coroutines

import android.os.Trace
import com.android.systemui.util.Compile
import java.util.concurrent.ThreadLocalRandom
import com.android.systemui.Flags
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
@@ -33,8 +32,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext

const val TAG = "CoroutineTracing"

const val DEFAULT_TRACK_NAME = "Coroutines"

@OptIn(ExperimentalContracts::class)
@@ -58,21 +55,21 @@ suspend inline fun <R> coroutineScope(
inline fun CoroutineScope.launch(
    crossinline spanName: () -> String,
    context: CoroutineContext = EmptyCoroutineContext,
    // TODO(b/306457056): DO NOT pass CoroutineStart; doing so will regress .odex size
    crossinline block: suspend CoroutineScope.() -> Unit,
): Job = launch(context) { traceCoroutine(spanName) { block() } }
    start: CoroutineStart = CoroutineStart.DEFAULT,
    noinline block: suspend CoroutineScope.() -> Unit,
): Job = launch(nameCoroutine(spanName) + context, start, block)

/**
 * Convenience function for calling [CoroutineScope.launch] with [traceCoroutine] to enable tracing.
 *
 * @see traceCoroutine
 */
inline fun CoroutineScope.launch(
fun CoroutineScope.launch(
    spanName: String,
    context: CoroutineContext = EmptyCoroutineContext,
    // TODO(b/306457056): DO NOT pass CoroutineStart; doing so will regress .odex size
    crossinline block: suspend CoroutineScope.() -> Unit,
): Job = launch(context) { traceCoroutine(spanName) { block() } }
    start: CoroutineStart = CoroutineStart.DEFAULT,
    block: suspend CoroutineScope.() -> Unit,
): Job = launch(nameCoroutine(spanName) + context, start, block)

/**
 * Convenience function for calling [CoroutineScope.async] with [traceCoroutine] enable tracing
@@ -80,23 +77,23 @@ inline fun CoroutineScope.launch(
 * @see traceCoroutine
 */
inline fun <T> CoroutineScope.async(
    crossinline spanName: () -> String,
    spanName: () -> String,
    context: CoroutineContext = EmptyCoroutineContext,
    // TODO(b/306457056): DO NOT pass CoroutineStart; doing so will regress .odex size
    crossinline block: suspend CoroutineScope.() -> T,
): Deferred<T> = async(context) { traceCoroutine(spanName) { block() } }
    start: CoroutineStart = CoroutineStart.DEFAULT,
    noinline block: suspend CoroutineScope.() -> T,
): Deferred<T> = async(nameCoroutine(spanName) + context, start, block)

/**
 * Convenience function for calling [CoroutineScope.async] with [traceCoroutine] enable tracing.
 *
 * @see traceCoroutine
 */
inline fun <T> CoroutineScope.async(
fun <T> CoroutineScope.async(
    spanName: String,
    context: CoroutineContext = EmptyCoroutineContext,
    // TODO(b/306457056): DO NOT pass CoroutineStart; doing so will regress .odex size
    crossinline block: suspend CoroutineScope.() -> T,
): Deferred<T> = async(context) { traceCoroutine(spanName) { block() } }
    start: CoroutineStart = CoroutineStart.DEFAULT,
    block: suspend CoroutineScope.() -> T,
): Deferred<T> = async(nameCoroutine(spanName) + context, start, block)

/**
 * Convenience function for calling [runBlocking] with [traceCoroutine] to enable tracing.
@@ -104,32 +101,32 @@ inline fun <T> CoroutineScope.async(
 * @see traceCoroutine
 */
inline fun <T> runBlocking(
    crossinline spanName: () -> String,
    spanName: () -> String,
    context: CoroutineContext,
    crossinline block: suspend () -> T,
): T = runBlocking(context) { traceCoroutine(spanName) { block() } }
    noinline block: suspend CoroutineScope.() -> T,
): T = runBlocking(nameCoroutine(spanName) + context, block)

/**
 * Convenience function for calling [runBlocking] with [traceCoroutine] to enable tracing.
 *
 * @see traceCoroutine
 */
inline fun <T> runBlocking(
fun <T> runBlocking(
    spanName: String,
    context: CoroutineContext,
    crossinline block: suspend CoroutineScope.() -> T,
): T = runBlocking(context) { traceCoroutine(spanName) { block() } }
    block: suspend CoroutineScope.() -> T,
): T = runBlocking(nameCoroutine(spanName) + context, block)

/**
 * Convenience function for calling [withContext] with [traceCoroutine] to enable tracing.
 *
 * @see traceCoroutine
 */
suspend inline fun <T> withContext(
suspend fun <T> withContext(
    spanName: String,
    context: CoroutineContext,
    crossinline block: suspend CoroutineScope.() -> T,
): T = withContext(context) { traceCoroutine(spanName) { block() } }
    block: suspend CoroutineScope.() -> T,
): T = withContext(nameCoroutine(spanName) + context, block)

/**
 * Convenience function for calling [withContext] with [traceCoroutine] to enable tracing.
@@ -137,10 +134,10 @@ suspend inline fun <T> withContext(
 * @see traceCoroutine
 */
suspend inline fun <T> withContext(
    crossinline spanName: () -> String,
    spanName: () -> String,
    context: CoroutineContext,
    crossinline block: suspend CoroutineScope.() -> T,
): T = withContext(context) { traceCoroutine(spanName) { block() } }
    noinline block: suspend CoroutineScope.() -> T,
): T = withContext(nameCoroutine(spanName) + context, block)

/**
 * Traces a section of work of a `suspend` [block]. The trace sections will appear on the thread
@@ -189,22 +186,11 @@ inline fun <T> traceCoroutine(spanName: () -> String, block: () -> T): T {
    // For coroutine tracing to work, trace spans must be added and removed even when
    // tracing is not active (i.e. when TRACE_TAG_APP is disabled). Otherwise, when the
    // coroutine resumes when tracing is active, we won't know its name.
    val traceData = if (Compile.IS_DEBUG) traceThreadLocal.get() else null
    val asyncTracingEnabled = Trace.isEnabled()
    val spanString = if (traceData != null || asyncTracingEnabled) spanName() else "<none>"
    traceData?.beginSpan(spanString)

    // Also trace to the "Coroutines" async track. This makes it easy to see the duration of
    // coroutine spans. When the coroutine_tracing flag is enabled, those same names will
    // appear in small slices on each thread as the coroutines are suspended and resumed.
    val cookie = if (asyncTracingEnabled) ThreadLocalRandom.current().nextInt() else 0
    if (asyncTracingEnabled)
        Trace.asyncTraceForTrackBegin(Trace.TRACE_TAG_APP, DEFAULT_TRACK_NAME, spanString, cookie)
    val traceData = if (Flags.coroutineTracing()) traceThreadLocal.get() else null
    traceData?.beginSpan(spanName())
    try {
        return block()
    } finally {
        if (asyncTracingEnabled)
            Trace.asyncTraceForTrackEnd(Trace.TRACE_TAG_APP, DEFAULT_TRACK_NAME, cookie)
        traceData?.endSpan()
    }
}
Loading