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;
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;
// 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) {
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);
}
}
}
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");
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;
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;
}
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
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;
+ }
}