Setting TaskRecord#mUserSetupComplete directly from Settings
TaskRecord#mUserSetupComplete flag was being set by checking
UserController#mSetupCompletedUsers which was being populated by a
callback which was getting delayed long enough for some tasks being
launched with mUserSetupComplete set to false, which is not expected for
any task other than Setup Wizard. This change checks the flag directly
from Settings before setting the property.
Bug: b/27455564
Change-Id: I9ae2e969b590a95f71002a54c7de224b26e9da79
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index 62275a9..ea85fa1 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -40,6 +40,7 @@
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.UserHandle;
+import android.provider.Settings;
import android.service.voice.IVoiceInteractionSession;
import android.util.DisplayMetrics;
import android.util.Slog;
@@ -74,6 +75,7 @@
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
import static android.content.pm.ApplicationInfo.PRIVATE_FLAG_PRIVILEGED;
+import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ADD_REMOVE;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_LOCKTASK;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_RECENTS;
@@ -444,9 +446,9 @@
// task as having a true root activity.
rootWasReset = true;
}
-
userId = UserHandle.getUserId(info.applicationInfo.uid);
- mUserSetupComplete = mService.mUserController.isUserSetupCompleteLocked(userId);
+ mUserSetupComplete = Settings.Secure.getIntForUser(mService.mContext.getContentResolver(),
+ USER_SETUP_COMPLETE, 0, userId) != 0;
if ((info.flags & ActivityInfo.FLAG_AUTO_REMOVE_FROM_RECENTS) != 0) {
// If the activity itself has requested auto-remove, then just always do it.
autoRemoveRecents = true;
@@ -1570,6 +1572,7 @@
pw.print(prefix); pw.print("userId="); pw.print(userId);
pw.print(" effectiveUid="); UserHandle.formatUid(pw, effectiveUid);
pw.print(" mCallingUid="); UserHandle.formatUid(pw, mCallingUid);
+ pw.print(" mUserSetupComplete="); pw.print(mUserSetupComplete);
pw.print(" mCallingPackage="); pw.println(mCallingPackage);
if (affinity != null || rootAffinity != null) {
pw.print(prefix); pw.print("affinity="); pw.print(affinity);