From cd5a45a9793bfbba079242586933af6832a41e52 Mon Sep 17 00:00:00 2001 From: Vadim Caen Date: Mon, 24 Jan 2022 18:14:44 +0100 Subject: [PATCH] Add option to show the splashscreen from 'adb shell am' Add an option to show the splashscreen when launching an appliation : --splashscreen-show-icon This will allow to show the splash screen when the application is run from Android Studio Bug: 205021357 Test: adb shell am start --splashscreen-show-icon Change-Id: I09371169bea9c8114c6bf6fe4d486164b5cf561a --- .../server/am/ActivityManagerShellCommand.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java index c062365944d77..b6a0ec4278d62 100644 --- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java +++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java @@ -98,6 +98,7 @@ import android.util.DebugUtils; import android.util.DisplayMetrics; import android.util.proto.ProtoOutputStream; import android.view.Display; +import android.window.SplashScreen; import com.android.internal.compat.CompatibilityChangeConfig; import com.android.internal.util.HexDump; @@ -178,6 +179,7 @@ final class ActivityManagerShellCommand extends ShellCommand { private boolean mIsLockTask; private boolean mAsync; private BroadcastOptions mBroadcastOptions; + private boolean mShowSplashScreen; final boolean mDumping; @@ -428,6 +430,8 @@ final class ActivityManagerShellCommand extends ShellCommand { mBroadcastOptions.setBackgroundActivityStartsAllowed(true); } else if (opt.equals("--async")) { mAsync = true; + } else if (opt.equals("--splashscreen-show-icon")) { + mShowSplashScreen = true; } else { return false; } @@ -566,6 +570,12 @@ final class ActivityManagerShellCommand extends ShellCommand { } options.setLockTaskEnabled(true); } + if (mShowSplashScreen) { + if (options == null) { + options = ActivityOptions.makeBasic(); + } + options.setSplashScreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_ICON); + } if (mWaitOption) { result = mInternal.startActivityAndWait(null, SHELL_PACKAGE_NAME, null, intent, mimeType, null, null, 0, mStartFlags, profilerInfo, @@ -3301,6 +3311,7 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println(" --windowingMode : The windowing mode to launch the activity into."); pw.println(" --activityType : The activity type to launch the activity as."); pw.println(" --display : The display to launch the activity into."); + pw.println(" --splashscreen-icon: Show the splash screen icon on launch."); pw.println(" start-service [--user | current] "); pw.println(" Start a Service. Options are:"); pw.println(" --user | current: Specify which user to run as; if not");