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

Commit 70f21570 authored by Winson's avatar Winson Committed by android-build-merger
Browse files

Fixing issue with old tasks being visible in Overview am: b258f6a4 am: f4806c80

am: 2a4cd151

Change-Id: I8a229f3515bebca4cd8456afae963bb97dac96d6
parents b490f534 2a4cd151
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -6405,6 +6405,21 @@ public final class Settings {
         */
        public static final String WEB_ACTION_ENABLED = "web_action_enabled";

        /**
         * The uptime when tasks were last persisted.  This is used to adjust the previous task
         * active times to be relative to the current boot time.
         * @hide
         */
        public static final String TASK_PERSISTER_LAST_WRITE_UPTIME = "task_persister_write_uptime";

        /**
         * Used by Overview to keep track of the last visible task's active time to determine what
         * should tasks be visible.
         * @hide
         */
        public static final String OVERVIEW_LAST_VISIBLE_TASK_ACTIVE_UPTIME =
                "overview_last_visible_task_active_uptime";

        /**
         * This are the settings to be backed up.
         *
+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ public final class Prefs {
        Key.QS_WORK_ADDED,
    })
    public @interface Key {
        @Deprecated
        String OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME = "OverviewLastStackTaskActiveTime";
        String DEBUG_MODE_ENABLED = "debugModeEnabled";
        String HOTSPOT_TILE_LAST_USED = "HotspotTileLastUsed";
+15 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
@@ -46,6 +47,7 @@ import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.systemui.EventLogConstants;
import com.android.systemui.EventLogTags;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.SystemUI;
@@ -250,6 +252,19 @@ public class Recents extends SystemUI
            registerWithSystemUser();
        }
        putComponent(Recents.class, this);

        // Migrate the old stack active time if necessary, otherwise, it will already be managed
        // when the tasks are loaded in the system. See TaskPersister.restoreTasksForUserLocked().
        long lastVisibleTaskActiveTime = Prefs.getLong(mContext,
                Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, -1);
        if (lastVisibleTaskActiveTime != -1) {
            long uptime = SystemClock.elapsedRealtime();
            Settings.Secure.putLongForUser(mContext.getContentResolver(),
                    Settings.Secure.OVERVIEW_LAST_VISIBLE_TASK_ACTIVE_UPTIME,
                    uptime - Math.max(0, System.currentTimeMillis() - lastVisibleTaskActiveTime),
                    processUser);
            Prefs.remove(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME);
        }
    }

    @Override
+10 −12
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.Activity;
import android.app.ActivityOptions;
import android.app.TaskStackBuilder;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -170,13 +171,6 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
            if (action.equals(Intent.ACTION_SCREEN_OFF)) {
                // When the screen turns off, dismiss Recents to Home
                dismissRecentsToHomeIfVisible(false);
            } else if (action.equals(Intent.ACTION_TIME_CHANGED)) {
                // For the time being, if the time changes, then invalidate the
                // last-stack-active-time, this ensures that we will just show the last N tasks
                // the next time that Recents loads, but prevents really old tasks from showing
                // up if the task time is set forward.
                Prefs.putLong(RecentsActivity.this, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME,
                        0);
            }
        }
    };
@@ -322,7 +316,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);
        registerReceiver(mSystemBroadcastReceiver, filter);

        getWindow().addPrivateFlags(LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION);
@@ -800,14 +793,19 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        EventBus.getDefault().dump(prefix, writer);
        Recents.getTaskLoader().dump(prefix, writer);

        ContentResolver cr = getContentResolver();
        long lastPersistUptime = Settings.Secure.getLong(cr,
                Settings.Secure.TASK_PERSISTER_LAST_WRITE_UPTIME, 0);
        long lastVisibleTaskActiveUptime = Settings.Secure.getLongForUser(cr,
                Settings.Secure.OVERVIEW_LAST_VISIBLE_TASK_ACTIVE_UPTIME,
                SystemClock.elapsedRealtime(), Recents.getSystemServices().getCurrentUser());

        String id = Integer.toHexString(System.identityHashCode(this));
        long lastStackActiveTime = Prefs.getLong(this,
                Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, -1);

        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(" lastPersistUptime="); writer.print(lastPersistUptime);
        writer.print(" lastVisibleTaskActiveUptime="); writer.print(lastVisibleTaskActiveUptime);
        writer.print(" [0x"); writer.print(id); writer.print("]");
        writer.println();

+6 −1
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
@@ -75,6 +76,7 @@ import android.view.WindowManager.KeyboardShortcutsReceiver;
import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityManager;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.AssistUtils;
import com.android.internal.os.BackgroundThread;
import com.android.systemui.R;
@@ -199,6 +201,9 @@ public class SystemServicesProxy {
     */
    private List<TaskStackListener> mTaskStackListeners = new ArrayList<>();

    /** Test constructor */
    @VisibleForTesting public SystemServicesProxy() {}

    /** Private constructor */
    private SystemServicesProxy(Context context) {
        mAccm = AccessibilityManager.getInstance(context);
@@ -300,7 +305,7 @@ public class SystemServicesProxy {
                rti.baseIntent = new Intent();
                rti.baseIntent.setComponent(cn);
                rti.description = description;
                rti.firstActiveTime = rti.lastActiveTime = i;
                rti.firstActiveTime = rti.lastActiveTime = SystemClock.elapsedRealtime();
                if (i % 2 == 0) {
                    rti.taskDescription = new ActivityManager.TaskDescription(description,
                        Bitmap.createBitmap(mDummyIcon), null,
Loading