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

Commit a18b8a82 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Migrate screen rotation latency tracker with shell transition" into sc-v2-dev

parents e7129047 9cb2c662
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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 android.window;

import android.os.IBinder;

/**
 * Implemented by WM Core to know the metrics of transition that runs on a different process.
 * @hide
 */
oneway interface ITransitionMetricsReporter {

    /**
     * Called when the transition animation starts.
     *
     * @param startTime The time when the animation started.
     */
    void reportAnimationStart(IBinder transitionToken, long startTime);
}
+4 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.view.RemoteAnimationAdapter;
import android.window.IDisplayAreaOrganizerController;
import android.window.ITaskFragmentOrganizerController;
import android.window.ITaskOrganizerController;
import android.window.ITransitionMetricsReporter;
import android.window.ITransitionPlayer;
import android.window.IWindowContainerTransactionCallback;
import android.window.WindowContainerToken;
@@ -98,4 +99,7 @@ interface IWindowOrganizerController {
     * this will replace the existing one if set.
     */
    void registerTransitionPlayer(in ITransitionPlayer player);

    /** @return An interface enabling the transition players to report its metrics. */
    ITransitionMetricsReporter getTransitionMetricsReporter();
}
+2 −2
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ public final class TransitionInfo implements Parcelable {
    private TransitionInfo(Parcel in) {
        mType = in.readInt();
        mFlags = in.readInt();
        in.readList(mChanges, null /* classLoader */);
        in.readTypedList(mChanges, Change.CREATOR);
        mRootLeash = new SurfaceControl();
        mRootLeash.readFromParcel(in);
        mRootOffset.readFromParcel(in);
@@ -152,7 +152,7 @@ public final class TransitionInfo implements Parcelable {
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mType);
        dest.writeInt(mFlags);
        dest.writeList(mChanges);
        dest.writeTypedList(mChanges);
        mRootLeash.writeToParcel(dest, flags);
        mRootOffset.writeToParcel(dest, flags);
        dest.writeTypedObject(mOptions, flags);
+57 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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 android.window;

import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Singleton;

/**
 * A helper class for who plays transition animation can report its metrics easily.
 * @hide
 */
public class TransitionMetrics {

    private final ITransitionMetricsReporter mTransitionMetricsReporter;

    private TransitionMetrics(ITransitionMetricsReporter reporter) {
        mTransitionMetricsReporter = reporter;
    }

    /** Reports the current timestamp as when the transition animation starts. */
    public void reportAnimationStart(IBinder transitionToken) {
        try {
            mTransitionMetricsReporter.reportAnimationStart(transitionToken,
                    SystemClock.elapsedRealtime());
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    /** Gets the singleton instance of TransitionMetrics. */
    public static TransitionMetrics getInstance() {
        return sTransitionMetrics.get();
    }

    private static final Singleton<TransitionMetrics> sTransitionMetrics = new Singleton<>() {
        @Override
        protected TransitionMetrics create() {
            return new TransitionMetrics(WindowOrganizer.getTransitionMetricsReporter());
        }
    };
}
+13 −1
Original line number Diff line number Diff line
@@ -159,7 +159,19 @@ public class WindowOrganizer {
        }
    }

    IWindowOrganizerController getWindowOrganizerController() {
    /**
     * @see TransitionMetrics
     * @hide
     */
    public static ITransitionMetricsReporter getTransitionMetricsReporter() {
        try {
            return getWindowOrganizerController().getTransitionMetricsReporter();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    static IWindowOrganizerController getWindowOrganizerController() {
        return IWindowOrganizerControllerSingleton.get();
    }

Loading