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

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

Snap for 8316345 from 2a54e74e to sc-qpr3-release

Change-Id: I36b66c7d313c6dafdc9028ab768d292834ebb28f
parents 80afa4ab 2a54e74e
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -64,8 +64,6 @@ cc_binary {
        "libwilhelm",
    ],

    header_libs: ["bionic_libc_platform_headers"],

    compile_multilib: "both",

    cflags: [
+0 −5
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@

#include <android-base/macros.h>
#include <binder/IPCThreadState.h>
#include <bionic/pac.h>
#include <hwbinder/IPCThreadState.h>
#include <utils/Log.h>
#include <cutils/memory.h>
@@ -183,10 +182,6 @@ int main(int argc, char* const argv[])
      ALOGV("app_process main with argv: %s", argv_String.string());
    }

    // Because of applications that are using PAC instructions incorrectly, PAC
    // is disabled in application processes for now.
    ScopedDisablePAC x;

    AppRuntime runtime(argv[0], computeArgBlockSize(argc, argv));
    // Process command line arguments
    // ignore argv[0]
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ public class TimingsTraceLog {
     * Logs a duration so it can be parsed by external tools for performance reporting.
     */
    public void logDuration(String name, long timeMs) {
        Slog.d(mTag, name + " took to complete: " + timeMs + "ms");
        Slog.v(mTag, name + " took to complete: " + timeMs + "ms");
    }

    /**
+7 −7
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ public class TimingsTraceLogTest {
    public void testLogDuration() throws Exception {
        TimingsTraceLog log = new TimingsTraceLog(TAG, TRACE_TAG_APP, 10);
        log.logDuration("logro", 42);
        verify((MockedVoidMethod) () -> Slog.d(eq(TAG), contains("logro took to complete: 42ms")));
        verify((MockedVoidMethod) () -> Slog.v(eq(TAG), contains("logro took to complete: 42ms")));
    }

    @Test
@@ -134,7 +134,7 @@ public class TimingsTraceLogTest {

        verify((MockedVoidMethod) () -> Trace.traceBegin(TRACE_TAG_APP, "test"));
        verify((MockedVoidMethod) () -> Trace.traceEnd(TRACE_TAG_APP));
        verify((MockedVoidMethod) () -> Slog.d(eq(TAG), matches("test took to complete: \\dms")));
        verify((MockedVoidMethod) () -> Slog.v(eq(TAG), matches("test took to complete: \\dms")));
    }

    @Test
@@ -149,8 +149,8 @@ public class TimingsTraceLogTest {
        verify((MockedVoidMethod) () -> Trace.traceBegin(TRACE_TAG_APP, "L2"));
        verify((MockedVoidMethod) () -> Trace.traceEnd(TRACE_TAG_APP), times(2)); // L1 and L2

        verify((MockedVoidMethod) () -> Slog.d(eq(TAG), matches("L2 took to complete: \\d+ms")));
        verify((MockedVoidMethod) () -> Slog.d(eq(TAG), matches("L1 took to complete: \\d+ms")));
        verify((MockedVoidMethod) () -> Slog.v(eq(TAG), matches("L2 took to complete: \\d+ms")));
        verify((MockedVoidMethod) () -> Slog.v(eq(TAG), matches("L1 took to complete: \\d+ms")));
    }

    @Test
@@ -170,9 +170,9 @@ public class TimingsTraceLogTest {
        verify((MockedVoidMethod) () -> Trace.traceBegin(TRACE_TAG_APP, "L3"));
        verify((MockedVoidMethod) () -> Trace.traceEnd(TRACE_TAG_APP), times(3));

        verify((MockedVoidMethod) () -> Slog.d(eq(TAG), matches("L2 took to complete: \\d+ms")));
        verify((MockedVoidMethod) () -> Slog.d(eq(TAG), matches("L1 took to complete: \\d+ms")));
        verify((MockedVoidMethod) () -> Slog.d(eq(TAG), matches("L3 took to complete: \\d+ms")),
        verify((MockedVoidMethod) () -> Slog.v(eq(TAG), matches("L2 took to complete: \\d+ms")));
        verify((MockedVoidMethod) () -> Slog.v(eq(TAG), matches("L1 took to complete: \\d+ms")));
        verify((MockedVoidMethod) () -> Slog.v(eq(TAG), matches("L3 took to complete: \\d+ms")),
                never());

        verify((MockedVoidMethod) () -> Slog.w(TAG, "not tracing duration of 'L3' "
+73 −9
Original line number Diff line number Diff line
@@ -806,8 +806,8 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen

            if (shouldExpand(null, intent, getSplitRules())) {
                setLaunchingInExpandedContainer(launchingActivity, options);
            } else if (!setLaunchingToSideContainer(launchingActivity, intent, options)) {
                setLaunchingInSameContainer(launchingActivity, intent, options);
            } else if (!splitWithLaunchingActivity(launchingActivity, intent, options)) {
                setLaunchingInSameSideContainer(launchingActivity, intent, options);
            }

            return super.onStartActivity(who, intent, options);
@@ -826,9 +826,9 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
        /**
         * Returns {@code true} if the activity that is going to be started via the
         * {@code intent} should be paired with the {@code launchingActivity} and is set to be
         * launched in an empty side container.
         * launched in the side container.
         */
        private boolean setLaunchingToSideContainer(Activity launchingActivity, Intent intent,
        private boolean splitWithLaunchingActivity(Activity launchingActivity, Intent intent,
                Bundle options) {
            final SplitPairRule splitPairRule = getSplitRule(launchingActivity, intent,
                    getSplitRules());
@@ -836,9 +836,14 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
                return false;
            }

            // Create a new split with an empty side container
            final TaskFragmentContainer secondaryContainer = mPresenter
            // Check if there is any existing side container to launch into.
            TaskFragmentContainer secondaryContainer = findSideContainerForNewLaunch(
                    launchingActivity, splitPairRule);
            if (secondaryContainer == null) {
                // Create a new split with an empty side container.
                secondaryContainer = mPresenter
                        .createNewSplitWithEmptySideContainer(launchingActivity, splitPairRule);
            }

            // Amend the request to let the WM know that the activity should be placed in the
            // dedicated container.
@@ -847,13 +852,40 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
            return true;
        }

        /**
         * Finds if there is an existing split side {@link TaskFragmentContainer} that can be used
         * for the new rule.
         */
        @Nullable
        private TaskFragmentContainer findSideContainerForNewLaunch(Activity launchingActivity,
                SplitPairRule splitPairRule) {
            final TaskFragmentContainer launchingContainer = getContainerWithActivity(
                    launchingActivity.getActivityToken());
            if (launchingContainer == null) {
                return null;
            }

            // We only check if the launching activity is the primary of the split. We will check
            // if the launching activity is the secondary in #setLaunchingInSameSideContainer.
            final SplitContainer splitContainer = getActiveSplitForContainer(launchingContainer);
            if (splitContainer == null
                    || splitContainer.getPrimaryContainer() != launchingContainer) {
                return null;
            }

            if (canReuseContainer(splitPairRule, splitContainer.getSplitRule())) {
                return splitContainer.getSecondaryContainer();
            }
            return null;
        }

        /**
         * Checks if the activity that is going to be started via the {@code intent} should be
         * paired with the existing top activity which is currently paired with the
         * {@code launchingActivity}. If so, set the activity to be launched in the same
         * {@code launchingActivity}. If so, set the activity to be launched in the same side
         * container of the {@code launchingActivity}.
         */
        private void setLaunchingInSameContainer(Activity launchingActivity, Intent intent,
        private void setLaunchingInSameSideContainer(Activity launchingActivity, Intent intent,
                Bundle options) {
            final TaskFragmentContainer launchingContainer = getContainerWithActivity(
                    launchingActivity.getActivityToken());
@@ -884,6 +916,11 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
                return;
            }

            // Can only launch in the same container if the rules share the same presentation.
            if (!canReuseContainer(splitPairRule, splitContainer.getSplitRule())) {
                return;
            }

            // Amend the request to let the WM know that the activity should be placed in the
            // dedicated container. This is necessary for the case that the activity is started
            // into a new Task, or new Task will be escaped from the current host Task and be
@@ -900,4 +937,31 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
    public boolean isActivityEmbedded(@NonNull Activity activity) {
        return mPresenter.isActivityEmbedded(activity.getActivityToken());
    }

    /**
     * If the two rules have the same presentation, we can reuse the same {@link SplitContainer} if
     * there is any.
     */
    private static boolean canReuseContainer(SplitRule rule1, SplitRule rule2) {
        if (!isContainerReusableRule(rule1) || !isContainerReusableRule(rule2)) {
            return false;
        }
        return rule1.getSplitRatio() == rule2.getSplitRatio()
                && rule1.getLayoutDirection() == rule2.getLayoutDirection();
    }

    /**
     * Whether it is ok for other rule to reuse the {@link TaskFragmentContainer} of the given
     * rule.
     */
    private static boolean isContainerReusableRule(SplitRule rule) {
        // We don't expect to reuse the placeholder rule.
        if (!(rule instanceof SplitPairRule)) {
            return false;
        }
        final SplitPairRule pairRule = (SplitPairRule) rule;

        // Not reuse if it needs to destroy the existing.
        return !pairRule.shouldClearTop();
    }
}
Loading