Merge "DO NOT MERGE - Ensuring that there are per-user last stack active times." into nyc-mr2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e0e08f3f41
@@ -6166,6 +6166,14 @@ public final class Settings {
|
|||||||
public static final String LOCK_SCREEN_SHOW_NOTIFICATIONS =
|
public static final String LOCK_SCREEN_SHOW_NOTIFICATIONS =
|
||||||
"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
|
* 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
|
* containing the IDs of all hidden TV inputs. Each ID is encoded by
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public final class Prefs {
|
|||||||
Key.QS_WORK_ADDED,
|
Key.QS_WORK_ADDED,
|
||||||
})
|
})
|
||||||
public @interface Key {
|
public @interface Key {
|
||||||
|
@Deprecated
|
||||||
String OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME = "OverviewLastStackTaskActiveTime";
|
String OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME = "OverviewLastStackTaskActiveTime";
|
||||||
String DEBUG_MODE_ENABLED = "debugModeEnabled";
|
String DEBUG_MODE_ENABLED = "debugModeEnabled";
|
||||||
String HOTSPOT_TILE_LAST_USED = "HotspotTileLastUsed";
|
String HOTSPOT_TILE_LAST_USED = "HotspotTileLastUsed";
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import android.os.Handler;
|
|||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.provider.Settings.Secure;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -42,7 +43,6 @@ import android.view.WindowManager.LayoutParams;
|
|||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||||
import com.android.systemui.Interpolators;
|
import com.android.systemui.Interpolators;
|
||||||
import com.android.systemui.Prefs;
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.recents.events.EventBus;
|
import com.android.systemui.recents.events.EventBus;
|
||||||
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
|
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
|
// 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
|
// currentTime and remove the old tasks in between which would not be previously
|
||||||
// visible, but currently would be in the new currentTime
|
// visible, but currently would be in the new currentTime
|
||||||
long oldLastStackActiveTime = Prefs.getLong(RecentsActivity.this,
|
int currentUser = SystemServicesProxy.getInstance(RecentsActivity.this)
|
||||||
Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, -1);
|
.getCurrentUser();
|
||||||
|
long oldLastStackActiveTime = Settings.Secure.getLongForUser(getContentResolver(),
|
||||||
|
Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, -1, currentUser);
|
||||||
if (oldLastStackActiveTime != -1) {
|
if (oldLastStackActiveTime != -1) {
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
if (currentTime < oldLastStackActiveTime) {
|
if (currentTime < oldLastStackActiveTime) {
|
||||||
@@ -198,8 +200,8 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
|
|||||||
Recents.getSystemServices().removeTask(task.persistentId);
|
Recents.getSystemServices().removeTask(task.persistentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Prefs.putLong(RecentsActivity.this,
|
Settings.Secure.putLongForUser(RecentsActivity.this.getContentResolver(),
|
||||||
Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, currentTime);
|
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);
|
Recents.getTaskLoader().dump(prefix, writer);
|
||||||
|
|
||||||
String id = Integer.toHexString(System.identityHashCode(this));
|
String id = Integer.toHexString(System.identityHashCode(this));
|
||||||
long lastStackActiveTime = Prefs.getLong(this,
|
long lastStackActiveTime = Settings.Secure.getLongForUser(getContentResolver(),
|
||||||
Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, -1);
|
Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, -1,
|
||||||
|
SystemServicesProxy.getInstance(this).getCurrentUser());
|
||||||
|
|
||||||
writer.print(prefix); writer.print(TAG);
|
writer.print(prefix); writer.print(TAG);
|
||||||
writer.print(" visible="); writer.print(mIsVisible ? "Y" : "N");
|
writer.print(" visible="); writer.print(mIsVisible ? "Y" : "N");
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.provider.Settings.Secure;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.util.SparseIntArray;
|
import android.util.SparseIntArray;
|
||||||
@@ -129,14 +131,17 @@ public class RecentsTaskLoadPlan {
|
|||||||
preloadRawTasks(includeFrontMostExcludedTask);
|
preloadRawTasks(includeFrontMostExcludedTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemServicesProxy ssp = SystemServicesProxy.getInstance(mContext);
|
||||||
SparseArray<Task.TaskKey> affiliatedTasks = new SparseArray<>();
|
SparseArray<Task.TaskKey> affiliatedTasks = new SparseArray<>();
|
||||||
SparseIntArray affiliatedTaskCounts = new SparseIntArray();
|
SparseIntArray affiliatedTaskCounts = new SparseIntArray();
|
||||||
String dismissDescFormat = mContext.getString(
|
String dismissDescFormat = mContext.getString(
|
||||||
R.string.accessibility_recents_item_will_be_dismissed);
|
R.string.accessibility_recents_item_will_be_dismissed);
|
||||||
String appInfoDescFormat = mContext.getString(
|
String appInfoDescFormat = mContext.getString(
|
||||||
R.string.accessibility_recents_item_open_app_info);
|
R.string.accessibility_recents_item_open_app_info);
|
||||||
long lastStackActiveTime = Prefs.getLong(mContext,
|
int currentUserId = ssp.getCurrentUser();
|
||||||
Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, 0);
|
long legacyLastStackActiveTime = migrateLegacyLastStackActiveTime(currentUserId);
|
||||||
|
long lastStackActiveTime = Settings.Secure.getLongForUser(mContext.getContentResolver(),
|
||||||
|
Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, legacyLastStackActiveTime, currentUserId);
|
||||||
if (RecentsDebugFlags.Static.EnableMockTasks) {
|
if (RecentsDebugFlags.Static.EnableMockTasks) {
|
||||||
lastStackActiveTime = 0;
|
lastStackActiveTime = 0;
|
||||||
}
|
}
|
||||||
@@ -198,8 +203,8 @@ public class RecentsTaskLoadPlan {
|
|||||||
affiliatedTasks.put(taskKey.id, taskKey);
|
affiliatedTasks.put(taskKey.id, taskKey);
|
||||||
}
|
}
|
||||||
if (newLastStackActiveTime != -1) {
|
if (newLastStackActiveTime != -1) {
|
||||||
Prefs.putLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME,
|
Settings.Secure.putLongForUser(mContext.getContentResolver(),
|
||||||
newLastStackActiveTime);
|
Secure.OVERVIEW_LAST_STACK_ACTIVE_TIME, newLastStackActiveTime, currentUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the stacks
|
// Initialize the stacks
|
||||||
@@ -278,4 +283,35 @@ public class RecentsTaskLoadPlan {
|
|||||||
private boolean isHistoricalTask(ActivityManager.RecentTaskInfo t) {
|
private boolean isHistoricalTask(ActivityManager.RecentTaskInfo t) {
|
||||||
return t.lastActiveTime < (System.currentTimeMillis() - SESSION_BEGIN_TIME);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user