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

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

Snap for 11142129 from 0dbb1ef9 to 24Q1-release

Change-Id: Ifec411e62c71aae0f39c12dffeaaa9aa4d623bd8
parents 7b171144 0dbb1ef9
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -29,3 +29,10 @@ flag {
      "Notification Manager Service"
  bug: "299448097"
}

flag {
  name: "visit_risky_uris"
  namespace: "systemui"
  description: "Guards the security fix that ensures all URIs in intents and Person.java are valid"
  bug: "281044385"
}
+17 −2
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import android.view.inputmethod.BaseInputConnection;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.IResultReceiver;
import com.android.modules.expresslog.Counter;

import java.io.PrintWriter;
import java.lang.ref.WeakReference;
@@ -68,6 +69,7 @@ import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Main session associated with a context.
@@ -81,6 +83,9 @@ public final class MainContentCaptureSession extends ContentCaptureSession {

    private static final String TAG = MainContentCaptureSession.class.getSimpleName();

    private static final String CONTENT_CAPTURE_WRONG_THREAD_METRIC_ID =
            "content_capture.value_content_capture_wrong_thread_count";

    // For readability purposes...
    private static final boolean FORCE_FLUSH = true;

@@ -165,6 +170,8 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
    @Nullable
    private final LocalLog mFlushHistory;

    private final AtomicInteger mWrongThreadCount = new AtomicInteger(0);

    /**
     * Binder object used to update the session state.
     */
@@ -701,6 +708,7 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
                    + getDebugState());
        }

        reportWrongThreadMetric();
        try {
            mSystemServerInterface.finishSession(mId);
        } catch (RemoteException e) {
@@ -1040,20 +1048,27 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
    }

    /**
     * Checks that the current work is running on the assigned thread from {@code mHandler}.
     * Checks that the current work is running on the assigned thread from {@code mHandler} and
     * count the number of times running on the wrong thread.
     *
     * <p>It is not guaranteed that the callers always invoke function from a single thread.
     * Therefore, accessing internal properties in {@link MainContentCaptureSession} should
     * always delegate to the assigned thread from {@code mHandler} for synchronization.</p>
     */
    private void checkOnContentCaptureThread() {
        // TODO(b/309411951): Add metrics to track the issue instead.
        final boolean onContentCaptureThread = mHandler.getLooper().isCurrentThread();
        if (!onContentCaptureThread) {
            mWrongThreadCount.incrementAndGet();
            Log.e(TAG, "MainContentCaptureSession running on " + Thread.currentThread());
        }
    }

    /** Reports number of times running on the wrong thread. */
    private void reportWrongThreadMetric() {
        Counter.logIncrement(
                CONTENT_CAPTURE_WRONG_THREAD_METRIC_ID, mWrongThreadCount.getAndSet(0));
    }

    /**
     * Ensures that {@code r} will be running on the assigned thread.
     *
+7 −0
Original line number Diff line number Diff line
@@ -7,6 +7,13 @@ flag {
  bug: "232195501"
}

flag {
  name: "edge_to_edge_by_default"
  namespace: "windowing_frontend"
  description: "Make app go edge-to-edge by default when targeting SDK 35 or greater"
  bug: "309578419"
}

flag {
    name: "defer_display_updates"
    namespace: "window_manager"
+12 −2
Original line number Diff line number Diff line
@@ -175,6 +175,14 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
    private static final long NAV_BAR_COLOR_DEFAULT_TRANSPARENT = 232195501L;

    /**
     * Make app go edge-to-edge by default if the target SDK is
     * {@link Build.VERSION_CODES#VANILLA_ICE_CREAM} or above.
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
    private static final long EDGE_TO_EDGE_BY_DEFAULT = 309578419;

    private static final int CUSTOM_TITLE_COMPATIBLE_FEATURES = DEFAULT_FEATURES |
            (1 << FEATURE_CUSTOM_TITLE) |
            (1 << FEATURE_CONTENT_TRANSITIONS) |
@@ -387,7 +395,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        mAllowFloatingWindowsFillScreen = context.getResources().getBoolean(
                com.android.internal.R.bool.config_allowFloatingWindowsFillScreen);
        mDefaultEdgeToEdge =
                context.getApplicationInfo().targetSdkVersion >= DEFAULT_EDGE_TO_EDGE_SDK_VERSION;
                context.getApplicationInfo().targetSdkVersion >= DEFAULT_EDGE_TO_EDGE_SDK_VERSION
                        || (CompatChanges.isChangeEnabled(EDGE_TO_EDGE_BY_DEFAULT)
                                && Flags.edgeToEdgeByDefault());
        if (mDefaultEdgeToEdge) {
            mDecorFitsSystemWindows = false;
        }
@@ -2558,11 +2568,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {

            mNavigationBarColor =
                    navBarColor == navBarDefaultColor
                            && !mDefaultEdgeToEdge
                            && !(CompatChanges.isChangeEnabled(NAV_BAR_COLOR_DEFAULT_TRANSPARENT)
                                    && Flags.navBarTransparentByDefault())
                            && !context.getResources().getBoolean(
                                    R.bool.config_navBarDefaultTransparent)
                            && !mDefaultEdgeToEdge
                    ? navBarCompatibleColor
                    : navBarColor;

+52 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.media;
import static android.companion.virtual.VirtualDeviceParams.DEVICE_POLICY_DEFAULT;
import static android.companion.virtual.VirtualDeviceParams.POLICY_TYPE_AUDIO;
import static android.content.Context.DEVICE_ID_DEFAULT;
import static android.media.audio.Flags.autoPublicVolumeApiHardening;
import static android.media.audio.Flags.FLAG_FOCUS_FREEZE_TEST_API;

import android.Manifest;
@@ -49,6 +50,7 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.media.AudioAttributes.AttributeSystemUsage;
import android.media.CallbackUtil.ListenerInfo;
import android.media.audiopolicy.AudioPolicy;
@@ -901,6 +903,7 @@ public class AudioManager {
    @UnsupportedAppUsage
    public AudioManager(Context context) {
        setContext(context);
        initPlatform();
    }

    private Context getContext() {
@@ -914,6 +917,9 @@ public class AudioManager {
    }

    private void setContext(Context context) {
        if (context == null) {
            return;
        }
        mOriginalContextDeviceId = context.getDeviceId();
        mApplicationContext = context.getApplicationContext();
        if (mApplicationContext != null) {
@@ -1063,9 +1069,18 @@ public class AudioManager {
     * @see #isVolumeFixed()
     */
    public void adjustVolume(int direction, @PublicVolumeFlags int flags) {
        if (applyAutoHardening()) {
            final IAudioService service = getService();
            try {
                service.adjustVolume(direction, flags);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        } else {
            MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(getContext());
            helper.sendAdjustVolumeBy(USE_DEFAULT_STREAM_TYPE, direction, flags);
        }
    }

    /**
     * Adjusts the volume of the most relevant stream, or the given fallback
@@ -1093,9 +1108,18 @@ public class AudioManager {
     */
    public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType,
            @PublicVolumeFlags int flags) {
        if (applyAutoHardening()) {
            final IAudioService service = getService();
            try {
                service.adjustSuggestedStreamVolume(direction, suggestedStreamType, flags);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        } else {
            MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(getContext());
            helper.sendAdjustVolumeBy(suggestedStreamType, direction, flags);
        }
    }

    /** @hide */
    @UnsupportedAppUsage
@@ -9969,6 +9993,30 @@ public class AudioManager {
        }
    }

    //====================================================================
    // Flag related utilities

    private boolean mIsAutomotive = false;

    private void initPlatform() {
        try {
            final Context context = getContext();
            if (context != null) {
                mIsAutomotive = context.getPackageManager()
                        .hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE);
            }
        } catch (Exception e) {
            Log.e(TAG, "Error querying system feature for AUTOMOTIVE", e);
        }
    }

    private boolean applyAutoHardening() {
        if (mIsAutomotive && autoPublicVolumeApiHardening()) {
            return true;
        }
        return false;
    }

    //---------------------------------------------------------
    // Inner classes
    //--------------------
Loading