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

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

Snap for 12272146 from d0f6ef48 to 24Q4-release

Change-Id: I27ff8912badd7dbf3b291067dbd331ad72cfb81c
parents 188088de d0f6ef48
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -186,13 +186,12 @@ public class BaseIconFactory implements AutoCloseable {
     * Creates an icon from the bitmap cropped to the current device icon shape
     */
    @NonNull
    public BitmapInfo createShapedIconBitmap(Bitmap icon, IconOptions options) {
        Drawable d = new FixedSizeBitmapDrawable(icon);
    public AdaptiveIconDrawable createShapedAdaptiveIcon(Bitmap iconBitmap) {
        Drawable drawable = new FixedSizeBitmapDrawable(iconBitmap);
        float inset = getExtraInsetFraction();
        inset = inset / (1 + 2 * inset);
        d = new AdaptiveIconDrawable(new ColorDrawable(Color.BLACK),
                new InsetDrawable(d, inset, inset, inset, inset));
        return createBadgedIconBitmap(d, options);
        return new AdaptiveIconDrawable(new ColorDrawable(Color.BLACK),
                new InsetDrawable(drawable, inset, inset, inset, inset));
    }

    @NonNull
@@ -212,7 +211,16 @@ public class BaseIconFactory implements AutoCloseable {
    public BitmapInfo createBadgedIconBitmap(@NonNull Drawable icon,
            @Nullable IconOptions options) {
        float[] scale = new float[1];
        AdaptiveIconDrawable adaptiveIcon = normalizeAndWrapToAdaptiveIcon(icon, null, scale);
        Drawable tempIcon = icon;
        if (options != null
                && options.mIsArchived
                && icon instanceof BitmapDrawable bitmapDrawable) {
            // b/358123888
            // Pre-archived apps can have BitmapDrawables without insets.
            // Need to convert to Adaptive Icon with insets to avoid cropping.
            tempIcon = createShapedAdaptiveIcon(bitmapDrawable.getBitmap());
        }
        AdaptiveIconDrawable adaptiveIcon = normalizeAndWrapToAdaptiveIcon(tempIcon, null, scale);
        Bitmap bitmap = createIconBitmap(adaptiveIcon, scale[0],
                options == null ? MODE_WITH_SHADOW : options.mGenerationMode);

@@ -497,6 +505,8 @@ public class BaseIconFactory implements AutoCloseable {

        boolean mIsInstantApp;

        boolean mIsArchived;

        @BitmapGenerationMode
        int mGenerationMode = MODE_WITH_SHADOW;

+4 −1
Original line number Diff line number Diff line
@@ -541,7 +541,10 @@ public abstract class BaseIconCache {
        }
        if (icon != null) {
            BaseIconFactory li = getIconFactory();
            entry.bitmap = li.createShapedIconBitmap(icon, new IconOptions().setUser(user));
            entry.bitmap = li.createBadgedIconBitmap(
                    li.createShapedAdaptiveIcon(icon),
                    new IconOptions().setUser(user)
            );
            li.close();
        }
        if (!TextUtils.isEmpty(title) && entry.bitmap.icon != null) {
+1 −18
Original line number Diff line number Diff line
@@ -24,26 +24,9 @@ java_library {
        "com_android_systemui_flags_lib",
        "//frameworks/libs/systemui:compilelib",
    ],
    srcs: ["android/src-platform-api/**/*.kt"],
    srcs: ["android/src/**/*.kt"],
}

// TODO(b/358541864): Remove source files of "tracinglib-androidx" and delete this target
// Disable due to compilation error using java.lang.StackWalker:
// java_library {
//     name: "tracinglib-androidx",
//     defaults: ["tracinglib-defaults"],
//     static_libs: [
//         "kotlinx_coroutines_android",
//         "com_android_systemui_flags_lib",
//         "//frameworks/libs/systemui:compilelib",
//         "androidx.tracing_tracing",
//     ],
//     srcs: ["android/src-public-api/**/*.kt"],
//     sdk_version: "31",
//     min_sdk_version: "19",
//     java_version: "17",
// }

java_test_host {
    name: "tracinglib-host-test",
    defaults: ["tracinglib-defaults"],
+0 −77
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.app.tracing

import androidx.tracing.Trace
import java.util.concurrent.ThreadLocalRandom

@PublishedApi
internal actual fun isEnabled(): Boolean {
    return Trace.isEnabled()
}

internal actual fun traceCounter(counterName: String, counterValue: Int) {
    Trace.setCounter(counterName, counterValue)
}

internal actual fun traceBegin(methodName: String) {
    Trace.beginSection(methodName)
}

internal actual fun traceEnd() {
    Trace.endSection()
}

internal actual fun asyncTraceBegin(methodName: String, cookie: Int) {
    Trace.beginAsyncSection(methodName, cookie)
}

internal actual fun asyncTraceEnd(methodName: String, cookie: Int) {
    Trace.endAsyncSection(methodName, cookie)
}

private fun namedSlice(trackName: String, methodName: String) = "$trackName:$methodName"

@PublishedApi
internal actual fun asyncTraceForTrackBegin(trackName: String, methodName: String, cookie: Int) {
    if (isEnabled()) {
        asyncTraceBegin(namedSlice(trackName, methodName), cookie)
    }
}

@PublishedApi
internal actual fun asyncTraceForTrackEnd(trackName: String, methodName: String, cookie: Int) {
    if (isEnabled()) {
        asyncTraceEnd(namedSlice(trackName, methodName), cookie)
    }
}

internal actual fun instant(eventName: String) {
    if (isEnabled()) {
        traceBegin("instant:$eventName")
        traceEnd()
    }
}

internal actual fun instantForTrack(trackName: String, eventName: String) {
    if (Trace.isEnabled()) {
        val cookie = ThreadLocalRandom.current().nextInt()
        val name = "instant:${namedSlice(trackName,eventName)}"
        asyncTraceBegin(name, cookie)
        asyncTraceEnd(name, cookie)
    }
}
Loading