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

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

Snap for 12955189 from 89fb0138 to 25Q2-release

Change-Id: Ife9e2f51df5db12054f10f1021ea26d7dfb6ec72
parents 618bcb0f 89fb0138
Loading
Loading
Loading
Loading
+0 −32
Original line number Diff line number Diff line
@@ -16,22 +16,14 @@
package com.android.launcher3.icons;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.RegionIterator;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.ColorDrawable;
import android.util.Log;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.core.graphics.PathParser;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -99,30 +91,6 @@ public class GraphicsUtils {
        sOnNewBitmapRunnable.run();
    }


    /**
     * Returns the default path to be used by an icon
     */
    public static Path getShapePath(@NonNull Context context, int size) {
        if (IconProvider.CONFIG_ICON_MASK_RES_ID != Resources.ID_NULL) {
            Path path = PathParser.createPathFromPathData(
                    context.getString(IconProvider.CONFIG_ICON_MASK_RES_ID));
            if (path != null) {
                if (size != MASK_SIZE) {
                    Matrix m = new Matrix();
                    float scale = ((float) size) / MASK_SIZE;
                    m.setScale(scale, scale);
                    path.transform(m);
                }
                return path;
            }
        }
        AdaptiveIconDrawable drawable = new AdaptiveIconDrawable(
                new ColorDrawable(Color.BLACK), new ColorDrawable(Color.BLACK));
        drawable.setBounds(0, 0, size, size);
        return new Path(drawable.getIconMask());
    }

    /**
     * Returns the color associated with the attribute
     */
+14 −2
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;

import androidx.core.graphics.ColorUtils;
@@ -39,12 +41,22 @@ public class PlaceHolderIconDrawable extends FastBitmapDrawable {

    public PlaceHolderIconDrawable(BitmapInfo info, Context context) {
        super(info);

        mProgressPath = GraphicsUtils.getShapePath(context, 100);
        mProgressPath = getDefaultPath();
        mPaint.setColor(ColorUtils.compositeColors(
                GraphicsUtils.getAttrColor(context, R.attr.loadingIconColor), info.color));
    }

    /**
     * Gets the current default icon mask {@link Path}.
     * @return Shaped {@link Path} scaled to [0, 0, 100, 100] bounds
     */
    private Path getDefaultPath() {
        AdaptiveIconDrawable drawable = new AdaptiveIconDrawable(
                new ColorDrawable(Color.BLACK), new ColorDrawable(Color.BLACK));
        drawable.setBounds(0, 0, 100, 100);
        return new Path(drawable.getIconMask());
    }

    @Override
    protected void drawInternal(Canvas canvas, Rect bounds) {
        int saveCount = canvas.save();
+2 −2
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ 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.systemui.Flags
import com.android.systemui.Flags.FLAG_COROUTINE_TRACING
import java.util.concurrent.atomic.AtomicInteger
import org.junit.After
import org.junit.Assert
@@ -33,7 +33,7 @@ import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
@EnableFlags(Flags.FLAG_COROUTINE_TRACING)
@EnableFlags(FLAG_COROUTINE_TRACING)
class ThreadLocalMicroBenchmark {

    @get:Rule val setFlagsRule = SetFlagsRule()
+2 −2
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import androidx.test.filters.SmallTest
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 com.android.systemui.Flags.FLAG_COROUTINE_TRACING
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
@@ -41,7 +41,7 @@ import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
@EnableFlags(Flags.FLAG_COROUTINE_TRACING)
@EnableFlags(FLAG_COROUTINE_TRACING)
class TraceContextMicroBenchmark {

    @get:Rule val setFlagsRule = SetFlagsRule()
+28 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.app.tracing

import android.annotation.SuppressLint
import android.os.Trace
import com.android.app.tracing.TrackGroupUtils.trackGroup
import com.android.app.tracing.coroutines.traceCoroutine
import java.util.concurrent.ThreadLocalRandom
import kotlin.contracts.ExperimentalContracts
@@ -238,4 +239,31 @@ public object TraceUtils {
            block()
        }
    }

    /** Starts an async slice, and returns a runnable that stops the slice. */
    @JvmStatic
    public fun traceAsyncClosable(
        traceTag: Long = Trace.TRACE_TAG_APP,
        trackName: String,
        sliceName: String,
    ): () -> Unit {
        val cookie = ThreadLocalRandom.current().nextInt()
        Trace.asyncTraceForTrackBegin(traceTag, trackName, sliceName, cookie)
        return { Trace.asyncTraceForTrackEnd(traceTag, trackName, cookie) }
    }

    /** Starts an async slice, and returns a runnable that stops the slice. */
    @JvmStatic
    @JvmOverloads
    public fun traceAsyncClosable(
        traceTag: Long = Trace.TRACE_TAG_APP,
        trackGroupName: String,
        trackName: String,
        sliceName: String,
    ): () -> Unit {
        val groupedTrackName = trackGroup(trackGroupName, trackName)
        val cookie = ThreadLocalRandom.current().nextInt()
        Trace.asyncTraceForTrackBegin(traceTag, groupedTrackName, sliceName, cookie)
        return { Trace.asyncTraceForTrackEnd(traceTag, groupedTrackName, cookie) }
    }
}
Loading