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

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

Snap for 9348344 from 17fc0194 to tm-qpr2-release

Change-Id: I5f50021da5d1d42acd6de413a543ca6330f13fb1
parents e3c95be5 17fc0194
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ import android.location.CountryDetector;
import android.location.ICountryDetector;
import android.location.ILocationManager;
import android.location.LocationManager;
import android.media.AudioDeviceVolumeManager;
import android.media.AudioManager;
import android.media.MediaFrameworkInitializer;
import android.media.MediaFrameworkPlatformInitializer;
@@ -339,6 +340,13 @@ public final class SystemServiceRegistry {
                return new AudioManager(ctx);
            }});

        registerService(Context.AUDIO_DEVICE_VOLUME_SERVICE, AudioDeviceVolumeManager.class,
                new CachedServiceFetcher<AudioDeviceVolumeManager>() {
            @Override
            public AudioDeviceVolumeManager createService(ContextImpl ctx) {
                return new AudioDeviceVolumeManager(ctx);
            }});

        registerService(Context.MEDIA_ROUTER_SERVICE, MediaRouter.class,
                new CachedServiceFetcher<MediaRouter>() {
            @Override
+12 −0
Original line number Diff line number Diff line
@@ -3846,6 +3846,7 @@ public abstract class Context {
            WIFI_RTT_RANGING_SERVICE,
            NSD_SERVICE,
            AUDIO_SERVICE,
            AUDIO_DEVICE_VOLUME_SERVICE,
            AUTH_SERVICE,
            FINGERPRINT_SERVICE,
            //@hide: FACE_SERVICE,
@@ -4686,6 +4687,17 @@ public abstract class Context {
     */
    public static final String AUDIO_SERVICE = "audio";

    /**
     * @hide
     * Use with {@link #getSystemService(String)} to retrieve a
     * {@link android.media.AudioDeviceVolumeManager} for handling management of audio device
     * (e.g. speaker, USB headset) volume.
     *
     * @see #getSystemService(String)
     * @see android.media.AudioDeviceVolumeManager
     */
    public static final String AUDIO_DEVICE_VOLUME_SERVICE = "audio_device_volume";

    /**
     * Use with {@link #getSystemService(String)} to retrieve a {@link
     * android.media.MediaTranscodingManager} for transcoding media.
+68 −0
Original line number Diff line number Diff line
@@ -414,6 +414,53 @@ public final class TransitionInfo implements Parcelable {
        return false;
    }

    /**
     * Releases temporary-for-animation surfaces referenced by this to potentially free up memory.
     * This includes root-leash and snapshots.
     */
    public void releaseAnimSurfaces() {
        for (int i = mChanges.size() - 1; i >= 0; --i) {
            final Change c = mChanges.get(i);
            if (c.mSnapshot != null) {
                c.mSnapshot.release();
                c.mSnapshot = null;
            }
        }
        if (mRootLeash != null) {
            mRootLeash.release();
        }
    }

    /**
     * Releases ALL the surfaces referenced by this to potentially free up memory. Do NOT use this
     * if the surface-controls get stored and used elsewhere in the process. To just release
     * temporary-for-animation surfaces, use {@link #releaseAnimSurfaces}.
     */
    public void releaseAllSurfaces() {
        releaseAnimSurfaces();
        for (int i = mChanges.size() - 1; i >= 0; --i) {
            mChanges.get(i).getLeash().release();
        }
    }

    /**
     * Makes a copy of this as if it were parcel'd and unparcel'd. This implies that surfacecontrol
     * refcounts are incremented which allows the "remote" receiver to release them without breaking
     * the caller's references. Use this only if you need to "send" this to a local function which
     * assumes it is being called from a remote caller.
     */
    public TransitionInfo localRemoteCopy() {
        final TransitionInfo out = new TransitionInfo(mType, mFlags);
        for (int i = 0; i < mChanges.size(); ++i) {
            out.mChanges.add(mChanges.get(i).localRemoteCopy());
        }
        out.mRootLeash = mRootLeash != null ? new SurfaceControl(mRootLeash, "localRemote") : null;
        // Doesn't have any native stuff, so no need for actual copy
        out.mOptions = mOptions;
        out.mRootOffset.set(mRootOffset);
        return out;
    }

    /** Represents the change a WindowContainer undergoes during a transition */
    public static final class Change implements Parcelable {
        private final WindowContainerToken mContainer;
@@ -466,6 +513,27 @@ public final class TransitionInfo implements Parcelable {
            mSnapshotLuma = in.readFloat();
        }

        private Change localRemoteCopy() {
            final Change out = new Change(mContainer, new SurfaceControl(mLeash, "localRemote"));
            out.mParent = mParent;
            out.mLastParent = mLastParent;
            out.mMode = mMode;
            out.mFlags = mFlags;
            out.mStartAbsBounds.set(mStartAbsBounds);
            out.mEndAbsBounds.set(mEndAbsBounds);
            out.mEndRelOffset.set(mEndRelOffset);
            out.mTaskInfo = mTaskInfo;
            out.mAllowEnterPip = mAllowEnterPip;
            out.mStartRotation = mStartRotation;
            out.mEndRotation = mEndRotation;
            out.mEndFixedRotation = mEndFixedRotation;
            out.mRotationAnimation = mRotationAnimation;
            out.mBackgroundColor = mBackgroundColor;
            out.mSnapshot = mSnapshot != null ? new SurfaceControl(mSnapshot, "localRemote") : null;
            out.mSnapshotLuma = mSnapshotLuma;
            return out;
        }

        /** Sets the parent of this change's container. The parent must be a participant or null. */
        public void setParent(@Nullable WindowContainerToken parent) {
            mParent = parent;
+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ public abstract class WindowProviderService extends Service implements WindowPro

    @SuppressLint("OnNameExpected")
    @Override
    public void onConfigurationChanged(@Nullable Configuration configuration) {
    public void onConfigurationChanged(@NonNull Configuration configuration) {
        // This is only called from WindowTokenClient.
        mCallbacksController.dispatchConfigurationChanged(configuration);
    }
+41 −5
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import android.graphics.Rect;
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Log;
import android.view.Choreographer;
import android.view.Display;
import android.view.Surface;
import android.view.SurfaceControl;
@@ -179,8 +180,10 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
                // This is necessary in case there was a resize animation ongoing when exit PIP
                // started, in which case the first resize will be skipped to let the exit
                // operation handle the final resize out of PIP mode. See b/185306679.
                finishResizeDelayedIfNeeded(() -> {
                    finishResize(tx, destinationBounds, direction, animationType);
                    sendOnPipTransitionFinished(direction);
                });
            }
        }

@@ -196,6 +199,39 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        }
    };

    /**
     * Finishes resizing the PiP, delaying the operation if it has to be synced with the PiP menu.
     *
     * This is done to avoid a race condition between the last transaction applied in
     * onPipAnimationUpdate and the finishResize in onPipAnimationEnd. The transaction in
     * onPipAnimationUpdate is applied directly from WmShell, while onPipAnimationEnd creates a
     * WindowContainerTransaction in finishResize, which is to be applied by WmCore later. Normally,
     * the WCT should be the last transaction to finish the animation. However, it  may happen that
     * it gets applied *before* the transaction created by the last onPipAnimationUpdate. This
     * happens only when the PiP surface transaction has to be synced with the PiP menu due to the
     * necessity for a delay when syncing the PiP surface animation with the PiP menu surface
     * animation and redrawing the PiP menu contents. As a result, the PiP surface gets scaled after
     * the new bounds are applied by WmCore, which makes the PiP surface have unexpected bounds.
     *
     * To avoid this, we delay the finishResize operation until
     * the next frame. This aligns the last onAnimationUpdate transaction with the WCT application.
     */
    private void finishResizeDelayedIfNeeded(Runnable finishResizeRunnable) {
        if (!shouldSyncPipTransactionWithMenu()) {
            finishResizeRunnable.run();
            return;
        }

        // Delay the finishResize to the next frame
        Choreographer.getInstance().postCallback(Choreographer.CALLBACK_COMMIT, () -> {
            mMainExecutor.execute(finishResizeRunnable);
        }, null);
    }

    private boolean shouldSyncPipTransactionWithMenu() {
        return mPipMenuController.isMenuVisible();
    }

    @VisibleForTesting
    final PipTransitionController.PipTransitionCallback mPipTransitionCallback =
            new PipTransitionController.PipTransitionCallback() {
@@ -221,7 +257,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
                @Override
                public boolean handlePipTransaction(SurfaceControl leash,
                        SurfaceControl.Transaction tx, Rect destinationBounds) {
                    if (mPipMenuController.isMenuVisible()) {
                    if (shouldSyncPipTransactionWithMenu()) {
                        mPipMenuController.movePipMenu(leash, tx, destinationBounds);
                        return true;
                    }
@@ -1223,7 +1259,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        mSurfaceTransactionHelper
                .crop(tx, mLeash, toBounds)
                .round(tx, mLeash, mPipTransitionState.isInPip());
        if (mPipMenuController.isMenuVisible()) {
        if (shouldSyncPipTransactionWithMenu()) {
            mPipMenuController.resizePipMenu(mLeash, tx, toBounds);
        } else {
            tx.apply();
@@ -1265,7 +1301,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        mSurfaceTransactionHelper
                .scale(tx, mLeash, startBounds, toBounds, degrees)
                .round(tx, mLeash, startBounds, toBounds);
        if (mPipMenuController.isMenuVisible()) {
        if (shouldSyncPipTransactionWithMenu()) {
            mPipMenuController.movePipMenu(mLeash, tx, toBounds);
        } else {
            tx.apply();
Loading