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

Commit 11f53e96 authored by Winson Chung's avatar Winson Chung
Browse files

Minor optimizations to task loading/screenshot

- Pass graphic buffer instead of bitmap for current screenshot
- Add option to skip preloading titles
- Adding some more compat classes

Bug: 67510855
Test: Build quickstep

Change-Id: Idf4642683d3121e69f0854ac909a8c22c7238b9a
parent e254526f
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -30,7 +30,7 @@ include $(BUILD_STATIC_JAVA_LIBRARY)


include $(CLEAR_VARS)
include $(CLEAR_VARS)


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


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


package com.android.systemui.shared.recents;
package com.android.systemui.shared.recents;


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


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


    /**
    /**
     * Proxies SurfaceControl.screenshot().
     * Proxies SurfaceControl.screenshotToBuffer().
     */
     */
    Bitmap screenshot(in Rect sourceCrop, int width, int height,
    GraphicBufferCompat screenshot(in Rect sourceCrop, int width, int height, int minLayer,
                      int minLayer, int maxLayer, boolean useIdentityTransform,
            int maxLayer, boolean useIdentityTransform, int rotation);
                      int rotation);
}
}
+13 −4
Original line number Original line Diff line number Diff line
@@ -45,6 +45,11 @@ import java.util.List;
 */
 */
public class RecentsTaskLoadPlan {
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. */
    /** The set of conditions to load tasks. */
    public static class Options {
    public static class Options {
        public int runningTaskId = -1;
        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
     * 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).
     * 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();
        Resources res = mContext.getResources();
        ArrayList<Task> allTasks = new ArrayList<>();
        ArrayList<Task> allTasks = new ArrayList<>();
        if (mRawTasks == null) {
        if (mRawTasks == null) {
@@ -110,9 +116,12 @@ public class RecentsTaskLoadPlan {
            }
            }


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


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