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

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

Merge changes I53b9dab1,If8a33073

* changes:
  Make mock tasks work again.
  Fixing layout issue causing overlay to sometimes not appear.
parents 3ea9b72a 6e6bd877
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -26,10 +26,6 @@ import com.android.systemui.tuner.TunerService;
 */
public class RecentsDebugFlags implements TunerService.Tunable {

    private static final String KEY_FAST_TOGGLE = "overview_fast_toggle_via_button";
    private static final String KEY_FAST_TOGGLE_INDICATOR = "overview_fast_toggle_indicator";
    private static final String KEY_INITIAL_STATE_PAGING = "overview_initial_state_paging";

    public static class Static {
        // Enables debug drawing for the transition thumbnail
        public static final boolean EnableTransitionThumbnailDebugMode = false;
@@ -39,18 +35,23 @@ public class RecentsDebugFlags implements TunerService.Tunable {
        public static final boolean DisableBackgroundCache = false;
        // Enables the task affiliations
        public static final boolean EnableAffiliatedTaskGroups = true;
        // Enables the simulated task affiliations
        public static final boolean EnableSimulatedTaskGroups = false;
        // Defines the number of mock task affiliations per group
        public static final int TaskAffiliationsGroupCount = 12;

        // Enables us to create mock recents tasks
        public static final boolean EnableSystemServicesProxy = false;
        public static final boolean EnableMockTasks = false;
        // Defines the number of mock recents packages to create
        public static final int SystemServicesProxyMockPackageCount = 3;
        public static final int MockTasksPackageCount = 3;
        // Defines the number of mock recents tasks to create
        public static final int SystemServicesProxyMockTaskCount = 100;
        public static final int MockTaskCount = 100;
        // Enables the simulated task affiliations
        public static final boolean EnableMockTaskGroups = false;
        // Defines the number of mock task affiliations per group
        public static final int MockTaskGroupsTaskCount = 12;
    }

    private static final String KEY_FAST_TOGGLE = "overview_fast_toggle_via_button";
    private static final String KEY_FAST_TOGGLE_INDICATOR = "overview_fast_toggle_indicator";
    private static final String KEY_INITIAL_STATE_PAGING = "overview_initial_state_paging";

    private boolean mFastToggleRecents;
    private boolean mFastToggleIndicator;
    private boolean mInitialStatePaging;
+21 −16
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ public class SystemServicesProxy {
        // Resolve the assist intent
        mAssistComponent = mAssistUtils.getAssistComponentForUser(UserHandle.myUserId());

        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) {
        if (RecentsDebugFlags.Static.EnableMockTasks) {
            // Create a dummy icon
            mDummyIcon = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
            mDummyIcon.eraseColor(0xFF999999);
@@ -164,20 +164,20 @@ public class SystemServicesProxy {
        if (mAm == null) return null;

        // If we are mocking, then create some recent tasks
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) {
        if (RecentsDebugFlags.Static.EnableMockTasks) {
            ArrayList<ActivityManager.RecentTaskInfo> tasks =
                    new ArrayList<ActivityManager.RecentTaskInfo>();
            int count = Math.min(numLatestTasks, RecentsDebugFlags.Static.SystemServicesProxyMockTaskCount);
            int count = Math.min(numLatestTasks, RecentsDebugFlags.Static.MockTaskCount);
            for (int i = 0; i < count; i++) {
                // Create a dummy component name
                int packageIndex = i % RecentsDebugFlags.Static.SystemServicesProxyMockPackageCount;
                int packageIndex = i % RecentsDebugFlags.Static.MockTasksPackageCount;
                ComponentName cn = new ComponentName("com.android.test" + packageIndex,
                        "com.android.test" + i + ".Activity");
                String description = "" + i + " - " +
                        Long.toString(Math.abs(new Random().nextLong()), 36);
                // Create the recent task info
                ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo();
                rti.id = rti.persistentId = i;
                rti.id = rti.persistentId = rti.affiliatedTaskId = i;
                rti.baseIntent = new Intent();
                rti.baseIntent.setComponent(cn);
                rti.description = description;
@@ -418,7 +418,7 @@ public class SystemServicesProxy {
        if (mAm == null) return null;

        // If we are mocking, then just return a dummy thumbnail
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) {
        if (RecentsDebugFlags.Static.EnableMockTasks) {
            Bitmap thumbnail = Bitmap.createBitmap(mDummyThumbnailWidth, mDummyThumbnailHeight,
                    Bitmap.Config.ARGB_8888);
            thumbnail.eraseColor(0xff333333);
@@ -484,7 +484,7 @@ public class SystemServicesProxy {
    /** Moves a task to the front with the specified activity options. */
    public void moveTaskToFront(int taskId, ActivityOptions opts) {
        if (mAm == null) return;
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) return;
        if (RecentsDebugFlags.Static.EnableMockTasks) return;

        if (opts != null) {
            mAm.moveTaskToFront(taskId, ActivityManager.MOVE_TASK_WITH_HOME,
@@ -497,7 +497,7 @@ public class SystemServicesProxy {
    /** Removes the task */
    public void removeTask(final int taskId) {
        if (mAm == null) return;
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) return;
        if (RecentsDebugFlags.Static.EnableMockTasks) return;

        // Remove the task.
        BackgroundThread.getHandler().post(new Runnable() {
@@ -528,7 +528,7 @@ public class SystemServicesProxy {
     */
    public ActivityInfo getActivityInfo(ComponentName cn, int userId) {
        if (mIpm == null) return null;
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) return new ActivityInfo();
        if (RecentsDebugFlags.Static.EnableMockTasks) return new ActivityInfo();

        try {
            return mIpm.getActivityInfo(cn, PackageManager.GET_META_DATA, userId);
@@ -545,7 +545,7 @@ public class SystemServicesProxy {
     */
    public ActivityInfo getActivityInfo(ComponentName cn) {
        if (mPm == null) return null;
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) return new ActivityInfo();
        if (RecentsDebugFlags.Static.EnableMockTasks) return new ActivityInfo();

        try {
            return mPm.getActivityInfo(cn, PackageManager.GET_META_DATA);
@@ -562,7 +562,7 @@ public class SystemServicesProxy {
        if (mPm == null) return null;

        // If we are mocking, then return a mock label
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) {
        if (RecentsDebugFlags.Static.EnableMockTasks) {
            return "Recent Task: " + userId;
        }

@@ -576,7 +576,7 @@ public class SystemServicesProxy {
        if (mPm == null) return null;

        // If we are mocking, then return a mock label
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) {
        if (RecentsDebugFlags.Static.EnableMockTasks) {
            return "Recent Task App: " + userId;
        }

@@ -588,6 +588,11 @@ public class SystemServicesProxy {
     * description joins the app and activity labels.
     */
    public String getBadgedContentDescription(ActivityInfo info, int userId, Resources res) {
        // If we are mocking, then return a mock label
        if (RecentsDebugFlags.Static.EnableMockTasks) {
            return "Recent Task Content Description: " + userId;
        }

        String activityLabel = info.loadLabel(mPm).toString();
        String applicationLabel = info.applicationInfo.loadLabel(mPm).toString();
        String badgedApplicationLabel = getBadgedLabel(applicationLabel, userId);
@@ -604,7 +609,7 @@ public class SystemServicesProxy {
        if (mPm == null) return null;

        // If we are mocking, then return a mock label
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) {
        if (RecentsDebugFlags.Static.EnableMockTasks) {
            return new ColorDrawable(0xFF666666);
        }

@@ -620,7 +625,7 @@ public class SystemServicesProxy {
        if (mPm == null) return null;

        // If we are mocking, then return a mock label
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) {
        if (RecentsDebugFlags.Static.EnableMockTasks) {
            return new ColorDrawable(0xFF666666);
        }

@@ -635,7 +640,7 @@ public class SystemServicesProxy {
            int userId, Resources res) {

        // If we are mocking, then return a mock label
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) {
        if (RecentsDebugFlags.Static.EnableMockTasks) {
            return new ColorDrawable(0xFF666666);
        }

@@ -673,7 +678,7 @@ public class SystemServicesProxy {
    /** Returns the package name of the home activity. */
    public String getHomeActivityPackageName() {
        if (mPm == null) return null;
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) return null;
        if (RecentsDebugFlags.Static.EnableMockTasks) return null;

        ArrayList<ResolveInfo> homeActivities = new ArrayList<>();
        ComponentName defaultHomeActivity = mPm.getHomeActivities(homeActivities);
+5 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Debug;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.ArraySet;
@@ -31,6 +32,7 @@ import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.RecentsDebugFlags;
import com.android.systemui.recents.misc.SystemServicesProxy;

import java.util.ArrayList;
@@ -130,6 +132,9 @@ public class RecentsTaskLoadPlan {
                R.string.accessibility_recents_item_will_be_dismissed);
        long lastStackActiveTime = Prefs.getLong(mContext,
                Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, 0);
        if (RecentsDebugFlags.Static.EnableMockTasks) {
            lastStackActiveTime = 0;
        }
        long newLastStackActiveTime = -1;
        int taskCount = mRawTasks.size();
        for (int i = 0; i < taskCount; i++) {
+3 −3
Original line number Diff line number Diff line
@@ -776,7 +776,7 @@ public class TaskStack {
     * Temporary: This method will simulate affiliation groups by
     */
    public void createAffiliatedGroupings(Context context) {
        if (RecentsDebugFlags.Static.EnableSimulatedTaskGroups) {
        if (RecentsDebugFlags.Static.EnableMockTaskGroups) {
            ArrayMap<Task.TaskKey, Task> taskMap = new ArrayMap<>();
            // Sort all tasks by increasing firstActiveTime of the task
            ArrayList<Task> tasks = mStackTaskList.getTasks();
@@ -792,7 +792,7 @@ public class TaskStack {
            String prevPackage = "";
            int prevAffiliation = -1;
            Random r = new Random();
            int groupCountDown = RecentsDebugFlags.Static.TaskAffiliationsGroupCount;
            int groupCountDown = RecentsDebugFlags.Static.MockTaskGroupsTaskCount;
            for (int i = 0; i < taskCount; i++) {
                Task t = tasks.get(i);
                String packageName = t.key.getComponent().getPackageName();
@@ -807,7 +807,7 @@ public class TaskStack {
                    addGroup(group);
                    prevAffiliation = affiliation;
                    prevPackage = packageName;
                    groupCountDown = RecentsDebugFlags.Static.TaskAffiliationsGroupCount;
                    groupCountDown = RecentsDebugFlags.Static.MockTaskGroupsTaskCount;
                }
                group.addTask(t);
                taskMap.put(t.key, t);
+93 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.recents.views;

import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.FrameLayout;

/**
 * This is an optimized FrameLayout whose layout is completely directed by its parent, and as a
 * result, does not propagate <code>requestLayout()</code> up the view hierarchy. Instead, it will
 * relayout its children with the last known layout bounds when a layout is requested from a child
 * view.
 */
public class FixedSizeFrameLayout extends FrameLayout {

    private final Rect mLayoutBounds = new Rect();

    public FixedSizeFrameLayout(Context context) {
        super(context);
    }

    public FixedSizeFrameLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public FixedSizeFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public FixedSizeFrameLayout(Context context, AttributeSet attrs, int defStyleAttr,
            int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    protected final void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        measureContents(MeasureSpec.getSize(widthMeasureSpec),
                MeasureSpec.getSize(heightMeasureSpec));
    }

    @Override
    protected final void onLayout(boolean changed, int left, int top, int right, int bottom) {
        mLayoutBounds.set(left, top, right, bottom);
        layoutContents(mLayoutBounds, changed);
    }

    @Override
    public final void requestLayout() {
        // The base ViewGroup constructor attempts to call requestLayout() before this class's
        // members are initialized so we should just propagate in that case
        if (mLayoutBounds == null || mLayoutBounds.isEmpty()) {
            super.requestLayout();
        } else {
            // If we are already laid out, then just reuse the same bounds to layout the children
            // (but not itself)
            // TODO: Investigate whether we should coalesce these to the next frame if needed
            measureContents(getMeasuredWidth(), getMeasuredHeight());
            layoutContents(mLayoutBounds, false);
        }
    }

    /**
     * Measures the contents of this fixed layout.
     */
    protected void measureContents(int width, int height) {
        super.onMeasure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST),
                MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
    }

    /**
     * Lays out the contents of this fixed layout.
     */
    protected void layoutContents(Rect bounds, boolean changed) {
        super.onLayout(changed, bounds.left, bounds.top, bounds.right, bounds.bottom);
    }

}
Loading