diff options
Diffstat (limited to 'services/core/java/com/android/server/am')
5 files changed, 57 insertions, 36 deletions
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index 8373994b4c4..1a01a4b0dd4 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -3174,8 +3174,11 @@ public final class ActiveServices { } } - // If unbound while waiting to start, remove the pending service - mPendingServices.remove(s); + // If unbound while waiting to start and there is no connection left in this service, + // remove the pending service + if (s.getConnections().isEmpty()) { + mPendingServices.remove(s); + } if ((c.flags&Context.BIND_AUTO_CREATE) != 0) { boolean hasAutoCreate = s.hasAutoCreateConnections(); diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 20253be76c6..0d9b907cddf 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -271,8 +271,8 @@ import android.os.WorkSource; import android.os.storage.IStorageManager; import android.os.storage.StorageManager; import android.provider.DeviceConfig; -import android.provider.Settings; import android.provider.DeviceConfig.Properties; +import android.provider.Settings; import android.server.ServerProtoEnums; import android.sysprop.VoldProperties; import android.text.TextUtils; @@ -352,7 +352,6 @@ import com.android.server.contentcapture.ContentCaptureManagerInternal; import com.android.server.firewall.IntentFirewall; import com.android.server.job.JobSchedulerInternal; import com.android.server.pm.Installer; -import com.android.server.pm.Installer.InstallerException; import com.android.server.uri.GrantUri; import com.android.server.uri.UriGrantsManagerInternal; import com.android.server.utils.PriorityDump; @@ -364,8 +363,6 @@ import com.android.server.wm.ActivityTaskManagerService; import com.android.server.wm.WindowManagerService; import com.android.server.wm.WindowProcessController; -import dalvik.system.VMRuntime; - import libcore.util.EmptyArray; import java.io.File; @@ -5205,26 +5202,6 @@ public class ActivityManagerService extends IActivityManager.Stub mCallFinishBooting = false; } - ArraySet<String> completedIsas = new ArraySet<String>(); - for (String abi : Build.SUPPORTED_ABIS) { - ZYGOTE_PROCESS.establishZygoteConnectionForAbi(abi); - final String instructionSet = VMRuntime.getInstructionSet(abi); - if (!completedIsas.contains(instructionSet)) { - try { - mInstaller.markBootComplete(VMRuntime.getInstructionSet(abi)); - } catch (InstallerException e) { - if (!VMRuntime.didPruneDalvikCache()) { - // This is technically not the right filter, as different zygotes may - // have made different pruning decisions. But the log is best effort, - // anyways. - Slog.w(TAG, "Unable to mark boot complete for abi: " + abi + " (" + - e.getMessage() +")"); - } - } - completedIsas.add(instructionSet); - } - } - IntentFilter pkgFilter = new IntentFilter(); pkgFilter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART); pkgFilter.addDataScheme("package"); @@ -8263,6 +8240,21 @@ public class ActivityManagerService extends IActivityManager.Stub } } + private boolean isActiveInstrumentation(int uid) { + synchronized (ActivityManagerService.this) { + for (int i = mActiveInstrumentation.size() - 1; i >= 0; i--) { + final ActiveInstrumentation instrumentation = mActiveInstrumentation.get(i); + for (int j = instrumentation.mRunningProcesses.size() - 1; j >= 0; j--) { + final ProcessRecord process = instrumentation.mRunningProcesses.get(j); + if (process.uid == uid) { + return true; + } + } + } + } + return false; + } + @Override public int getUidProcessState(int uid, String callingPackage) { if (!hasUsageStatsPermission(callingPackage)) { @@ -18507,6 +18499,11 @@ public class ActivityManagerService extends IActivityManager.Stub public void unregisterProcessObserver(IProcessObserver processObserver) { ActivityManagerService.this.unregisterProcessObserver(processObserver); } + + @Override + public boolean isActiveInstrumentation(int uid) { + return ActivityManagerService.this.isActiveInstrumentation(uid); + } } long inputDispatchingTimedOut(int pid, final boolean aboveSystem, String reason) { diff --git a/services/core/java/com/android/server/am/CarUserSwitchingDialog.java b/services/core/java/com/android/server/am/CarUserSwitchingDialog.java index ebfc2a011e8..a6811e3070b 100644 --- a/services/core/java/com/android/server/am/CarUserSwitchingDialog.java +++ b/services/core/java/com/android/server/am/CarUserSwitchingDialog.java @@ -30,9 +30,9 @@ import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.RectF; -import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.UserManager; +import android.provider.Settings; import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; @@ -56,8 +56,6 @@ final class CarUserSwitchingDialog extends UserSwitchingDialog { String switchingToSystemUserMessage) { super(service, context, oldUser, newUser, aboveSystem, switchingFromSystemUserMessage, switchingToSystemUserMessage); - - getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); } @Override @@ -81,8 +79,19 @@ final class CarUserSwitchingDialog extends UserSwitchingDialog { .setImageDrawable(drawable); } - ((TextView) view.findViewById(R.id.user_loading)) - .setText(res.getString(R.string.car_loading_profile)); + TextView msgView = view.findViewById(R.id.user_loading); + + // TODO(b/145132885): use constant from CarSettings + boolean showInfo = "true".equals(Settings.Global.getString( + getContext().getContentResolver(), + "android.car.ENABLE_USER_SWITCH_DEVELOPER_MESSAGE")); + + if (showInfo) { + msgView.setText(res.getString(R.string.car_loading_profile) + " user\n(from " + + mOldUser.id + " to " + mNewUser.id + ")"); + } else { + msgView.setText(res.getString(R.string.car_loading_profile)); + } setView(view); } diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java index fe29a36ec45..278163b9dfe 100644 --- a/services/core/java/com/android/server/am/ProcessList.java +++ b/services/core/java/com/android/server/am/ProcessList.java @@ -422,9 +422,7 @@ public final class ProcessList { @GuardedBy("ProcessList.this.mService") void freeIsolatedUidLocked(int uid) { - // Strip out userId - final int appId = UserHandle.getAppId(uid); - mUidUsed.delete(appId); + mUidUsed.delete(uid); } }; diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java index f6b49bc9a25..07b5c5fccca 100644 --- a/services/core/java/com/android/server/am/UserController.java +++ b/services/core/java/com/android/server/am/UserController.java @@ -129,6 +129,10 @@ class UserController implements Handler.Callback { // giving up on them and unfreezing the screen. static final int USER_SWITCH_TIMEOUT_MS = 3 * 1000; + // Amount of time we wait for observers to handle a user switch before we log a warning. + // Must be smaller than USER_SWITCH_TIMEOUT_MS. + private static final int USER_SWITCH_WARNING_TIMEOUT_MS = 500; + // ActivityManager thread message constants static final int REPORT_USER_SWITCH_MSG = 10; static final int CONTINUE_USER_SWITCH_MSG = 20; @@ -408,6 +412,7 @@ class UserController implements Handler.Callback { */ private boolean finishUserUnlocking(final UserState uss) { final int userId = uss.mHandle.getIdentifier(); + Slog.d(TAG, "UserController event: finishUserUnlocking(" + userId + ")"); // Only keep marching forward if user is actually unlocked if (!StorageManager.isUserKeyUnlocked(userId)) return false; synchronized (mLock) { @@ -452,6 +457,7 @@ class UserController implements Handler.Callback { */ void finishUserUnlocked(final UserState uss) { final int userId = uss.mHandle.getIdentifier(); + Slog.d(TAG, "UserController event: finishUserUnlocked(" + userId + ")"); // Only keep marching forward if user is actually unlocked if (!StorageManager.isUserKeyUnlocked(userId)) return; synchronized (mLock) { @@ -522,6 +528,7 @@ class UserController implements Handler.Callback { private void finishUserUnlockedCompleted(UserState uss) { final int userId = uss.mHandle.getIdentifier(); + Slog.d(TAG, "UserController event: finishUserUnlockedCompleted(" + userId + ")"); synchronized (mLock) { // Bail if we ended up with a stale user if (mStartedUsers.get(uss.mHandle.getIdentifier()) != uss) return; @@ -739,6 +746,7 @@ class UserController implements Handler.Callback { } void finishUserStopping(final int userId, final UserState uss) { + Slog.d(TAG, "UserController event: finishUserStopping(" + userId + ")"); // On to the next. final Intent shutdownIntent = new Intent(Intent.ACTION_SHUTDOWN); // This is the result receiver for the final shutdown broadcast. @@ -778,6 +786,7 @@ class UserController implements Handler.Callback { void finishUserStopped(UserState uss) { final int userId = uss.mHandle.getIdentifier(); + Slog.d(TAG, "UserController event: finishUserStopped(" + userId + ")"); final boolean stopped; boolean lockUser = true; final ArrayList<IStopUserCallback> stopCallbacks; @@ -1259,7 +1268,7 @@ class UserController implements Handler.Callback { Slog.w(TAG, msg); throw new SecurityException(msg); } - + Slog.i(TAG, "unlocking user " + userId); final long binderToken = Binder.clearCallingIdentity(); try { return unlockUserCleared(userId, token, secret, listener); @@ -1344,6 +1353,7 @@ class UserController implements Handler.Callback { boolean switchUser(final int targetUserId) { enforceShellRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES, targetUserId); + Slog.i(TAG, "switching to user " + targetUserId); int currentUserId = getCurrentUserId(); UserInfo targetUserInfo = getUserInfo(targetUserId); if (targetUserId == currentUserId) { @@ -1486,9 +1496,13 @@ class UserController implements Handler.Callback { synchronized (mLock) { long delay = SystemClock.elapsedRealtime() - dispatchStartedTime; if (delay > USER_SWITCH_TIMEOUT_MS) { - Slog.e(TAG, "User switch timeout: observer " + name + Slog.e(TAG, "User switch timeout: observer " + name + " sent result after " + delay + " ms"); + } else if (delay > USER_SWITCH_WARNING_TIMEOUT_MS) { + Slog.w(TAG, "User switch slowed down by observer " + name + + ": result sent after " + delay + " ms"); } + curWaitingUserSwitchCallbacks.remove(name); // Continue switching if all callbacks have been notified and // user switching session is still valid |