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

Commit f26e393e authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Minor optimizations to task loading/screenshot"

parents d147307d 11f53e96
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ include $(BUILD_STATIC_JAVA_LIBRARY)

include $(CLEAR_VARS)

LOCAL_PACKAGE_NAME := SharedDummyLib
LOCAL_PACKAGE_NAME := SystemUISharedLib
LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_JAVA_LIBRARIES := SystemUISharedLib
+4 −5
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package com.android.systemui.shared.recents;

import android.graphics.Bitmap;
import android.graphics.Rect;
import com.android.systemui.shared.system.GraphicBufferCompat;

/**
 * Temporary callbacks into SystemUI.
@@ -25,9 +25,8 @@ import android.graphics.Rect;
interface ISystemUiProxy {

    /**
     * Proxies SurfaceControl.screenshot().
     * Proxies SurfaceControl.screenshotToBuffer().
     */
    Bitmap screenshot(in Rect sourceCrop, int width, int height,
                      int minLayer, int maxLayer, boolean useIdentityTransform,
                      int rotation);
    GraphicBufferCompat screenshot(in Rect sourceCrop, int width, int height, int minLayer,
            int maxLayer, boolean useIdentityTransform, int rotation);
}
+13 −4
Original line number Diff line number Diff line
@@ -45,6 +45,11 @@ import java.util.List;
 */
public class RecentsTaskLoadPlan {

    /** The set of conditions to preload tasks. */
    public static class PreloadOptions {
        public boolean loadTitles = true;
    }

    /** The set of conditions to load tasks. */
    public static class Options {
        public int runningTaskId = -1;
@@ -80,7 +85,8 @@ public class RecentsTaskLoadPlan {
     * Note: Do not lock, since this can be calling back to the loader, which separately also drives
     * this call (callers should synchronize on the loader before making this call).
     */
    public void preloadPlan(RecentsTaskLoader loader, int runningTaskId, int currentUserId) {
    public void preloadPlan(PreloadOptions opts, RecentsTaskLoader loader, int runningTaskId,
            int currentUserId) {
        Resources res = mContext.getResources();
        ArrayList<Task> allTasks = new ArrayList<>();
        if (mRawTasks == null) {
@@ -110,9 +116,12 @@ public class RecentsTaskLoadPlan {
            }

            // Load the title, icon, and color
            String title = loader.getAndUpdateActivityTitle(taskKey, t.taskDescription);
            String titleDescription = loader.getAndUpdateContentDescription(taskKey,
                    t.taskDescription);
            String title = opts.loadTitles
                    ? loader.getAndUpdateActivityTitle(taskKey, t.taskDescription)
                    : "";
            String titleDescription = opts.loadTitles
                    ? loader.getAndUpdateContentDescription(taskKey, t.taskDescription)
                    : "";
            Drawable icon = isStackTask
                    ? loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, res, false)
                    : null;
+2 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.util.LruCache;

import com.android.internal.annotations.GuardedBy;
import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan.Options;
import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan.PreloadOptions;
import com.android.systemui.shared.recents.model.Task.TaskKey;
import com.android.systemui.shared.recents.model.TaskKeyLruCache.EvictionCallback;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -155,7 +156,7 @@ public class RecentsTaskLoader {
            int currentUserId) {
        try {
            Trace.beginSection("preloadPlan");
            plan.preloadPlan(this, runningTaskId, currentUserId);
            plan.preloadPlan(new PreloadOptions(), this, runningTaskId, currentUserId);
        } finally {
            Trace.endSection();
        }
+73 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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 com.android.systemui.shared.recents.utilities;

import static android.os.Trace.TRACE_TAG_APP;

/**
 * Helper class for internal trace functions.
 */
public class AppTrace {

    /**
     * Begins a new async trace section with the given {@param key} and {@param cookie}.
     */
    public static void start(String key, int cookie) {
        android.os.Trace.asyncTraceBegin(TRACE_TAG_APP, key, cookie);
    }

    /**
     * Begins a new async trace section with the given {@param key}.
     */
    public static void start(String key) {
        android.os.Trace.asyncTraceBegin(TRACE_TAG_APP, key, 0);
    }

    /**
     * Ends an existing async trace section with the given {@param key}.
     */
    public static void end(String key) {
        android.os.Trace.asyncTraceEnd(TRACE_TAG_APP, key, 0);
    }

    /**
     * Ends an existing async trace section with the given {@param key} and {@param cookie}.
     */
    public static void end(String key, int cookie) {
        android.os.Trace.asyncTraceEnd(TRACE_TAG_APP, key, cookie);
    }

    /**
     * Begins a new trace section with the given {@param key}. Can be nested.
     */
    public static void beginSection(String key) {
        android.os.Trace.beginSection(key);
    }

    /**
     * Ends an existing trace section started in the last {@link #beginSection(String)}.
     */
    public static void endSection() {
        android.os.Trace.endSection();
    }

    /**
     * Traces a counter value.
     */
    public static void count(String name, int count) {
        android.os.Trace.traceCounter(TRACE_TAG_APP, name, count);
    }
}
Loading