summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-02-16 03:02:14 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-02-16 03:02:17 +0000
commite0e08f3f418420a94ef9d507fdd5195dfe2da082 (patch)
treef88f064f4b12068af429991974f68685ad52c0f5
parent4d3435637fb929d04c3805613a378becdd45f02e (diff)
parent512bbdde691fbfc53d8fe39c09b828704a7faa1b (diff)
downloadbase-nougat-mr2-dev.tar.gz
Merge "DO NOT MERGE - Ensuring that there are per-user last stack active times." into nyc-mr2-devnougat-mr2-dev
-rwxr-xr-xcore/java/android/provider/Settings.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/Prefs.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java44
4 files changed, 59 insertions, 11 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index ff1281731a18..a8209af6aa2a 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -6167,6 +6167,14 @@ public final class Settings {
"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
* {@link android.net.Uri#encode(String)} and separated by ':'.
diff --git a/packages/SystemUI/src/com/android/systemui/Prefs.java b/packages/SystemUI/src/com/android/systemui/Prefs.java
index 19ae2954bb2a..b9ae585c339c 100644
--- a/packages/SystemUI/src/com/android/systemui/Prefs.java
+++ b/packages/SystemUI/src/com/android/systemui/Prefs.java
@@ -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";
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index 6e4a69bc1188..764397b93881 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -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;
@@ -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;
@@ -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) {
@@ -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);
}
}
}
@@ -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");
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
index 1f082cce54c1..0ca4cb9031a4 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
@@ -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;
@@ -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;
}
@@ -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
@@ -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;
+ }
}