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

Commit 8832611d authored by Winson Chung's avatar Winson Chung Committed by android-build-merger
Browse files

Merge "Exposing flickerlib classes and layer tracing to sysui" am: e25075b2

am: f19fcb50

Change-Id: I281764bab937ff4a71ed0572a648e4f08738a5d9
parents 382aaf00 f19fcb50
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -638,4 +638,14 @@ interface IWindowManager
     * native InputManager before proceeding with tests.
     * native InputManager before proceeding with tests.
     */
     */
    void syncInputTransactions();
    void syncInputTransactions();

    /**
     * Returns whether SurfaceFlinger layer tracing is enabled.
     */
    boolean isLayerTracing();

    /**
     * Enables/disables SurfaceFlinger layer tracing.
     */
    void setLayerTracing(boolean enabled);
}
}
+60 −0
Original line number Original line Diff line number Diff line
@@ -7806,4 +7806,64 @@ public class WindowManagerService extends IWindowManager.Stub
                    0 /* configChanges */, !PRESERVE_WINDOWS, true /* notifyClients */);
                    0 /* configChanges */, !PRESERVE_WINDOWS, true /* notifyClients */);
        }
        }
    }
    }

    /** Return whether layer tracing is enabled */
    public boolean isLayerTracing() {
        mAtmInternal.enforceCallerIsRecentsOrHasPermission(android.Manifest.permission.DUMP,
                "isLayerTracing");
        long token = Binder.clearCallingIdentity();
        try {
            Parcel data = null;
            Parcel reply = null;
            try {
                IBinder sf = ServiceManager.getService("SurfaceFlinger");
                if (sf != null) {
                    reply = Parcel.obtain();
                    data = Parcel.obtain();
                    data.writeInterfaceToken("android.ui.ISurfaceComposer");
                    sf.transact(/* LAYER_TRACE_STATUS_CODE */ 1026, data, reply, 0 /* flags */);
                    return reply.readBoolean();
                }
            } catch (RemoteException e) {
                Slog.e(TAG, "Failed to get layer tracing");
            } finally {
                if (data != null) {
                    data.recycle();
                }
                if (reply != null) {
                    reply.recycle();
                }
            }
        } finally {
            Binder.restoreCallingIdentity(token);
        }
        return false;
    }

    /** Enable or disable layer tracing */
    public void setLayerTracing(boolean enabled) {
        mAtmInternal.enforceCallerIsRecentsOrHasPermission(android.Manifest.permission.DUMP,
                "setLayerTracing");
        long token = Binder.clearCallingIdentity();
        try {
            Parcel data = null;
            try {
                IBinder sf = ServiceManager.getService("SurfaceFlinger");
                if (sf != null) {
                    data = Parcel.obtain();
                    data.writeInterfaceToken("android.ui.ISurfaceComposer");
                    data.writeInt(enabled ? 1 : 0);
                    sf.transact(/* LAYER_TRACE_CONTROL_CODE */ 1025, data, null, 0 /* flags */);
                }
            } catch (RemoteException e) {
                Slog.e(TAG, "Failed to set layer tracing");
            } finally {
                if (data != null) {
                    data.recycle();
                }
            }
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }
}
}
+14 −1
Original line number Original line Diff line number Diff line
@@ -29,11 +29,24 @@ java_test {
    ],
    ],
}
}


java_library {
    name: "flickerlib_without_helpers",
    platform_apis: true,
    srcs: ["src/**/*.java"],
    exclude_srcs: ["src/**/helpers/*.java"],
    static_libs: [
        "cts-wm-util",
        "platformprotosnano",
        "layersprotosnano",
        "truth-prebuilt"
    ],
}

java_library {
java_library {
    name: "flickerautomationhelperlib",
    name: "flickerautomationhelperlib",
    sdk_version: "test_current",
    sdk_version: "test_current",
    srcs: [
    srcs: [
        "src/com/android/server/wm/flicker/AutomationUtils.java",
        "src/com/android/server/wm/flicker/helpers/AutomationUtils.java",
        "src/com/android/server/wm/flicker/WindowUtils.java",
        "src/com/android/server/wm/flicker/WindowUtils.java",
    ],
    ],
    static_libs: [
    static_libs: [
+19 −19
Original line number Original line Diff line number Diff line
@@ -24,14 +24,14 @@ import java.util.function.Function;
 * results. Assertions are functions that are applied over a single trace entry and returns a
 * results. Assertions are functions that are applied over a single trace entry and returns a
 * result which includes a detailed reason if the assertion fails.
 * result which includes a detailed reason if the assertion fails.
 */
 */
class Assertions {
public class Assertions {
    /**
    /**
     * Checks assertion on a single trace entry.
     * Checks assertion on a single trace entry.
     *
     *
     * @param <T> trace entry type to perform the assertion on.
     * @param <T> trace entry type to perform the assertion on.
     */
     */
    @FunctionalInterface
    @FunctionalInterface
    interface TraceAssertion<T> extends Function<T, Result> {
    public interface TraceAssertion<T> extends Function<T, Result> {
        /**
        /**
         * Returns an assertion that represents the logical negation of this assertion.
         * Returns an assertion that represents the logical negation of this assertion.
         *
         *
@@ -46,7 +46,7 @@ class Assertions {
     * Checks assertion on a single layers trace entry.
     * Checks assertion on a single layers trace entry.
     */
     */
    @FunctionalInterface
    @FunctionalInterface
    interface LayersTraceAssertion extends TraceAssertion<LayersTrace.Entry> {
    public interface LayersTraceAssertion extends TraceAssertion<LayersTrace.Entry> {


    }
    }


@@ -54,11 +54,11 @@ class Assertions {
     * Utility class to store assertions with an identifier to help generate more useful debug
     * Utility class to store assertions with an identifier to help generate more useful debug
     * data when dealing with multiple assertions.
     * data when dealing with multiple assertions.
     */
     */
    static class NamedAssertion<T> {
    public static class NamedAssertion<T> {
        final TraceAssertion<T> assertion;
        public final TraceAssertion<T> assertion;
        final String name;
        public final String name;


        NamedAssertion(TraceAssertion<T> assertion, String name) {
        public NamedAssertion(TraceAssertion<T> assertion, String name) {
            this.assertion = assertion;
            this.assertion = assertion;
            this.name = name;
            this.name = name;
        }
        }
@@ -67,21 +67,21 @@ class Assertions {
    /**
    /**
     * Contains the result of an assertion including the reason for failed assertions.
     * Contains the result of an assertion including the reason for failed assertions.
     */
     */
    static class Result {
    public static class Result {
        static final String NEGATION_PREFIX = "!";
        public static final String NEGATION_PREFIX = "!";
        final boolean success;
        public final boolean success;
        final long timestamp;
        public final long timestamp;
        final String assertionName;
        public final String assertionName;
        final String reason;
        public final String reason;


        Result(boolean success, long timestamp, String assertionName, String reason) {
        public Result(boolean success, long timestamp, String assertionName, String reason) {
            this.success = success;
            this.success = success;
            this.timestamp = timestamp;
            this.timestamp = timestamp;
            this.assertionName = assertionName;
            this.assertionName = assertionName;
            this.reason = reason;
            this.reason = reason;
        }
        }


        Result(boolean success, String reason) {
        public Result(boolean success, String reason) {
            this.success = success;
            this.success = success;
            this.reason = reason;
            this.reason = reason;
            this.assertionName = "";
            this.assertionName = "";
@@ -91,7 +91,7 @@ class Assertions {
        /**
        /**
         * Returns the negated {@code Result} and adds a negation prefix to the assertion name.
         * Returns the negated {@code Result} and adds a negation prefix to the assertion name.
         */
         */
        Result negate() {
        public Result negate() {
            String negatedAssertionName;
            String negatedAssertionName;
            if (this.assertionName.startsWith(NEGATION_PREFIX)) {
            if (this.assertionName.startsWith(NEGATION_PREFIX)) {
                negatedAssertionName = this.assertionName.substring(NEGATION_PREFIX.length() + 1);
                negatedAssertionName = this.assertionName.substring(NEGATION_PREFIX.length() + 1);
@@ -101,11 +101,11 @@ class Assertions {
            return new Result(!this.success, this.timestamp, negatedAssertionName, this.reason);
            return new Result(!this.success, this.timestamp, negatedAssertionName, this.reason);
        }
        }


        boolean passed() {
        public boolean passed() {
            return this.success;
            return this.success;
        }
        }


        boolean failed() {
        public boolean failed() {
            return !this.success;
            return !this.success;
        }
        }


+3 −3
Original line number Original line Diff line number Diff line
@@ -38,11 +38,11 @@ public class AssertionsChecker<T extends ITraceEntry> {
    private AssertionOption mOption = AssertionOption.NONE;
    private AssertionOption mOption = AssertionOption.NONE;
    private List<NamedAssertion<T>> mAssertions = new LinkedList<>();
    private List<NamedAssertion<T>> mAssertions = new LinkedList<>();


    void add(Assertions.TraceAssertion<T> assertion, String name) {
    public void add(Assertions.TraceAssertion<T> assertion, String name) {
        mAssertions.add(new NamedAssertion<>(assertion, name));
        mAssertions.add(new NamedAssertion<>(assertion, name));
    }
    }


    void filterByRange(long startTime, long endTime) {
    public void filterByRange(long startTime, long endTime) {
        mFilterEntriesByRange = true;
        mFilterEntriesByRange = true;
        mFilterStartTime = startTime;
        mFilterStartTime = startTime;
        mFilterEndTime = endTime;
        mFilterEndTime = endTime;
@@ -75,7 +75,7 @@ public class AssertionsChecker<T extends ITraceEntry> {
     * @param entries list of entries to perform assertions on
     * @param entries list of entries to perform assertions on
     * @return list of failed assertion results
     * @return list of failed assertion results
     */
     */
    List<Result> test(List<T> entries) {
    public List<Result> test(List<T> entries) {
        List<T> filteredEntries;
        List<T> filteredEntries;
        List<Result> failures;
        List<Result> failures;


Loading