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

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

Snap for 12881634 from 542d9782 to 25Q2-release

Change-Id: I7d2edb9f4a04580d27a6dc6bc4b255898c2a0ab8
parents 49794981 542d9782
Loading
Loading
Loading
Loading
+4 −34
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import android.graphics.drawable.InsetDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.PatternMatcher;
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
@@ -62,7 +61,6 @@ import java.util.Objects;
 */
public class IconProvider {

    private final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
    static final int CONFIG_ICON_MASK_RES_ID = Resources.getSystem().getIdentifier(
            "config_icon_mask", "string", "android");

@@ -79,7 +77,7 @@ public class IconProvider {
    private final ComponentName mClock;

    @NonNull
    private String mSystemState = "";
    protected String mSystemState = "";

    public IconProvider(Context context) {
        mContext = context;
@@ -290,14 +288,6 @@ public class IconProvider {
        return TextUtils.isEmpty(cn) ? null : ComponentName.unflattenFromString(cn);
    }

    /**
     * Returns a string representation of the current system icon state
     */
    public String getSystemIconState() {
        return (CONFIG_ICON_MASK_RES_ID == ID_NULL
                ? "" : mContext.getResources().getString(CONFIG_ICON_MASK_RES_ID));
    }

    /**
     * Registers a callback to listen for various system dependent icon changes.
     */
@@ -330,18 +320,9 @@ public class IconProvider {
    private class IconChangeReceiver extends BroadcastReceiver implements SafeCloseable {

        private final IconChangeListener mCallback;
        private String mIconState;

        IconChangeReceiver(IconChangeListener callback, Handler handler) {
            mCallback = callback;
            mIconState = getSystemIconState();


            IntentFilter packageFilter = new IntentFilter(ACTION_OVERLAY_CHANGED);
            packageFilter.addDataScheme("package");
            packageFilter.addDataSchemeSpecificPart("android", PatternMatcher.PATTERN_LITERAL);
            mContext.registerReceiver(this, packageFilter, null, handler);

            if (mCalendar != null || mClock != null) {
                final IntentFilter filter = new IntentFilter(ACTION_TIMEZONE_CHANGED);
                if (mCalendar != null) {
@@ -369,20 +350,14 @@ public class IconProvider {
                        }
                    }
                    break;
                case ACTION_OVERLAY_CHANGED: {
                    String newState = getSystemIconState();
                    if (!mIconState.equals(newState)) {
                        mIconState = newState;
                        mCallback.onSystemIconStateChanged(mIconState);
                    }
                    break;
                }
            }
        }

        @Override
        public void close() {
            try {
                mContext.unregisterReceiver(this);
            } catch (Exception ignored) { }
        }
    }

@@ -395,10 +370,5 @@ public class IconProvider {
         * Called when the icon for a particular app changes
         */
        void onAppIconChanged(String packageName, UserHandle user);

        /**
         * Called when the global icon state changed, which can typically affect all icons
         */
        void onSystemIconStateChanged(String iconState);
    }
}
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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

public object TrackGroupUtils {
    /**
     * Generates a track name in a way that perfetto can group tracks together.
     *
     * This leverages the "Create process workspace" perfetto plugin. This plugins parses all the
     * tracks that follow the "groupName##trackName" format, nesting "trackName" under "groupName".
     *
     * This allows to easily group tracks that are related under a single summary track (e.g. all
     * "shade" related tracks will appear together, under the "shade" track in the process
     * workspace).
     */
    public fun trackGroup(groupName: String, trackName: String): String = "$groupName##$trackName"
}
+33 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.app.tracing.coroutines

import android.os.Trace
import com.android.app.tracing.TraceUtils
import com.android.app.tracing.TrackGroupUtils.trackGroup
import java.io.Closeable
import java.util.concurrent.ThreadLocalRandom
import kotlin.contracts.ExperimentalContracts
@@ -41,9 +42,13 @@ import kotlin.contracts.contract
 */
@OptIn(ExperimentalContracts::class)
public class TrackTracer(
    public val trackName: String,
    trackName: String,
    public val traceTag: Long = Trace.TRACE_TAG_APP,
    public val trackGroup: String? = null,
) {
    public val trackName: String =
        if (trackGroup != null) trackGroup(trackGroup, trackName) else trackName

    /** See [Trace.instantForTrack]. */
    public inline fun instant(s: () -> String) {
        if (!Trace.isEnabled()) return
@@ -71,4 +76,31 @@ public class TrackTracer(
        Trace.asyncTraceForTrackBegin(traceTag, trackName, sliceName, cookie)
        return Closeable { Trace.asyncTraceForTrackEnd(traceTag, trackName, cookie) }
    }

    public companion object {
        /**
         * Creates an instant event for a track called [trackName] inside [groupName]. See
         * [trackGroup] for details on how the rendering in groups works.
         */
        @JvmStatic
        public fun instantForGroup(groupName: String, trackName: String, i: Int) {
            Trace.traceCounter(Trace.TRACE_TAG_APP, trackGroup(groupName, trackName), i)
        }

        /** Creates an instant event for [groupName] grgorp, see [instantForGroup]. */
        @JvmStatic
        public inline fun instantForGroup(groupName: String, trackName: () -> String, i: Int) {
            if (!Trace.isEnabled()) return
            instantForGroup(groupName, trackName(), i)
        }

        /**
         * Creates an instant event, see [instantForGroup], converting [i] to an int by multiplying
         * it by 100.
         */
        @JvmStatic
        public fun instantForGroup(groupName: String, trackName: String, i: Float) {
            instantForGroup(groupName, trackName, (i * 100).toInt())
        }
    }
}