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

Commit fb44d212 authored by Winson Chung's avatar Winson Chung
Browse files

3/Removing unnecessary filtering logic for recent tasks in SystemUI

- Remove all code related to last-stack-active-time, quiet profile task
  handling, and visible task range filtering
- Remove the notion of firstActiveTime since that was only used to filter
  tasks in SystemUI, also convert lastActiveTime to elapsed real time since
  it is only used in the system to order active tasks, and in SystemUI as
  a part of the TaskKey for caching purposes (it is no longer used to
  determine the last visible task based on time)

Bug: 34270611
Test: runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java
Change-Id: I44d494a521f60f302e0976fcf33490fe837f7cdb
parent d6aa3db6
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -16,13 +16,6 @@

package android.app;

import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;

import android.Manifest;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -1439,7 +1432,6 @@ public class ActivityManager {
            }
            dest.writeInt(stackId);
            dest.writeInt(userId);
            dest.writeLong(firstActiveTime);
            dest.writeLong(lastActiveTime);
            dest.writeInt(affiliatedTaskId);
            dest.writeInt(affiliatedTaskColor);
@@ -1468,7 +1460,6 @@ public class ActivityManager {
                    TaskDescription.CREATOR.createFromParcel(source) : null;
            stackId = source.readInt();
            userId = source.readInt();
            firstActiveTime = source.readLong();
            lastActiveTime = source.readLong();
            affiliatedTaskId = source.readInt();
            affiliatedTaskColor = source.readInt();
+0 −8
Original line number Diff line number Diff line
@@ -6791,14 +6791,6 @@ public final class Settings {
        public static final String LOCK_SCREEN_SHOW_NOTIFICATIONS =
                "lock_screen_show_notifications";

        /**
         * This preference stores the last stack active task time for each user, which affects what
         * tasks will be visible in Overview.
         * @hide
         */
        public static final String OVERVIEW_LAST_STACK_ACTIVE_TIME =
                "overview_last_stack_active_time";

        /**
         * List of TV inputs that are currently hidden. This is a string
         * containing the IDs of all hidden TV inputs. Each ID is encoded by
+0 −1
Original line number Diff line number Diff line
@@ -463,7 +463,6 @@ public class SettingsBackupTest {
                 Settings.Secure.NFC_PAYMENT_FOREGROUND,
                 Settings.Secure.NIGHT_DISPLAY_ACTIVATED,
                 Settings.Secure.NIGHT_DISPLAY_LAST_ACTIVATED_TIME,
                 Settings.Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME,
                 Settings.Secure.PACKAGE_VERIFIER_STATE,
                 Settings.Secure.PACKAGE_VERIFIER_USER_CONSENT,
                 Settings.Secure.PARENTAL_CONTROL_LAST_UPDATE,
+0 −40
Original line number Diff line number Diff line
@@ -188,41 +188,6 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
            } else if (action.equals(Intent.ACTION_USER_SWITCHED)) {
                // When switching users, dismiss Recents to Home similar to screen off
                finish();
            } else if (action.equals(Intent.ACTION_TIME_CHANGED)) {
                // If the time shifts but the currentTime >= lastStackActiveTime, then that boundary
                // is still valid.  Otherwise, we need to reset the lastStackactiveTime to the
                // currentTime and remove the old tasks in between which would not be previously
                // visible, but currently would be in the new currentTime
                int currentUser = SystemServicesProxy.getInstance(RecentsActivity.this)
                        .getCurrentUser();
                long oldLastStackActiveTime = Settings.Secure.getLongForUser(getContentResolver(),
                        Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, -1, currentUser);
                if (oldLastStackActiveTime != -1) {
                    long currentTime = System.currentTimeMillis();
                    if (currentTime < oldLastStackActiveTime) {
                        // We are only removing tasks that are between the new current time
                        // and the old last stack active time, they were not visible and in the
                        // TaskStack so we don't need to remove any associated TaskViews but we do
                        // need to load the task id's from the system
                        RecentsTaskLoader loader = Recents.getTaskLoader();
                        RecentsTaskLoadPlan loadPlan = loader.createLoadPlan(ctx);
                        loader.preloadRawTasks(loadPlan, false /* includeFrontMostExcludedTask */);
                        List<ActivityManager.RecentTaskInfo> tasks = loadPlan.getRawTasks();
                        for (int i = tasks.size() - 1; i >= 0; i--) {
                            ActivityManager.RecentTaskInfo task = tasks.get(i);
                            if (currentTime <= task.lastActiveTime && task.lastActiveTime <
                                    oldLastStackActiveTime) {
                                Recents.getSystemServices().removeTask(task.persistentId);
                            }
                        }
                        Recents.getSystemServices().updateOverviewLastStackActiveTimeAsync(
                                currentTime, currentUser);

                        // Clear the last PiP task time, it's an edge case and we'd rather it
                        // not relaunch the PiP task if the user double taps
                        RecentsImpl.clearLastPipTime();
                    }
                }
            }
        }
    };
@@ -383,7 +348,6 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        // Register the broadcast receiver to handle messages when the screen is turned off
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        filter.addAction(Intent.ACTION_TIME_CHANGED);
        filter.addAction(Intent.ACTION_USER_SWITCHED);
        registerReceiver(mSystemBroadcastReceiver, filter);

@@ -931,13 +895,9 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        Recents.getTaskLoader().dump(prefix, writer);

        String id = Integer.toHexString(System.identityHashCode(this));
        long lastStackActiveTime = Settings.Secure.getLongForUser(getContentResolver(),
                Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, -1,
                SystemServicesProxy.getInstance(this).getCurrentUser());

        writer.print(prefix); writer.print(TAG);
        writer.print(" visible="); writer.print(mIsVisible ? "Y" : "N");
        writer.print(" lastStackTaskActiveTime="); writer.print(lastStackActiveTime);
        writer.print(" currentTime="); writer.print(System.currentTimeMillis());
        writer.print(" [0x"); writer.print(id); writer.print("]");
        writer.println();
+2 −12
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.provider.Settings.Secure;
import android.service.dreams.DreamService;
import android.service.dreams.IDreamManager;
import android.util.ArraySet;
@@ -391,7 +390,7 @@ public class SystemServicesProxy {
     *                                     visible.
     */
    public List<ActivityManager.RecentTaskInfo> getRecentTasks(int numLatestTasks, int userId,
            boolean includeFrontMostExcludedTask, ArraySet<Integer> quietProfileIds) {
            boolean includeFrontMostExcludedTask) {
        if (mAm == null) return null;

        // If we are mocking, then create some recent tasks
@@ -412,7 +411,7 @@ public class SystemServicesProxy {
                rti.baseIntent = new Intent();
                rti.baseIntent.setComponent(cn);
                rti.description = description;
                rti.firstActiveTime = rti.lastActiveTime = i;
                rti.lastActiveTime = i;
                if (i % 2 == 0) {
                    rti.taskDescription = new ActivityManager.TaskDescription(description,
                            Bitmap.createBitmap(mDummyIcon), null,
@@ -469,7 +468,6 @@ public class SystemServicesProxy {
            // are requested to include it
            boolean isExcluded = (t.baseIntent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
                    == Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
            isExcluded |= quietProfileIds.contains(t.userId);
            if (isExcluded && (!isFirstValidTask || !includeFrontMostExcludedTask)) {
                iter.remove();
            }
@@ -1292,14 +1290,6 @@ public class SystemServicesProxy {
        });
    }

    public void updateOverviewLastStackActiveTimeAsync(long newLastStackActiveTime,
            int currentUserId) {
        mUiOffloadThread.submit(() -> {
            Settings.Secure.putLongForUser(mContext.getContentResolver(),
                    Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, newLastStackActiveTime, currentUserId);
        });
    }

    public interface StartActivityFromRecentsResultListener {
        void onStartActivityResult(boolean succeeded);
    }
Loading