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

Commit 7a2a0390 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Migrate screen rotation latency tracker with shell transition" into...

Merge "Migrate screen rotation latency tracker with shell transition" into sc-v2-dev am: a18b8a82 am: 672bcfb0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16017068

Change-Id: I93ebd8401de45b3cacf19d301dff50782982d421
parents c5cbe402 672bcfb0
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();
}
+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();
    }

+2 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Transformation;
import android.window.TransitionInfo;
import android.window.TransitionMetrics;
import android.window.TransitionRequestInfo;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;
@@ -362,6 +363,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
            }
        }
        startTransaction.apply();
        TransitionMetrics.getInstance().reportAnimationStart(transition);
        // run finish now in-case there are no animations
        onAnimFinish.run();
        return true;
Loading