Loading services/core/java/com/android/server/policy/PhoneWindowManager.java +1 −196 Original line number Diff line number Diff line Loading @@ -21,15 +21,12 @@ import static android.Manifest.permission.SYSTEM_ALERT_WINDOW; import static android.Manifest.permission.SYSTEM_APPLICATION_OVERLAY; import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW; import static android.app.AppOpsManager.OP_TOAST_WINDOW; import static android.content.Context.CONTEXT_RESTRICTED; import static android.content.Context.WINDOW_SERVICE; import static android.content.pm.PackageManager.FEATURE_AUTOMOTIVE; import static android.content.pm.PackageManager.FEATURE_HDMI_CEC; import static android.content.pm.PackageManager.FEATURE_LEANBACK; import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE; import static android.content.pm.PackageManager.FEATURE_WATCH; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.content.res.Configuration.EMPTY; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O; import static android.provider.Settings.Secure.VOLUME_HUSH_OFF; Loading @@ -47,7 +44,6 @@ import static android.view.KeyEvent.KEYCODE_VOLUME_UP; import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.LAST_SYSTEM_WINDOW; Loading Loading @@ -117,13 +113,10 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.database.ContentObserver; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManagerInternal; import android.hardware.hdmi.HdmiAudioSystemClient; Loading Loading @@ -182,7 +175,6 @@ import android.view.KeyCharacterMap; import android.view.KeyCharacterMap.FallbackAction; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import android.view.WindowManager; import android.view.WindowManagerGlobal; Loading Loading @@ -249,9 +241,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final boolean localLOGV = false; static final boolean DEBUG_INPUT = false; static final boolean DEBUG_KEYGUARD = false; static final boolean DEBUG_SPLASH_SCREEN = false; static final boolean DEBUG_WAKEUP = false; static final boolean SHOW_SPLASH_SCREENS = true; // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. // No longer recommended for desk docks; Loading Loading @@ -2354,7 +2344,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { POWER_BUTTON_SUPPRESSION_DELAY_DEFAULT_MILLIS); if (!mContext.getResources() .getBoolean(com.android.internal.R.bool.config_volumeHushGestureEnabled)) { mRingerToggleChord = Settings.Secure.VOLUME_HUSH_OFF; mRingerToggleChord = VOLUME_HUSH_OFF; } // Configure wake gesture. Loading Loading @@ -2572,191 +2562,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { return attrs.type == TYPE_NOTIFICATION_SHADE; } /** {@inheritDoc} */ @Override public StartingSurface addSplashScreen(IBinder appToken, int userId, String packageName, int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags, Configuration overrideConfig, int displayId) { if (!SHOW_SPLASH_SCREENS) { return null; } if (packageName == null) { return null; } WindowManager wm = null; View view = null; try { Context context = mContext; if (DEBUG_SPLASH_SCREEN) Slog.d(TAG, "addSplashScreen " + packageName + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" + Integer.toHexString(theme)); // Obtain proper context to launch on the right display. final Context displayContext = getDisplayContext(context, displayId); if (displayContext == null) { // Can't show splash screen on requested display, so skip showing at all. return null; } context = displayContext; if (theme != context.getThemeResId() || labelRes != 0) { try { context = context.createPackageContextAsUser(packageName, CONTEXT_RESTRICTED, UserHandle.of(userId)); context.setTheme(theme); } catch (PackageManager.NameNotFoundException e) { Slog.w(TAG, "Failed creating package context with package name " + packageName + " for user " + userId, e); } } if (overrideConfig != null && !overrideConfig.equals(EMPTY)) { if (DEBUG_SPLASH_SCREEN) Slog.d(TAG, "addSplashScreen: creating context based" + " on overrideConfig" + overrideConfig + " for splash screen"); final Context overrideContext = context.createConfigurationContext(overrideConfig); overrideContext.setTheme(theme); final TypedArray typedArray = overrideContext.obtainStyledAttributes( com.android.internal.R.styleable.Window); final int resId = typedArray.getResourceId(R.styleable.Window_windowBackground, 0); if (resId != 0 && overrideContext.getDrawable(resId) != null) { // We want to use the windowBackground for the override context if it is // available, otherwise we use the default one to make sure a themed starting // window is displayed for the app. if (DEBUG_SPLASH_SCREEN) Slog.d(TAG, "addSplashScreen: apply overrideConfig" + overrideConfig + " to starting window resId=" + resId); context = overrideContext; } typedArray.recycle(); } final PhoneWindow win = new PhoneWindow(context); win.setIsStartingWindow(true); CharSequence label = context.getResources().getText(labelRes, null); // Only change the accessibility title if the label is localized if (label != null) { win.setTitle(label, true); } else { win.setTitle(nonLocalizedLabel, false); } win.setType( WindowManager.LayoutParams.TYPE_APPLICATION_STARTING); synchronized (mWindowManagerFuncs.getWindowManagerLock()) { // Assumes it's safe to show starting windows of launched apps while // the keyguard is being hidden. This is okay because starting windows never show // secret information. // TODO(b/113840485): Occluded may not only happen on default display if (displayId == DEFAULT_DISPLAY && isKeyguardOccluded()) { windowFlags |= FLAG_SHOW_WHEN_LOCKED; } } // Force the window flags: this is a fake window, so it is not really // touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM // flag because we do know that the next window will take input // focus, so we want to get the IME window up on top of us right away. win.setFlags( windowFlags| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, windowFlags| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); win.setDefaultIcon(icon); win.setDefaultLogo(logo); win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); final WindowManager.LayoutParams params = win.getAttributes(); params.token = appToken; params.packageName = packageName; params.windowAnimations = win.getWindowStyle().getResourceId( com.android.internal.R.styleable.Window_windowAnimationStyle, 0); params.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS; // Setting as trusted overlay to let touches pass through. This is safe because this // window is controlled by the system. params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY; if (!compatInfo.supportsScreen()) { params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW; } params.setTitle("Splash Screen " + packageName); addSplashscreenContent(win, context); wm = (WindowManager) context.getSystemService(WINDOW_SERVICE); view = win.getDecorView(); if (DEBUG_SPLASH_SCREEN) Slog.d(TAG, "Adding splash screen window for " + packageName + " / " + appToken + ": " + (view.getParent() != null ? view : null)); wm.addView(view, params); // Only return the view if it was successfully added to the // window manager... which we can tell by it having a parent. return view.getParent() != null ? new SplashScreenSurface(view, appToken) : null; } catch (WindowManager.BadTokenException e) { // ignore Log.w(TAG, appToken + " already running, starting window not displayed. " + e.getMessage()); } catch (RuntimeException e) { // don't crash if something else bad happens, for example a // failure loading resources because we are loading from an app // on external storage that has been unmounted. Log.w(TAG, appToken + " failed creating starting window", e); } finally { if (view != null && view.getParent() == null) { Log.w(TAG, "view not successfully added to wm, removing view"); wm.removeViewImmediate(view); } } return null; } private void addSplashscreenContent(PhoneWindow win, Context ctx) { final TypedArray a = ctx.obtainStyledAttributes(R.styleable.Window); final int resId = a.getResourceId(R.styleable.Window_windowSplashscreenContent, 0); a.recycle(); if (resId == 0) { return; } final Drawable drawable = ctx.getDrawable(resId); if (drawable == null) { return; } // We wrap this into a view so the system insets get applied to the drawable. final View v = new View(ctx); v.setBackground(drawable); win.setContentView(v); } /** Obtain proper context for showing splash screen on the provided display. */ private Context getDisplayContext(Context context, int displayId) { if (displayId == DEFAULT_DISPLAY) { // The default context fits. return context; } final Display targetDisplay = mDisplayManager.getDisplay(displayId); if (targetDisplay == null) { // Failed to obtain the non-default display where splash screen should be shown, // lets not show at all. return null; } return context.createDisplayContext(targetDisplay); } @Override public Animation createHiddenByKeyguardExit(boolean onWallpaper, boolean goingToNotificationShade, boolean subtleAnimation) { Loading services/core/java/com/android/server/policy/SplashScreenSurface.javadeleted 100644 → 0 +0 −55 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.server.policy; import static com.android.server.policy.PhoneWindowManager.DEBUG_SPLASH_SCREEN; import android.os.Debug; import android.os.IBinder; import android.util.Slog; import android.view.View; import android.view.WindowManager; import com.android.internal.policy.DecorView; import com.android.internal.policy.PhoneWindow; import com.android.server.policy.WindowManagerPolicy.StartingSurface; /** * Holds the contents of a splash screen starting window, i.e. the {@link DecorView} of a * {@link PhoneWindow}. This is just a wrapper such that we can return it from * {@link WindowManagerPolicy#addSplashScreen}. */ class SplashScreenSurface implements StartingSurface { private static final String TAG = PhoneWindowManager.TAG; private final View mView; private final IBinder mAppToken; SplashScreenSurface(View view, IBinder appToken) { mView = view; mAppToken = appToken; } @Override public void remove(boolean animate) { if (DEBUG_SPLASH_SCREEN) Slog.v(TAG, "Removing splash screen window for " + mAppToken + ": " + this + " Callers=" + Debug.getCallers(4)); final WindowManager wm = mView.getContext().getSystemService(WindowManager.class); wm.removeView(mView); } } services/core/java/com/android/server/policy/WindowManagerPolicy.java +0 −43 Original line number Diff line number Diff line Loading @@ -69,7 +69,6 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.Rect; import android.os.Bundle; Loading Loading @@ -223,21 +222,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants { boolean canShowWhenLocked(); } /** * Holds the contents of a starting window. {@link #addSplashScreen} needs to wrap the * contents of the starting window into an class implementing this interface, which then will be * held by WM and released with {@link #remove} when no longer needed. */ interface StartingSurface { /** * Removes the starting window surface. Do not hold the window manager lock when calling * this method! * @param animate Whether need to play the default exit animation for starting window. */ void remove(boolean animate); } /** * Interface for calling back in to the window manager that is private * between it and the policy. Loading Loading @@ -692,33 +676,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants { } } /** * Called when the system would like to show a UI to indicate that an * application is starting. You can use this to add a * APPLICATION_STARTING_TYPE window with the given appToken to the window * manager (using the normal window manager APIs) that will be shown until * the application displays its own window. This is called without the * window manager locked so that you can call back into it. * * @param appToken Token of the application being started. * @param packageName The name of the application package being started. * @param theme Resource defining the application's overall visual theme. * @param nonLocalizedLabel The default title label of the application if * no data is found in the resource. * @param labelRes The resource ID the application would like to use as its name. * @param icon The resource ID the application would like to use as its icon. * @param windowFlags Window layout flags. * @param overrideConfig override configuration to consider when generating * context to for resources. * @param displayId Id of the display to show the splash screen at. * * @return The starting surface. * */ StartingSurface addSplashScreen(IBinder appToken, int userId, String packageName, int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags, Configuration overrideConfig, int displayId); /** * Create and return an animation to re-display a window that was force hidden by Keyguard. */ Loading services/core/java/com/android/server/wm/ActivityRecord.java +9 −69 Original line number Diff line number Diff line Loading @@ -103,7 +103,6 @@ import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; import static android.view.SurfaceControl.getGlobalTransaction; import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; Loading Loading @@ -333,7 +332,6 @@ import com.android.server.am.AppTimeTracker; import com.android.server.am.PendingIntentRecord; import com.android.server.contentcapture.ContentCaptureManagerInternal; import com.android.server.display.color.ColorDisplayService; import com.android.server.policy.WindowManagerPolicy; import com.android.server.uri.NeededUriGrants; import com.android.server.uri.UriPermissionOwner; import com.android.server.wm.ActivityMetricsLogger.TransitionInfoSnapshot; Loading Loading @@ -451,9 +449,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A private CharSequence nonLocalizedLabel; // the label information from the package mgr. private int labelRes; // the label information from the package mgr. private int icon; // resource identifier of activity's icon. private int logo; // resource identifier of activity's logo. private int theme; // resource identifier of activity's theme. private int windowFlags; // custom window flags for preview window. private Task task; // the task this is in. private long createTime = System.currentTimeMillis(); long lastVisibleTime; // last time this activity became visible Loading Loading @@ -735,7 +731,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // Note: these are de-referenced before the starting window animates away. StartingData mStartingData; WindowState mStartingWindow; WindowManagerPolicy.StartingSurface mStartingSurface; StartingSurfaceController.StartingSurface mStartingSurface; boolean startingDisplayed; boolean startingMoved; Loading Loading @@ -1742,11 +1738,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A labelRes = app.labelRes; } icon = aInfo.getIconResource(); logo = aInfo.getLogoResource(); theme = aInfo.getThemeResource(); if ((aInfo.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0) { windowFlags |= LayoutParams.FLAG_HARDWARE_ACCELERATED; } if ((aInfo.flags & FLAG_MULTIPROCESS) != 0 && _caller != null && (aInfo.applicationInfo.uid == SYSTEM_UID || aInfo.applicationInfo.uid == _caller.mInfo.uid)) { Loading Loading @@ -1979,33 +1971,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return true; } private void applyStartingWindowTheme(String pkg, int theme) { if (theme != 0) { AttributeCache.Entry ent = AttributeCache.instance().get(pkg, theme, com.android.internal.R.styleable.Window, mWmService.mCurrentUserId); if (ent == null) { return; } final boolean windowShowWallpaper = ent.array.getBoolean( com.android.internal.R.styleable.Window_windowShowWallpaper, false); if (windowShowWallpaper && getDisplayContent().mWallpaperController .getWallpaperTarget() == null) { // If this theme is requesting a wallpaper, and the wallpaper // is not currently visible, then this effectively serves as // an opaque window and our starting window transition animation // can still work. We just need to make sure the starting window // is also showing the wallpaper. windowFlags |= FLAG_SHOW_WALLPAPER; } } } @VisibleForTesting boolean addStartingWindow(String pkg, int resolvedTheme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags, ActivityRecord from, boolean newTask, boolean taskSwitch, boolean processRunning, boolean allowTaskSnapshot, boolean activityCreated, boolean useEmpty, boolean addStartingWindow(String pkg, int resolvedTheme, ActivityRecord from, boolean newTask, boolean taskSwitch, boolean processRunning, boolean allowTaskSnapshot, boolean activityCreated, boolean useEmpty, boolean activityAllDrawn) { // If the display is frozen, we won't do anything until the actual window is // displayed so there is no reason to put in the starting window. Loading Loading @@ -2062,7 +2031,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (resolvedTheme == 0 && theme != 0) { return false; } applyStartingWindowTheme(pkg, resolvedTheme); if (from != null && transferStartingWindow(from)) { return true; Loading @@ -2075,9 +2043,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "Creating SplashScreenStartingData"); mStartingData = new SplashScreenStartingData(mWmService, pkg, resolvedTheme, compatInfo, nonLocalizedLabel, labelRes, icon, logo, windowFlags, getMergedOverrideConfiguration(), typeParameter); mStartingData = new SplashScreenStartingData(mWmService, resolvedTheme, typeParameter); scheduleAddStartingWindow(); return true; } Loading @@ -2099,17 +2065,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } void scheduleAddStartingWindow() { if (StartingSurfaceController.DEBUG_ENABLE_SHELL_DRAWER) { mAddStartingWindow.run(); } else { // Note: we really want to do sendMessageAtFrontOfQueue() because we // want to process the message ASAP, before any other queued // messages. if (!mWmService.mAnimationHandler.hasCallbacks(mAddStartingWindow)) { ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "Enqueueing ADD_STARTING"); mWmService.mAnimationHandler.postAtFrontOfQueue(mAddStartingWindow); } } } private class AddStartingWindow implements Runnable { Loading @@ -2120,9 +2076,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final StartingData startingData; synchronized (mWmService.mGlobalLock) { // There can only be one adding request, silly caller! if (!StartingSurfaceController.DEBUG_ENABLE_SHELL_DRAWER) { mWmService.mAnimationHandler.removeCallbacks(this); } if (mStartingData == null) { // Animation has been canceled... do nothing. Loading @@ -2137,7 +2090,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "Add starting %s: startingData=%s", this, startingData); WindowManagerPolicy.StartingSurface surface = null; StartingSurfaceController.StartingSurface surface = null; try { surface = startingData.createStartingSurface(ActivityRecord.this); } catch (Exception e) { Loading Loading @@ -2250,9 +2203,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } private boolean transferSplashScreenIfNeeded() { if (!mWmService.mStartingSurfaceController.DEBUG_ENABLE_SHELL_DRAWER) { return false; } if (!mHandleExitSplashScreen || mStartingSurface == null || mStartingWindow == null || mTransferringSplashScreenState == TRANSFER_SPLASH_SCREEN_FINISH) { return false; Loading Loading @@ -2393,7 +2343,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return; } final WindowManagerPolicy.StartingSurface surface; final StartingSurfaceController.StartingSurface surface; final StartingData startingData = mStartingData; if (mStartingData != null) { surface = mStartingSurface; Loading Loading @@ -2427,13 +2377,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } }; if (StartingSurfaceController.DEBUG_ENABLE_SHELL_DRAWER) { removeSurface.run(); } else { // Use the same thread to remove the window as we used to add it, as otherwise we end up // with things in the view hierarchy being called from different threads. mWmService.mAnimationHandler.post(removeSurface); } } /** Loading Loading @@ -6540,9 +6484,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return; } final CompatibilityInfo compatInfo = mAtmService.compatibilityInfoForPackageLocked(info.applicationInfo); mSplashScreenStyleEmpty = shouldUseEmptySplashScreen(sourceRecord, startActivity); final int splashScreenTheme = startActivity ? getSplashscreenTheme() : 0; Loading @@ -6557,7 +6498,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A && task.getActivity((r) -> !r.finishing && r != this) == null; final boolean scheduled = addStartingWindow(packageName, resolvedTheme, compatInfo, nonLocalizedLabel, labelRes, icon, logo, windowFlags, prev, newTask || newSingleActivity, taskSwitch, isProcessRunning(), allowTaskSnapshot(), activityCreated, mSplashScreenStyleEmpty, allDrawn); if (DEBUG_STARTING_WINDOW_VERBOSE && scheduled) { Loading services/core/java/com/android/server/wm/SnapshotStartingData.java +1 −1 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
services/core/java/com/android/server/policy/PhoneWindowManager.java +1 −196 Original line number Diff line number Diff line Loading @@ -21,15 +21,12 @@ import static android.Manifest.permission.SYSTEM_ALERT_WINDOW; import static android.Manifest.permission.SYSTEM_APPLICATION_OVERLAY; import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW; import static android.app.AppOpsManager.OP_TOAST_WINDOW; import static android.content.Context.CONTEXT_RESTRICTED; import static android.content.Context.WINDOW_SERVICE; import static android.content.pm.PackageManager.FEATURE_AUTOMOTIVE; import static android.content.pm.PackageManager.FEATURE_HDMI_CEC; import static android.content.pm.PackageManager.FEATURE_LEANBACK; import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE; import static android.content.pm.PackageManager.FEATURE_WATCH; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.content.res.Configuration.EMPTY; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.O; import static android.provider.Settings.Secure.VOLUME_HUSH_OFF; Loading @@ -47,7 +44,6 @@ import static android.view.KeyEvent.KEYCODE_VOLUME_UP; import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.LAST_SYSTEM_WINDOW; Loading Loading @@ -117,13 +113,10 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.database.ContentObserver; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManagerInternal; import android.hardware.hdmi.HdmiAudioSystemClient; Loading Loading @@ -182,7 +175,6 @@ import android.view.KeyCharacterMap; import android.view.KeyCharacterMap.FallbackAction; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import android.view.WindowManager; import android.view.WindowManagerGlobal; Loading Loading @@ -249,9 +241,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final boolean localLOGV = false; static final boolean DEBUG_INPUT = false; static final boolean DEBUG_KEYGUARD = false; static final boolean DEBUG_SPLASH_SCREEN = false; static final boolean DEBUG_WAKEUP = false; static final boolean SHOW_SPLASH_SCREENS = true; // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. // No longer recommended for desk docks; Loading Loading @@ -2354,7 +2344,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { POWER_BUTTON_SUPPRESSION_DELAY_DEFAULT_MILLIS); if (!mContext.getResources() .getBoolean(com.android.internal.R.bool.config_volumeHushGestureEnabled)) { mRingerToggleChord = Settings.Secure.VOLUME_HUSH_OFF; mRingerToggleChord = VOLUME_HUSH_OFF; } // Configure wake gesture. Loading Loading @@ -2572,191 +2562,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { return attrs.type == TYPE_NOTIFICATION_SHADE; } /** {@inheritDoc} */ @Override public StartingSurface addSplashScreen(IBinder appToken, int userId, String packageName, int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags, Configuration overrideConfig, int displayId) { if (!SHOW_SPLASH_SCREENS) { return null; } if (packageName == null) { return null; } WindowManager wm = null; View view = null; try { Context context = mContext; if (DEBUG_SPLASH_SCREEN) Slog.d(TAG, "addSplashScreen " + packageName + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" + Integer.toHexString(theme)); // Obtain proper context to launch on the right display. final Context displayContext = getDisplayContext(context, displayId); if (displayContext == null) { // Can't show splash screen on requested display, so skip showing at all. return null; } context = displayContext; if (theme != context.getThemeResId() || labelRes != 0) { try { context = context.createPackageContextAsUser(packageName, CONTEXT_RESTRICTED, UserHandle.of(userId)); context.setTheme(theme); } catch (PackageManager.NameNotFoundException e) { Slog.w(TAG, "Failed creating package context with package name " + packageName + " for user " + userId, e); } } if (overrideConfig != null && !overrideConfig.equals(EMPTY)) { if (DEBUG_SPLASH_SCREEN) Slog.d(TAG, "addSplashScreen: creating context based" + " on overrideConfig" + overrideConfig + " for splash screen"); final Context overrideContext = context.createConfigurationContext(overrideConfig); overrideContext.setTheme(theme); final TypedArray typedArray = overrideContext.obtainStyledAttributes( com.android.internal.R.styleable.Window); final int resId = typedArray.getResourceId(R.styleable.Window_windowBackground, 0); if (resId != 0 && overrideContext.getDrawable(resId) != null) { // We want to use the windowBackground for the override context if it is // available, otherwise we use the default one to make sure a themed starting // window is displayed for the app. if (DEBUG_SPLASH_SCREEN) Slog.d(TAG, "addSplashScreen: apply overrideConfig" + overrideConfig + " to starting window resId=" + resId); context = overrideContext; } typedArray.recycle(); } final PhoneWindow win = new PhoneWindow(context); win.setIsStartingWindow(true); CharSequence label = context.getResources().getText(labelRes, null); // Only change the accessibility title if the label is localized if (label != null) { win.setTitle(label, true); } else { win.setTitle(nonLocalizedLabel, false); } win.setType( WindowManager.LayoutParams.TYPE_APPLICATION_STARTING); synchronized (mWindowManagerFuncs.getWindowManagerLock()) { // Assumes it's safe to show starting windows of launched apps while // the keyguard is being hidden. This is okay because starting windows never show // secret information. // TODO(b/113840485): Occluded may not only happen on default display if (displayId == DEFAULT_DISPLAY && isKeyguardOccluded()) { windowFlags |= FLAG_SHOW_WHEN_LOCKED; } } // Force the window flags: this is a fake window, so it is not really // touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM // flag because we do know that the next window will take input // focus, so we want to get the IME window up on top of us right away. win.setFlags( windowFlags| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, windowFlags| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); win.setDefaultIcon(icon); win.setDefaultLogo(logo); win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); final WindowManager.LayoutParams params = win.getAttributes(); params.token = appToken; params.packageName = packageName; params.windowAnimations = win.getWindowStyle().getResourceId( com.android.internal.R.styleable.Window_windowAnimationStyle, 0); params.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS; // Setting as trusted overlay to let touches pass through. This is safe because this // window is controlled by the system. params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY; if (!compatInfo.supportsScreen()) { params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW; } params.setTitle("Splash Screen " + packageName); addSplashscreenContent(win, context); wm = (WindowManager) context.getSystemService(WINDOW_SERVICE); view = win.getDecorView(); if (DEBUG_SPLASH_SCREEN) Slog.d(TAG, "Adding splash screen window for " + packageName + " / " + appToken + ": " + (view.getParent() != null ? view : null)); wm.addView(view, params); // Only return the view if it was successfully added to the // window manager... which we can tell by it having a parent. return view.getParent() != null ? new SplashScreenSurface(view, appToken) : null; } catch (WindowManager.BadTokenException e) { // ignore Log.w(TAG, appToken + " already running, starting window not displayed. " + e.getMessage()); } catch (RuntimeException e) { // don't crash if something else bad happens, for example a // failure loading resources because we are loading from an app // on external storage that has been unmounted. Log.w(TAG, appToken + " failed creating starting window", e); } finally { if (view != null && view.getParent() == null) { Log.w(TAG, "view not successfully added to wm, removing view"); wm.removeViewImmediate(view); } } return null; } private void addSplashscreenContent(PhoneWindow win, Context ctx) { final TypedArray a = ctx.obtainStyledAttributes(R.styleable.Window); final int resId = a.getResourceId(R.styleable.Window_windowSplashscreenContent, 0); a.recycle(); if (resId == 0) { return; } final Drawable drawable = ctx.getDrawable(resId); if (drawable == null) { return; } // We wrap this into a view so the system insets get applied to the drawable. final View v = new View(ctx); v.setBackground(drawable); win.setContentView(v); } /** Obtain proper context for showing splash screen on the provided display. */ private Context getDisplayContext(Context context, int displayId) { if (displayId == DEFAULT_DISPLAY) { // The default context fits. return context; } final Display targetDisplay = mDisplayManager.getDisplay(displayId); if (targetDisplay == null) { // Failed to obtain the non-default display where splash screen should be shown, // lets not show at all. return null; } return context.createDisplayContext(targetDisplay); } @Override public Animation createHiddenByKeyguardExit(boolean onWallpaper, boolean goingToNotificationShade, boolean subtleAnimation) { Loading
services/core/java/com/android/server/policy/SplashScreenSurface.javadeleted 100644 → 0 +0 −55 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.server.policy; import static com.android.server.policy.PhoneWindowManager.DEBUG_SPLASH_SCREEN; import android.os.Debug; import android.os.IBinder; import android.util.Slog; import android.view.View; import android.view.WindowManager; import com.android.internal.policy.DecorView; import com.android.internal.policy.PhoneWindow; import com.android.server.policy.WindowManagerPolicy.StartingSurface; /** * Holds the contents of a splash screen starting window, i.e. the {@link DecorView} of a * {@link PhoneWindow}. This is just a wrapper such that we can return it from * {@link WindowManagerPolicy#addSplashScreen}. */ class SplashScreenSurface implements StartingSurface { private static final String TAG = PhoneWindowManager.TAG; private final View mView; private final IBinder mAppToken; SplashScreenSurface(View view, IBinder appToken) { mView = view; mAppToken = appToken; } @Override public void remove(boolean animate) { if (DEBUG_SPLASH_SCREEN) Slog.v(TAG, "Removing splash screen window for " + mAppToken + ": " + this + " Callers=" + Debug.getCallers(4)); final WindowManager wm = mView.getContext().getSystemService(WindowManager.class); wm.removeView(mView); } }
services/core/java/com/android/server/policy/WindowManagerPolicy.java +0 −43 Original line number Diff line number Diff line Loading @@ -69,7 +69,6 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.Rect; import android.os.Bundle; Loading Loading @@ -223,21 +222,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants { boolean canShowWhenLocked(); } /** * Holds the contents of a starting window. {@link #addSplashScreen} needs to wrap the * contents of the starting window into an class implementing this interface, which then will be * held by WM and released with {@link #remove} when no longer needed. */ interface StartingSurface { /** * Removes the starting window surface. Do not hold the window manager lock when calling * this method! * @param animate Whether need to play the default exit animation for starting window. */ void remove(boolean animate); } /** * Interface for calling back in to the window manager that is private * between it and the policy. Loading Loading @@ -692,33 +676,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants { } } /** * Called when the system would like to show a UI to indicate that an * application is starting. You can use this to add a * APPLICATION_STARTING_TYPE window with the given appToken to the window * manager (using the normal window manager APIs) that will be shown until * the application displays its own window. This is called without the * window manager locked so that you can call back into it. * * @param appToken Token of the application being started. * @param packageName The name of the application package being started. * @param theme Resource defining the application's overall visual theme. * @param nonLocalizedLabel The default title label of the application if * no data is found in the resource. * @param labelRes The resource ID the application would like to use as its name. * @param icon The resource ID the application would like to use as its icon. * @param windowFlags Window layout flags. * @param overrideConfig override configuration to consider when generating * context to for resources. * @param displayId Id of the display to show the splash screen at. * * @return The starting surface. * */ StartingSurface addSplashScreen(IBinder appToken, int userId, String packageName, int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags, Configuration overrideConfig, int displayId); /** * Create and return an animation to re-display a window that was force hidden by Keyguard. */ Loading
services/core/java/com/android/server/wm/ActivityRecord.java +9 −69 Original line number Diff line number Diff line Loading @@ -103,7 +103,6 @@ import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; import static android.view.SurfaceControl.getGlobalTransaction; import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; Loading Loading @@ -333,7 +332,6 @@ import com.android.server.am.AppTimeTracker; import com.android.server.am.PendingIntentRecord; import com.android.server.contentcapture.ContentCaptureManagerInternal; import com.android.server.display.color.ColorDisplayService; import com.android.server.policy.WindowManagerPolicy; import com.android.server.uri.NeededUriGrants; import com.android.server.uri.UriPermissionOwner; import com.android.server.wm.ActivityMetricsLogger.TransitionInfoSnapshot; Loading Loading @@ -451,9 +449,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A private CharSequence nonLocalizedLabel; // the label information from the package mgr. private int labelRes; // the label information from the package mgr. private int icon; // resource identifier of activity's icon. private int logo; // resource identifier of activity's logo. private int theme; // resource identifier of activity's theme. private int windowFlags; // custom window flags for preview window. private Task task; // the task this is in. private long createTime = System.currentTimeMillis(); long lastVisibleTime; // last time this activity became visible Loading Loading @@ -735,7 +731,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // Note: these are de-referenced before the starting window animates away. StartingData mStartingData; WindowState mStartingWindow; WindowManagerPolicy.StartingSurface mStartingSurface; StartingSurfaceController.StartingSurface mStartingSurface; boolean startingDisplayed; boolean startingMoved; Loading Loading @@ -1742,11 +1738,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A labelRes = app.labelRes; } icon = aInfo.getIconResource(); logo = aInfo.getLogoResource(); theme = aInfo.getThemeResource(); if ((aInfo.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0) { windowFlags |= LayoutParams.FLAG_HARDWARE_ACCELERATED; } if ((aInfo.flags & FLAG_MULTIPROCESS) != 0 && _caller != null && (aInfo.applicationInfo.uid == SYSTEM_UID || aInfo.applicationInfo.uid == _caller.mInfo.uid)) { Loading Loading @@ -1979,33 +1971,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return true; } private void applyStartingWindowTheme(String pkg, int theme) { if (theme != 0) { AttributeCache.Entry ent = AttributeCache.instance().get(pkg, theme, com.android.internal.R.styleable.Window, mWmService.mCurrentUserId); if (ent == null) { return; } final boolean windowShowWallpaper = ent.array.getBoolean( com.android.internal.R.styleable.Window_windowShowWallpaper, false); if (windowShowWallpaper && getDisplayContent().mWallpaperController .getWallpaperTarget() == null) { // If this theme is requesting a wallpaper, and the wallpaper // is not currently visible, then this effectively serves as // an opaque window and our starting window transition animation // can still work. We just need to make sure the starting window // is also showing the wallpaper. windowFlags |= FLAG_SHOW_WALLPAPER; } } } @VisibleForTesting boolean addStartingWindow(String pkg, int resolvedTheme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags, ActivityRecord from, boolean newTask, boolean taskSwitch, boolean processRunning, boolean allowTaskSnapshot, boolean activityCreated, boolean useEmpty, boolean addStartingWindow(String pkg, int resolvedTheme, ActivityRecord from, boolean newTask, boolean taskSwitch, boolean processRunning, boolean allowTaskSnapshot, boolean activityCreated, boolean useEmpty, boolean activityAllDrawn) { // If the display is frozen, we won't do anything until the actual window is // displayed so there is no reason to put in the starting window. Loading Loading @@ -2062,7 +2031,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (resolvedTheme == 0 && theme != 0) { return false; } applyStartingWindowTheme(pkg, resolvedTheme); if (from != null && transferStartingWindow(from)) { return true; Loading @@ -2075,9 +2043,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "Creating SplashScreenStartingData"); mStartingData = new SplashScreenStartingData(mWmService, pkg, resolvedTheme, compatInfo, nonLocalizedLabel, labelRes, icon, logo, windowFlags, getMergedOverrideConfiguration(), typeParameter); mStartingData = new SplashScreenStartingData(mWmService, resolvedTheme, typeParameter); scheduleAddStartingWindow(); return true; } Loading @@ -2099,17 +2065,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } void scheduleAddStartingWindow() { if (StartingSurfaceController.DEBUG_ENABLE_SHELL_DRAWER) { mAddStartingWindow.run(); } else { // Note: we really want to do sendMessageAtFrontOfQueue() because we // want to process the message ASAP, before any other queued // messages. if (!mWmService.mAnimationHandler.hasCallbacks(mAddStartingWindow)) { ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "Enqueueing ADD_STARTING"); mWmService.mAnimationHandler.postAtFrontOfQueue(mAddStartingWindow); } } } private class AddStartingWindow implements Runnable { Loading @@ -2120,9 +2076,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final StartingData startingData; synchronized (mWmService.mGlobalLock) { // There can only be one adding request, silly caller! if (!StartingSurfaceController.DEBUG_ENABLE_SHELL_DRAWER) { mWmService.mAnimationHandler.removeCallbacks(this); } if (mStartingData == null) { // Animation has been canceled... do nothing. Loading @@ -2137,7 +2090,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "Add starting %s: startingData=%s", this, startingData); WindowManagerPolicy.StartingSurface surface = null; StartingSurfaceController.StartingSurface surface = null; try { surface = startingData.createStartingSurface(ActivityRecord.this); } catch (Exception e) { Loading Loading @@ -2250,9 +2203,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } private boolean transferSplashScreenIfNeeded() { if (!mWmService.mStartingSurfaceController.DEBUG_ENABLE_SHELL_DRAWER) { return false; } if (!mHandleExitSplashScreen || mStartingSurface == null || mStartingWindow == null || mTransferringSplashScreenState == TRANSFER_SPLASH_SCREEN_FINISH) { return false; Loading Loading @@ -2393,7 +2343,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return; } final WindowManagerPolicy.StartingSurface surface; final StartingSurfaceController.StartingSurface surface; final StartingData startingData = mStartingData; if (mStartingData != null) { surface = mStartingSurface; Loading Loading @@ -2427,13 +2377,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } }; if (StartingSurfaceController.DEBUG_ENABLE_SHELL_DRAWER) { removeSurface.run(); } else { // Use the same thread to remove the window as we used to add it, as otherwise we end up // with things in the view hierarchy being called from different threads. mWmService.mAnimationHandler.post(removeSurface); } } /** Loading Loading @@ -6540,9 +6484,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return; } final CompatibilityInfo compatInfo = mAtmService.compatibilityInfoForPackageLocked(info.applicationInfo); mSplashScreenStyleEmpty = shouldUseEmptySplashScreen(sourceRecord, startActivity); final int splashScreenTheme = startActivity ? getSplashscreenTheme() : 0; Loading @@ -6557,7 +6498,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A && task.getActivity((r) -> !r.finishing && r != this) == null; final boolean scheduled = addStartingWindow(packageName, resolvedTheme, compatInfo, nonLocalizedLabel, labelRes, icon, logo, windowFlags, prev, newTask || newSingleActivity, taskSwitch, isProcessRunning(), allowTaskSnapshot(), activityCreated, mSplashScreenStyleEmpty, allDrawn); if (DEBUG_STARTING_WINDOW_VERBOSE && scheduled) { Loading
services/core/java/com/android/server/wm/SnapshotStartingData.java +1 −1 File changed.Preview size limit exceeded, changes collapsed. Show changes