Loading core/java/android/provider/Settings.java +8 −0 Original line number Diff line number Diff line Loading @@ -6166,6 +6166,14 @@ 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 Loading packages/SystemUI/src/com/android/systemui/Prefs.java +1 −0 Original line number Diff line number Diff line Loading @@ -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"; Loading packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +10 −7 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.Handler; import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings.Secure; import android.util.Log; import android.view.KeyEvent; import android.view.View; Loading @@ -42,7 +43,6 @@ import android.view.WindowManager.LayoutParams; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.systemui.Interpolators; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.recents.events.EventBus; import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent; Loading Loading @@ -179,8 +179,10 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD // 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 long oldLastStackActiveTime = Prefs.getLong(RecentsActivity.this, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, -1); 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) { Loading @@ -198,8 +200,8 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD Recents.getSystemServices().removeTask(task.persistentId); } } Prefs.putLong(RecentsActivity.this, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, currentTime); Settings.Secure.putLongForUser(RecentsActivity.this.getContentResolver(), Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, currentTime, currentUser); } } } Loading Loading @@ -825,8 +827,9 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD Recents.getTaskLoader().dump(prefix, writer); String id = Integer.toHexString(System.identityHashCode(this)); long lastStackActiveTime = Prefs.getLong(this, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, -1); 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"); Loading packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java +40 −4 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.provider.Settings.Secure; import android.util.ArraySet; import android.util.SparseArray; import android.util.SparseIntArray; Loading Loading @@ -129,14 +131,17 @@ public class RecentsTaskLoadPlan { preloadRawTasks(includeFrontMostExcludedTask); } SystemServicesProxy ssp = SystemServicesProxy.getInstance(mContext); SparseArray<Task.TaskKey> affiliatedTasks = new SparseArray<>(); SparseIntArray affiliatedTaskCounts = new SparseIntArray(); String dismissDescFormat = mContext.getString( R.string.accessibility_recents_item_will_be_dismissed); String appInfoDescFormat = mContext.getString( R.string.accessibility_recents_item_open_app_info); long lastStackActiveTime = Prefs.getLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, 0); int currentUserId = ssp.getCurrentUser(); long legacyLastStackActiveTime = migrateLegacyLastStackActiveTime(currentUserId); long lastStackActiveTime = Settings.Secure.getLongForUser(mContext.getContentResolver(), Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, legacyLastStackActiveTime, currentUserId); if (RecentsDebugFlags.Static.EnableMockTasks) { lastStackActiveTime = 0; } Loading Loading @@ -198,8 +203,8 @@ public class RecentsTaskLoadPlan { affiliatedTasks.put(taskKey.id, taskKey); } if (newLastStackActiveTime != -1) { Prefs.putLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, newLastStackActiveTime); Settings.Secure.putLongForUser(mContext.getContentResolver(), Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, newLastStackActiveTime, currentUserId); } // Initialize the stacks Loading Loading @@ -278,4 +283,35 @@ public class RecentsTaskLoadPlan { private boolean isHistoricalTask(ActivityManager.RecentTaskInfo t) { return t.lastActiveTime < (System.currentTimeMillis() - SESSION_BEGIN_TIME); } /** * Migrate the last active time from the prefs to the secure settings. * * The first time this runs, it will: * 1) fetch the last stack active time from the prefs * 2) set the prefs to the last stack active time for all users * 3) clear the pref * 4) return the last stack active time * * Subsequent calls to this will return zero. */ private long migrateLegacyLastStackActiveTime(int currentUserId) { long legacyLastStackActiveTime = Prefs.getLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, -1); if (legacyLastStackActiveTime != -1) { Prefs.remove(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME); UserManager userMgr = (UserManager) mContext.getSystemService(Context.USER_SERVICE); List<UserInfo> users = userMgr.getUsers(); for (int i = 0; i < users.size(); i++) { int userId = users.get(i).id; if (userId != currentUserId) { Settings.Secure.putLongForUser(mContext.getContentResolver(), Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, legacyLastStackActiveTime, userId); } } return legacyLastStackActiveTime; } return 0; } } Loading
core/java/android/provider/Settings.java +8 −0 Original line number Diff line number Diff line Loading @@ -6166,6 +6166,14 @@ 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 Loading
packages/SystemUI/src/com/android/systemui/Prefs.java +1 −0 Original line number Diff line number Diff line Loading @@ -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"; Loading
packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +10 −7 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.Handler; import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings.Secure; import android.util.Log; import android.view.KeyEvent; import android.view.View; Loading @@ -42,7 +43,6 @@ import android.view.WindowManager.LayoutParams; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.systemui.Interpolators; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.recents.events.EventBus; import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent; Loading Loading @@ -179,8 +179,10 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD // 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 long oldLastStackActiveTime = Prefs.getLong(RecentsActivity.this, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, -1); 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) { Loading @@ -198,8 +200,8 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD Recents.getSystemServices().removeTask(task.persistentId); } } Prefs.putLong(RecentsActivity.this, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, currentTime); Settings.Secure.putLongForUser(RecentsActivity.this.getContentResolver(), Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, currentTime, currentUser); } } } Loading Loading @@ -825,8 +827,9 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD Recents.getTaskLoader().dump(prefix, writer); String id = Integer.toHexString(System.identityHashCode(this)); long lastStackActiveTime = Prefs.getLong(this, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, -1); 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"); Loading
packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java +40 −4 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.provider.Settings.Secure; import android.util.ArraySet; import android.util.SparseArray; import android.util.SparseIntArray; Loading Loading @@ -129,14 +131,17 @@ public class RecentsTaskLoadPlan { preloadRawTasks(includeFrontMostExcludedTask); } SystemServicesProxy ssp = SystemServicesProxy.getInstance(mContext); SparseArray<Task.TaskKey> affiliatedTasks = new SparseArray<>(); SparseIntArray affiliatedTaskCounts = new SparseIntArray(); String dismissDescFormat = mContext.getString( R.string.accessibility_recents_item_will_be_dismissed); String appInfoDescFormat = mContext.getString( R.string.accessibility_recents_item_open_app_info); long lastStackActiveTime = Prefs.getLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, 0); int currentUserId = ssp.getCurrentUser(); long legacyLastStackActiveTime = migrateLegacyLastStackActiveTime(currentUserId); long lastStackActiveTime = Settings.Secure.getLongForUser(mContext.getContentResolver(), Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, legacyLastStackActiveTime, currentUserId); if (RecentsDebugFlags.Static.EnableMockTasks) { lastStackActiveTime = 0; } Loading Loading @@ -198,8 +203,8 @@ public class RecentsTaskLoadPlan { affiliatedTasks.put(taskKey.id, taskKey); } if (newLastStackActiveTime != -1) { Prefs.putLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, newLastStackActiveTime); Settings.Secure.putLongForUser(mContext.getContentResolver(), Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, newLastStackActiveTime, currentUserId); } // Initialize the stacks Loading Loading @@ -278,4 +283,35 @@ public class RecentsTaskLoadPlan { private boolean isHistoricalTask(ActivityManager.RecentTaskInfo t) { return t.lastActiveTime < (System.currentTimeMillis() - SESSION_BEGIN_TIME); } /** * Migrate the last active time from the prefs to the secure settings. * * The first time this runs, it will: * 1) fetch the last stack active time from the prefs * 2) set the prefs to the last stack active time for all users * 3) clear the pref * 4) return the last stack active time * * Subsequent calls to this will return zero. */ private long migrateLegacyLastStackActiveTime(int currentUserId) { long legacyLastStackActiveTime = Prefs.getLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, -1); if (legacyLastStackActiveTime != -1) { Prefs.remove(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME); UserManager userMgr = (UserManager) mContext.getSystemService(Context.USER_SERVICE); List<UserInfo> users = userMgr.getUsers(); for (int i = 0; i < users.size(); i++) { int userId = users.get(i).id; if (userId != currentUserId) { Settings.Secure.putLongForUser(mContext.getContentResolver(), Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, legacyLastStackActiveTime, userId); } } return legacyLastStackActiveTime; } return 0; } }