diff options
Diffstat (limited to 'services/java')
10 files changed, 293 insertions, 200 deletions
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index 37dae35..c26448f 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -210,7 +210,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run mBlacklist = new LocationBlacklist(mContext, mLocationHandler); mBlacklist.init(); - mLocationFudger = new LocationFudger(); + mLocationFudger = new LocationFudger(mContext, mLocationHandler); synchronized (mLock) { loadProvidersLocked(); diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 4398441..90783b7 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -55,6 +55,7 @@ import com.android.server.display.DisplayManagerService; import com.android.server.input.InputManagerService; import com.android.server.net.NetworkPolicyManagerService; import com.android.server.net.NetworkStatsService; +import com.android.server.pm.Installer; import com.android.server.pm.PackageManagerService; import com.android.server.pm.UserManagerService; import com.android.server.power.PowerManagerService; @@ -117,6 +118,7 @@ class ServerThread extends Thread { : Integer.parseInt(factoryTestStr); final boolean headless = "1".equals(SystemProperties.get("ro.config.headless", "0")); + Installer installer = null; AccountManagerService accountManager = null; ContentService contentService = null; LightsService lights = null; @@ -195,6 +197,13 @@ class ServerThread extends Thread { // Critical services... boolean onlyCore = false; try { + // Wait for installd to finished starting up so that it has a chance to + // create critical directories such as /data/user with the appropriate + // permissions. We need this to complete before we initialize other services. + Slog.i(TAG, "Waiting for installd to be ready."); + installer = new Installer(); + installer.ping(); + Slog.i(TAG, "Entropy Mixer"); ServiceManager.addService("entropy", new EntropyMixer()); @@ -234,7 +243,7 @@ class ServerThread extends Thread { onlyCore = true; } - pm = PackageManagerService.main(context, + pm = PackageManagerService.main(context, installer, factoryTest != SystemServer.FACTORY_TEST_OFF, onlyCore); boolean firstBoot = false; diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java index f6354bb..99ec1d2 100644 --- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -682,11 +682,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { for (int i = 0, count = installedServices.size(); i < count; i++) { ResolveInfo resolveInfo = installedServices.get(i); ServiceInfo serviceInfo = resolveInfo.serviceInfo; - // For now we are enforcing this if the target version is JellyBean or - // higher and in a later release we will enforce this for everyone. - if (serviceInfo.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.JELLY_BEAN - && !android.Manifest.permission.BIND_ACCESSIBILITY_SERVICE.equals( - serviceInfo.permission)) { + if (!android.Manifest.permission.BIND_ACCESSIBILITY_SERVICE.equals(serviceInfo.permission)) { Slog.w(LOG_TAG, "Skipping accessibilty service " + new ComponentName( serviceInfo.packageName, serviceInfo.name).flattenToShortString() + ": it does not require the permission " diff --git a/services/java/com/android/server/am/ActiveServices.java b/services/java/com/android/server/am/ActiveServices.java index 3bb95a8..aefc264 100644 --- a/services/java/com/android/server/am/ActiveServices.java +++ b/services/java/com/android/server/am/ActiveServices.java @@ -478,12 +478,6 @@ public class ActiveServices { if (res.record == null) { return -1; } - if (mAm.isSingleton(res.record.processName, res.record.appInfo, - res.record.serviceInfo.name, res.record.serviceInfo.flags)) { - userId = 0; - res = retrieveServiceLocked(service, resolvedType, Binder.getCallingPid(), - Binder.getCallingUid(), 0, true); - } ServiceRecord s = res.record; final long origId = Binder.clearCallingIdentity(); diff --git a/services/java/com/android/server/location/LocationFudger.java b/services/java/com/android/server/location/LocationFudger.java index 57bc1c5..84fd255 100644 --- a/services/java/com/android/server/location/LocationFudger.java +++ b/services/java/com/android/server/location/LocationFudger.java @@ -19,10 +19,14 @@ package com.android.server.location; import java.io.FileDescriptor; import java.io.PrintWriter; import java.security.SecureRandom; +import android.content.Context; +import android.database.ContentObserver; import android.location.Location; import android.os.Bundle; +import android.os.Handler; import android.os.Parcelable; import android.os.SystemClock; +import android.provider.Settings; import android.util.Log; @@ -39,22 +43,19 @@ public class LocationFudger { private static final String EXTRA_COARSE_LOCATION = "coarseLocation"; /** - * This is the main control: Best location accuracy allowed for coarse applications. + * Default coarse accuracy in meters. */ - private static final float ACCURACY_METERS = 200.0f; + private static final float DEFAULT_ACCURACY_IN_METERS = 2000.0f; /** - * The distance between grids for snap-to-grid. See {@link #createCoarse}. + * Minimum coarse accuracy in meters. */ - private static final double GRID_SIZE_METERS = ACCURACY_METERS; + private static final float MINIMUM_ACCURACY_IN_METERS = 200.0f; /** - * Standard deviation of the (normally distributed) random offset applied - * to coarse locations. It does not need to be as large as - * {@link #COARSE_ACCURACY_METERS} because snap-to-grid is the primary obfuscation - * method. See further details in the implementation. + * Secure settings key for coarse accuracy. */ - private static final double STANDARD_DEVIATION_METERS = GRID_SIZE_METERS / 4.0; + private static final String COARSE_ACCURACY_CONFIG_NAME = "locationCoarseAccuracy"; /** * This is the fastest interval that applications can receive coarse @@ -106,43 +107,90 @@ public class LocationFudger { private final Object mLock = new Object(); private final SecureRandom mRandom = new SecureRandom(); + /** + * Used to monitor coarse accuracy secure setting for changes. + */ + private final ContentObserver mSettingsObserver; + + /** + * Used to resolve coarse accuracy setting. + */ + private final Context mContext; + // all fields below protected by mLock private double mOffsetLatitudeMeters; private double mOffsetLongitudeMeters; private long mNextInterval; - public LocationFudger() { - mOffsetLatitudeMeters = nextOffset(); - mOffsetLongitudeMeters = nextOffset(); - mNextInterval = SystemClock.elapsedRealtime() + CHANGE_INTERVAL_MS; + /** + * Best location accuracy allowed for coarse applications. + * This value should only be set by {@link #setAccuracyInMetersLocked(float)}. + */ + private float mAccuracyInMeters; + + /** + * The distance between grids for snap-to-grid. See {@link #createCoarse}. + * This value should only be set by {@link #setAccuracyInMetersLocked(float)}. + */ + private double mGridSizeInMeters; + + /** + * Standard deviation of the (normally distributed) random offset applied + * to coarse locations. It does not need to be as large as + * {@link #COARSE_ACCURACY_METERS} because snap-to-grid is the primary obfuscation + * method. See further details in the implementation. + * This value should only be set by {@link #setAccuracyInMetersLocked(float)}. + */ + private double mStandardDeviationInMeters; + + public LocationFudger(Context context, Handler handler) { + mContext = context; + mSettingsObserver = new ContentObserver(handler) { + @Override + public void onChange(boolean selfChange) { + setAccuracyInMeters(loadCoarseAccuracy()); + } + }; + mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor( + COARSE_ACCURACY_CONFIG_NAME), false, mSettingsObserver); + + float accuracy = loadCoarseAccuracy(); + synchronized (mLock) { + setAccuracyInMetersLocked(accuracy); + mOffsetLatitudeMeters = nextOffsetLocked(); + mOffsetLongitudeMeters = nextOffsetLocked(); + mNextInterval = SystemClock.elapsedRealtime() + CHANGE_INTERVAL_MS; + } } /** * Get the cached coarse location, or generate a new one and cache it. */ public Location getOrCreate(Location location) { - Bundle extras = location.getExtras(); - if (extras == null) { - return addCoarseLocationExtra(location); - } - Parcelable parcel = extras.getParcelable(EXTRA_COARSE_LOCATION); - if (parcel == null) { - return addCoarseLocationExtra(location); - } - if (!(parcel instanceof Location)) { - return addCoarseLocationExtra(location); - } - Location coarse = (Location) parcel; - if (coarse.getAccuracy() < ACCURACY_METERS) { - return addCoarseLocationExtra(location); + synchronized (mLock) { + Bundle extras = location.getExtras(); + if (extras == null) { + return addCoarseLocationExtraLocked(location); + } + Parcelable parcel = extras.getParcelable(EXTRA_COARSE_LOCATION); + if (parcel == null) { + return addCoarseLocationExtraLocked(location); + } + if (!(parcel instanceof Location)) { + return addCoarseLocationExtraLocked(location); + } + Location coarse = (Location) parcel; + if (coarse.getAccuracy() < mAccuracyInMeters) { + return addCoarseLocationExtraLocked(location); + } + return coarse; } - return coarse; } - private Location addCoarseLocationExtra(Location location) { + private Location addCoarseLocationExtraLocked(Location location) { Bundle extras = location.getExtras(); if (extras == null) extras = new Bundle(); - Location coarse = createCoarse(location); + Location coarse = createCoarseLocked(location); extras.putParcelable(EXTRA_COARSE_LOCATION, coarse); location.setExtras(extras); return coarse; @@ -163,7 +211,7 @@ public class LocationFudger { * producing stable results, and mitigating against taking many samples * to average out a random offset. */ - private Location createCoarse(Location fine) { + private Location createCoarseLocked(Location fine) { Location coarse = new Location(fine); // clean all the optional information off the location, because @@ -188,14 +236,12 @@ public class LocationFudger { // // We apply the offset even if the location already claims to be // inaccurate, because it may be more accurate than claimed. - synchronized (mLock) { - updateRandomOffsetLocked(); - // perform lon first whilst lat is still within bounds - lon += metersToDegreesLongitude(mOffsetLongitudeMeters, lat); - lat += metersToDegreesLatitude(mOffsetLatitudeMeters); - if (D) Log.d(TAG, String.format("applied offset of %.0f, %.0f (meters)", - mOffsetLongitudeMeters, mOffsetLatitudeMeters)); - } + updateRandomOffsetLocked(); + // perform lon first whilst lat is still within bounds + lon += metersToDegreesLongitude(mOffsetLongitudeMeters, lat); + lat += metersToDegreesLatitude(mOffsetLatitudeMeters); + if (D) Log.d(TAG, String.format("applied offset of %.0f, %.0f (meters)", + mOffsetLongitudeMeters, mOffsetLatitudeMeters)); // wrap lat = wrapLatitude(lat); @@ -211,9 +257,9 @@ public class LocationFudger { // Note we quantize the latitude first, since the longitude // quantization depends on the latitude value and so leaks information // about the latitude - double latGranularity = metersToDegreesLatitude(GRID_SIZE_METERS); + double latGranularity = metersToDegreesLatitude(mGridSizeInMeters); lat = Math.round(lat / latGranularity) * latGranularity; - double lonGranularity = metersToDegreesLongitude(GRID_SIZE_METERS, lat); + double lonGranularity = metersToDegreesLongitude(mGridSizeInMeters, lat); lon = Math.round(lon / lonGranularity) * lonGranularity; // wrap again @@ -223,7 +269,7 @@ public class LocationFudger { // apply coarse.setLatitude(lat); coarse.setLongitude(lon); - coarse.setAccuracy(Math.max(ACCURACY_METERS, coarse.getAccuracy())); + coarse.setAccuracy(Math.max(mAccuracyInMeters, coarse.getAccuracy())); if (D) Log.d(TAG, "fudged " + fine + " to " + coarse); return coarse; @@ -259,16 +305,16 @@ public class LocationFudger { mNextInterval = now + CHANGE_INTERVAL_MS; mOffsetLatitudeMeters *= PREVIOUS_WEIGHT; - mOffsetLatitudeMeters += NEW_WEIGHT * nextOffset(); + mOffsetLatitudeMeters += NEW_WEIGHT * nextOffsetLocked(); mOffsetLongitudeMeters *= PREVIOUS_WEIGHT; - mOffsetLongitudeMeters += NEW_WEIGHT * nextOffset(); + mOffsetLongitudeMeters += NEW_WEIGHT * nextOffsetLocked(); if (D) Log.d(TAG, String.format("new offset: %.0f, %.0f (meters)", mOffsetLongitudeMeters, mOffsetLatitudeMeters)); } - private double nextOffset() { - return mRandom.nextGaussian() * STANDARD_DEVIATION_METERS; + private double nextOffsetLocked() { + return mRandom.nextGaussian() * mStandardDeviationInMeters; } private static double wrapLatitude(double lat) { @@ -307,4 +353,45 @@ public class LocationFudger { pw.println(String.format("offset: %.0f, %.0f (meters)", mOffsetLongitudeMeters, mOffsetLatitudeMeters)); } + + /** + * This is the main control: call this to set the best location accuracy + * allowed for coarse applications and all derived values. + */ + private void setAccuracyInMetersLocked(float accuracyInMeters) { + mAccuracyInMeters = Math.max(accuracyInMeters, MINIMUM_ACCURACY_IN_METERS); + if (D) { + Log.d(TAG, "setAccuracyInMetersLocked: new accuracy = " + mAccuracyInMeters); + } + mGridSizeInMeters = mAccuracyInMeters; + mStandardDeviationInMeters = mGridSizeInMeters / 4.0; + } + + /** + * Same as setAccuracyInMetersLocked without the pre-lock requirement. + */ + private void setAccuracyInMeters(float accuracyInMeters) { + synchronized (mLock) { + setAccuracyInMetersLocked(accuracyInMeters); + } + } + + /** + * Loads the coarse accuracy value from secure settings. + */ + private float loadCoarseAccuracy() { + String newSetting = Settings.Secure.getString(mContext.getContentResolver(), + COARSE_ACCURACY_CONFIG_NAME); + if (D) { + Log.d(TAG, "loadCoarseAccuracy: newSetting = \"" + newSetting + "\""); + } + if (newSetting == null) { + return DEFAULT_ACCURACY_IN_METERS; + } + try { + return Float.parseFloat(newSetting); + } catch (NumberFormatException e) { + return DEFAULT_ACCURACY_IN_METERS; + } + } } diff --git a/services/java/com/android/server/pm/Installer.java b/services/java/com/android/server/pm/Installer.java index 85de349..ad85c0d 100644 --- a/services/java/com/android/server/pm/Installer.java +++ b/services/java/com/android/server/pm/Installer.java @@ -25,7 +25,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -class Installer { +public final class Installer { private static final String TAG = "Installer"; private static final boolean LOCAL_DEBUG = false; diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index 8ce474a..ba63efd 100644 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -215,7 +215,7 @@ public class PackageManagerService extends IPackageManager.Stub { /** * Whether verification is enabled by default. */ - private static final boolean DEFAULT_VERIFY_ENABLE = true; + private static final boolean DEFAULT_VERIFY_ENABLE = false; /** * The default maximum time to wait for the verification agent to return in @@ -937,9 +937,10 @@ public class PackageManagerService extends IPackageManager.Stub { } } - public static final IPackageManager main(Context context, boolean factoryTest, - boolean onlyCore) { - PackageManagerService m = new PackageManagerService(context, factoryTest, onlyCore); + public static final IPackageManager main(Context context, Installer installer, + boolean factoryTest, boolean onlyCore) { + PackageManagerService m = new PackageManagerService(context, installer, + factoryTest, onlyCore); ServiceManager.addService("package", m); return m; } @@ -966,7 +967,8 @@ public class PackageManagerService extends IPackageManager.Stub { return res; } - public PackageManagerService(Context context, boolean factoryTest, boolean onlyCore) { + public PackageManagerService(Context context, Installer installer, + boolean factoryTest, boolean onlyCore) { EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_START, SystemClock.uptimeMillis()); @@ -1004,7 +1006,7 @@ public class PackageManagerService extends IPackageManager.Stub { mSeparateProcesses = null; } - mInstaller = new Installer(); + mInstaller = installer; WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); Display d = wm.getDefaultDisplay(); diff --git a/services/java/com/android/server/wm/DragState.java b/services/java/com/android/server/wm/DragState.java index dc52fcf..545fce5 100644 --- a/services/java/com/android/server/wm/DragState.java +++ b/services/java/com/android/server/wm/DragState.java @@ -189,7 +189,7 @@ class DragState { Slog.d(WindowManagerService.TAG, "broadcasting DRAG_STARTED at (" + touchX + ", " + touchY + ")"); } - final WindowList windows = mService.getWindowList(mDisplay); + final WindowList windows = mService.getWindowListLocked(mDisplay); final int N = windows.size(); for (int i = 0; i < N; i++) { sendDragStartedLw(windows.get(i), touchX, touchY, mDataDescription); @@ -392,7 +392,7 @@ class DragState { final int x = (int) xf; final int y = (int) yf; - final WindowList windows = mService.getWindowList(mDisplay); + final WindowList windows = mService.getWindowListLocked(mDisplay); final int N = windows.size(); for (int i = N - 1; i >= 0; i--) { WindowState child = windows.get(i); diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index b1e4f4b..dd98007 100755 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -610,11 +610,11 @@ public class WindowManagerService extends IWindowManager.Stub public AppWindowAnimParams(final AppWindowAnimator appAnimator) { mAppAnimator = appAnimator; - final AppWindowToken wtoken = appAnimator.mAppToken; + final AppWindowToken atoken = appAnimator.mAppToken; mWinAnimators = new ArrayList<WindowStateAnimator>(); - final int N = wtoken.allAppWindows.size(); + final int N = atoken.allAppWindows.size(); for (int i = 0; i < N; i++) { - mWinAnimators.add(wtoken.allAppWindows.get(i).mWinAnimator); + mWinAnimators.add(atoken.allAppWindows.get(i).mWinAnimator); } } } @@ -788,7 +788,7 @@ public class WindowManagerService extends IWindowManager.Stub mDisplayManager.registerDisplayListener(this, null); Display[] displays = mDisplayManager.getDisplays(); for (Display display : displays) { - createDisplayContent(display); + createDisplayContentLocked(display); } mKeyguardDisableHandler = new KeyguardDisableHandler(mContext, mPolicy); @@ -1166,7 +1166,7 @@ public class WindowManagerService extends IWindowManager.Stub // TODO(multidisplay): Needs some serious rethought when the target and IME are not on the // same display. Or even when the current IME/target are not on the same screen as the next // IME/target. For now only look for input windows on the main screen. - WindowList windows = getDefaultWindowList(); + WindowList windows = getDefaultWindowListLocked(); final int N = windows.size(); WindowState w = null; int i = N; @@ -1308,7 +1308,7 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v( TAG, "Adding input method window " + win + " at " + pos); // TODO(multidisplay): IMEs are only supported on the default display. - getDefaultWindowList().add(pos, win); + getDefaultWindowListLocked().add(pos, win); mWindowsChanged = true; moveInputMethodDialogsLocked(pos+1); return; @@ -1396,7 +1396,7 @@ public class WindowManagerService extends IWindowManager.Stub ArrayList<WindowState> dialogs = mInputMethodDialogs; // TODO(multidisplay): IMEs are only supported on the default display. - WindowList windows = getDefaultWindowList(); + WindowList windows = getDefaultWindowListLocked(); final int N = dialogs.size(); if (DEBUG_INPUT_METHOD) Slog.v(TAG, "Removing " + N + " dialogs w/pos=" + pos); for (int i=0; i<N; i++) { @@ -1446,7 +1446,7 @@ public class WindowManagerService extends IWindowManager.Stub } // TODO(multidisplay): IMEs are only supported on the default display. - WindowList windows = getDefaultWindowList(); + WindowList windows = getDefaultWindowListLocked(); int imPos = findDesiredInputMethodWindowIndexLocked(true); if (imPos >= 0) { @@ -1566,13 +1566,13 @@ public class WindowManagerService extends IWindowManager.Stub int changed = 0; // TODO(multidisplay): Wallpapers on main screen only. - final DisplayInfo displayInfo = getDefaultDisplayContent().getDisplayInfo(); + final DisplayInfo displayInfo = getDefaultDisplayContentLocked().getDisplayInfo(); final int dw = displayInfo.appWidth; final int dh = displayInfo.appHeight; // First find top-most window that has asked to be on top of the // wallpaper; all wallpapers go behind it. - final WindowList windows = getDefaultWindowList(); + final WindowList windows = getDefaultWindowListLocked(); int N = windows.size(); WindowState w = null; WindowState foundW = null; @@ -1812,7 +1812,7 @@ public class WindowManagerService extends IWindowManager.Stub token.hidden = !visible; // Need to do a layout to ensure the wallpaper now has the // correct size. - getDefaultDisplayContent().layoutNeeded = true; + getDefaultDisplayContentLocked().layoutNeeded = true; } int curWallpaperIndex = token.windows.size(); @@ -2055,7 +2055,7 @@ public class WindowManagerService extends IWindowManager.Stub token.hidden = !visible; // Need to do a layout to ensure the wallpaper now has the // correct size. - getDefaultDisplayContent().layoutNeeded = true; + getDefaultDisplayContentLocked().layoutNeeded = true; } int curWallpaperIndex = token.windows.size(); @@ -2173,7 +2173,7 @@ public class WindowManagerService extends IWindowManager.Stub } } - final DisplayContent displayContent = getDisplayContent(displayId); + final DisplayContent displayContent = getDisplayContentLocked(displayId); win = new WindowState(this, session, client, token, attachedWindow, seq, attrs, viewVisibility, displayContent); if (win.mDeathRecipient == null) { @@ -2668,7 +2668,7 @@ public class WindowManagerService extends IWindowManager.Stub boolean immediate) { RemoteCallbackList<IDisplayContentChangeListener> callbacks = null; synchronized (mWindowMap) { - DisplayContent displayContent = getDisplayContent(displayId); + DisplayContent displayContent = getDisplayContentLocked(displayId); if (displayContent == null) { return; } @@ -2966,7 +2966,7 @@ public class WindowManagerService extends IWindowManager.Stub configChanged = updateOrientationFromAppTokensLocked(false); performLayoutAndPlaceSurfacesLocked(); if (toBeDisplayed && win.mIsWallpaper) { - DisplayInfo displayInfo = getDefaultDisplayInfo(); + DisplayInfo displayInfo = getDefaultDisplayInfoLocked(); updateWallpaperOffsetLocked(win, displayInfo.appWidth, displayInfo.appHeight, false); } @@ -3089,7 +3089,7 @@ public class WindowManagerService extends IWindowManager.Stub throw new SecurityException("Requires RETRIEVE_WINDOW_INFO permission."); } synchronized (mWindowMap) { - DisplayContent displayContent = getDisplayContent(displayId); + DisplayContent displayContent = getDisplayContentLocked(displayId); if (displayContent == null) { return; } @@ -3106,6 +3106,7 @@ public class WindowManagerService extends IWindowManager.Stub } } + @Override public void magnifyDisplay(int displayId, float scale, float offsetX, float offsetY) { if (!checkCallingPermission( android.Manifest.permission.MAGNIFY_DISPLAY, "magnifyDisplay()")) { @@ -3134,7 +3135,7 @@ public class WindowManagerService extends IWindowManager.Stub } MagnificationSpec getDisplayMagnificationSpecLocked(int displayId) { - DisplayContent displayContent = getDisplayContent(displayId); + DisplayContent displayContent = getDisplayContentLocked(displayId); if (displayContent != null) { if (displayContent.mMagnificationSpec == null) { displayContent.mMagnificationSpec = new MagnificationSpec(); @@ -3280,7 +3281,7 @@ public class WindowManagerService extends IWindowManager.Stub break; } // TODO(multidisplay): For now assume all app animation is on main display. - final DisplayInfo displayInfo = getDefaultDisplayInfo(); + final DisplayInfo displayInfo = getDefaultDisplayInfoLocked(); if (enter) { // Entering app zooms out from the center of the initial rect. float scaleW = mNextAppTransitionStartWidth / (float) displayInfo.appWidth; @@ -3331,7 +3332,7 @@ public class WindowManagerService extends IWindowManager.Stub break; } // TOOD(multidisplay): For now assume all app animation is on the main screen. - DisplayInfo displayInfo = getDefaultDisplayInfo(); + DisplayInfo displayInfo = getDefaultDisplayInfoLocked(); if (thumb) { // Animation for zooming thumbnail from its initial size to // filling the screen. @@ -3426,7 +3427,7 @@ public class WindowManagerService extends IWindowManager.Stub return a; } - private boolean applyAnimationLocked(AppWindowToken wtoken, + private boolean applyAnimationLocked(AppWindowToken atoken, WindowManager.LayoutParams lp, int transit, boolean enter) { // Only apply an animation if the display isn't frozen. If it is // frozen, there is no reason to animate and it can cause strange @@ -3439,14 +3440,14 @@ public class WindowManagerService extends IWindowManager.Stub a = loadAnimation(mNextAppTransitionPackage, enter ? mNextAppTransitionEnter : mNextAppTransitionExit); if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, - "applyAnimation: wtoken=" + wtoken + "applyAnimation: atoken=" + atoken + " anim=" + a + " nextAppTransition=ANIM_CUSTOM" + " transit=" + transit + " Callers " + Debug.getCallers(3)); } else if (mNextAppTransitionType == ActivityOptions.ANIM_SCALE_UP) { a = createScaleUpAnimationLocked(transit, enter); initialized = true; if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, - "applyAnimation: wtoken=" + wtoken + "applyAnimation: atoken=" + atoken + " anim=" + a + " nextAppTransition=ANIM_SCALE_UP" + " transit=" + transit + " Callers " + Debug.getCallers(3)); } else if (mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_SCALE_UP || @@ -3457,7 +3458,7 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) { String animName = scaleUp ? "ANIM_THUMBNAIL_SCALE_UP" : "ANIM_THUMBNAIL_SCALE_DOWN"; - Slog.v(TAG, "applyAnimation: wtoken=" + wtoken + Slog.v(TAG, "applyAnimation: atoken=" + atoken + " anim=" + a + " nextAppTransition=" + animName + " transit=" + transit + " Callers " + Debug.getCallers(3)); } @@ -3517,7 +3518,7 @@ public class WindowManagerService extends IWindowManager.Stub } a = animAttr != 0 ? loadAnimation(lp, animAttr) : null; if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, - "applyAnimation: wtoken=" + wtoken + "applyAnimation: atoken=" + atoken + " anim=" + a + " animAttr=0x" + Integer.toHexString(animAttr) + " transit=" + transit + " Callers " + Debug.getCallers(3)); @@ -3529,15 +3530,15 @@ public class WindowManagerService extends IWindowManager.Stub e = new RuntimeException(); e.fillInStackTrace(); } - Slog.v(TAG, "Loaded animation " + a + " for " + wtoken, e); + Slog.v(TAG, "Loaded animation " + a + " for " + atoken, e); } - wtoken.mAppAnimator.setAnimation(a, initialized); + atoken.mAppAnimator.setAnimation(a, initialized); } } else { - wtoken.mAppAnimator.clearAnimation(); + atoken.mAppAnimator.clearAnimation(); } - return wtoken.mAppAnimator.animation != null; + return atoken.mAppAnimator.animation != null; } // ------------------------------------------------------------- @@ -3548,14 +3549,14 @@ public class WindowManagerService extends IWindowManager.Stub int v = tokens.size()-1; int m = mAppTokens.size()-1; while (v >= 0 && m >= 0) { - AppWindowToken wtoken = mAppTokens.get(m); - if (wtoken.removed) { + AppWindowToken atoken = mAppTokens.get(m); + if (atoken.removed) { m--; continue; } - if (tokens.get(v) != wtoken.token) { + if (tokens.get(v) != atoken.token) { Slog.w(TAG, "Tokens out of sync: external is " + tokens.get(v) - + " @ " + v + ", internal is " + wtoken.token + " @ " + m); + + " @ " + v + ", internal is " + atoken.token + " @ " + m); } v--; m--; @@ -3565,9 +3566,9 @@ public class WindowManagerService extends IWindowManager.Stub v--; } while (m >= 0) { - AppWindowToken wtoken = mAppTokens.get(m); - if (!wtoken.removed) { - Slog.w(TAG, "Invalid internal token: " + wtoken.token + " @ " + m); + AppWindowToken atoken = mAppTokens.get(m); + if (!atoken.removed) { + Slog.w(TAG, "Invalid internal atoken: " + atoken.token + " @ " + m); } m--; } @@ -3686,18 +3687,18 @@ public class WindowManagerService extends IWindowManager.Stub * Find the location to insert a new AppWindowToken into the window-ordered app token list. * Note that mAppTokens.size() == mAnimatingAppTokens.size() + 1. * @param addPos The location the token was inserted into in mAppTokens. - * @param wtoken The token to insert. + * @param atoken The token to insert. */ - private void addAppTokenToAnimating(final int addPos, final AppWindowToken wtoken) { + private void addAppTokenToAnimating(final int addPos, final AppWindowToken atoken) { if (addPos == 0 || addPos == mAnimatingAppTokens.size()) { // It was inserted into the beginning or end of mAppTokens. Honor that. - mAnimatingAppTokens.add(addPos, wtoken); + mAnimatingAppTokens.add(addPos, atoken); return; } // Find the item immediately above the mAppTokens insertion point and put the token // immediately below that one in mAnimatingAppTokens. final AppWindowToken aboveAnchor = mAppTokens.get(addPos + 1); - mAnimatingAppTokens.add(mAnimatingAppTokens.indexOf(aboveAnchor), wtoken); + mAnimatingAppTokens.add(mAnimatingAppTokens.indexOf(aboveAnchor), atoken); } @Override @@ -3723,25 +3724,25 @@ public class WindowManagerService extends IWindowManager.Stub } synchronized(mWindowMap) { - AppWindowToken wtoken = findAppWindowToken(token.asBinder()); - if (wtoken != null) { + AppWindowToken atoken = findAppWindowToken(token.asBinder()); + if (atoken != null) { Slog.w(TAG, "Attempted to add existing app token: " + token); return; } - wtoken = new AppWindowToken(this, token); - wtoken.inputDispatchingTimeoutNanos = inputDispatchingTimeoutNanos; - wtoken.groupId = groupId; - wtoken.appFullscreen = fullscreen; - wtoken.requestedOrientation = requestedOrientation; - if (DEBUG_TOKEN_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, "addAppToken: " + wtoken + atoken = new AppWindowToken(this, token); + atoken.inputDispatchingTimeoutNanos = inputDispatchingTimeoutNanos; + atoken.groupId = groupId; + atoken.appFullscreen = fullscreen; + atoken.requestedOrientation = requestedOrientation; + if (DEBUG_TOKEN_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, "addAppToken: " + atoken + " at " + addPos); - mAppTokens.add(addPos, wtoken); - addAppTokenToAnimating(addPos, wtoken); - mTokenMap.put(token.asBinder(), wtoken); + mAppTokens.add(addPos, atoken); + addAppTokenToAnimating(addPos, atoken); + mTokenMap.put(token.asBinder(), atoken); // Application tokens start out hidden. - wtoken.hidden = true; - wtoken.hiddenRequested = true; + atoken.hidden = true; + atoken.hiddenRequested = true; //dump(); } @@ -3755,12 +3756,12 @@ public class WindowManagerService extends IWindowManager.Stub } synchronized(mWindowMap) { - AppWindowToken wtoken = findAppWindowToken(token); - if (wtoken == null) { + AppWindowToken atoken = findAppWindowToken(token); + if (atoken == null) { Slog.w(TAG, "Attempted to set group id of non-existing app token: " + token); return; } - wtoken.groupId = groupId; + atoken.groupId = groupId; } } @@ -3775,7 +3776,7 @@ public class WindowManagerService extends IWindowManager.Stub } // TODO(multidisplay): Change to the correct display. - final WindowList windows = getDefaultWindowList(); + final WindowList windows = getDefaultWindowListLocked(); int pos = windows.size() - 1; while (pos >= 0) { WindowState wtoken = windows.get(pos); @@ -3806,20 +3807,20 @@ public class WindowManagerService extends IWindowManager.Stub boolean haveGroup = false; boolean lastFullscreen = false; for (int pos = mAppTokens.size() - 1; pos >= 0; pos--) { - AppWindowToken wtoken = mAppTokens.get(pos); + AppWindowToken atoken = mAppTokens.get(pos); - if (DEBUG_APP_ORIENTATION) Slog.v(TAG, "Checking app orientation: " + wtoken); + if (DEBUG_APP_ORIENTATION) Slog.v(TAG, "Checking app orientation: " + atoken); // if we're about to tear down this window and not seek for // the behind activity, don't use it for orientation if (!findingBehind - && (!wtoken.hidden && wtoken.hiddenRequested)) { - if (DEBUG_ORIENTATION) Slog.v(TAG, "Skipping " + wtoken + && (!atoken.hidden && atoken.hiddenRequested)) { + if (DEBUG_ORIENTATION) Slog.v(TAG, "Skipping " + atoken + " -- going to hide"); continue; } - if (haveGroup == true && curGroup != wtoken.groupId) { + if (haveGroup == true && curGroup != atoken.groupId) { // If we have hit a new application group, and the bottom // of the previous group didn't explicitly say to use // the orientation behind it, and the last app was @@ -3827,33 +3828,33 @@ public class WindowManagerService extends IWindowManager.Stub // user's orientation. if (lastOrientation != ActivityInfo.SCREEN_ORIENTATION_BEHIND && lastFullscreen) { - if (DEBUG_ORIENTATION) Slog.v(TAG, "Done at " + wtoken + if (DEBUG_ORIENTATION) Slog.v(TAG, "Done at " + atoken + " -- end of group, return " + lastOrientation); return lastOrientation; } } // We ignore any hidden applications on the top. - if (wtoken.hiddenRequested || wtoken.willBeHidden) { - if (DEBUG_ORIENTATION) Slog.v(TAG, "Skipping " + wtoken + if (atoken.hiddenRequested || atoken.willBeHidden) { + if (DEBUG_ORIENTATION) Slog.v(TAG, "Skipping " + atoken + " -- hidden on top"); continue; } if (!haveGroup) { haveGroup = true; - curGroup = wtoken.groupId; - lastOrientation = wtoken.requestedOrientation; + curGroup = atoken.groupId; + lastOrientation = atoken.requestedOrientation; } - int or = wtoken.requestedOrientation; + int or = atoken.requestedOrientation; // If this application is fullscreen, and didn't explicitly say // to use the orientation behind it, then just take whatever // orientation it has and ignores whatever is under it. - lastFullscreen = wtoken.appFullscreen; + lastFullscreen = atoken.appFullscreen; if (lastFullscreen && or != ActivityInfo.SCREEN_ORIENTATION_BEHIND) { - if (DEBUG_ORIENTATION) Slog.v(TAG, "Done at " + wtoken + if (DEBUG_ORIENTATION) Slog.v(TAG, "Done at " + atoken + " -- full screen, return " + or); return or; } @@ -3861,7 +3862,7 @@ public class WindowManagerService extends IWindowManager.Stub // then use it. if (or != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED && or != ActivityInfo.SCREEN_ORIENTATION_BEHIND) { - if (DEBUG_ORIENTATION) Slog.v(TAG, "Done at " + wtoken + if (DEBUG_ORIENTATION) Slog.v(TAG, "Done at " + atoken + " -- explicitly set, return " + or); return or; } @@ -3897,10 +3898,10 @@ public class WindowManagerService extends IWindowManager.Stub if (updateOrientationFromAppTokensLocked(false)) { if (freezeThisOneIfNeeded != null) { - AppWindowToken wtoken = findAppWindowToken( + AppWindowToken atoken = findAppWindowToken( freezeThisOneIfNeeded); - if (wtoken != null) { - startAppFreezingScreenLocked(wtoken, + if (atoken != null) { + startAppFreezingScreenLocked(atoken, ActivityInfo.CONFIG_ORIENTATION); } } @@ -3916,7 +3917,7 @@ public class WindowManagerService extends IWindowManager.Stub if (computeScreenConfigurationLocked(mTempConfiguration)) { if (currentConfig.diff(mTempConfiguration) != 0) { mWaitingForConfig = true; - getDefaultDisplayContent().layoutNeeded = true; + getDefaultDisplayContentLocked().layoutNeeded = true; startFreezingDisplayLocked(false, 0, 0); config = new Configuration(mTempConfiguration); } @@ -3992,13 +3993,13 @@ public class WindowManagerService extends IWindowManager.Stub } synchronized(mWindowMap) { - AppWindowToken wtoken = findAppWindowToken(token.asBinder()); - if (wtoken == null) { + AppWindowToken atoken = findAppWindowToken(token.asBinder()); + if (atoken == null) { Slog.w(TAG, "Attempted to set orientation of non-existing app token: " + token); return; } - wtoken.requestedOrientation = requestedOrientation; + atoken.requestedOrientation = requestedOrientation; } } @@ -4091,6 +4092,7 @@ public class WindowManagerService extends IWindowManager.Stub } } + @Override public int getPendingAppTransition() { return mNextAppTransition; } @@ -4101,6 +4103,7 @@ public class WindowManagerService extends IWindowManager.Stub } } + @Override public void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim, IRemoteCallback startedCallback) { synchronized(mWindowMap) { @@ -4282,7 +4285,7 @@ public class WindowManagerService extends IWindowManager.Stub updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, true /*updateInputWindows*/); - getDefaultDisplayContent().layoutNeeded = true; + getDefaultDisplayContentLocked().layoutNeeded = true; performLayoutAndPlaceSurfacesLocked(); Binder.restoreCallingIdentity(origId); return; @@ -5476,7 +5479,7 @@ public class WindowManagerService extends IWindowManager.Stub && !mOnlyCore; boolean haveKeyguard = true; // TODO(multidisplay): Expand to all displays? - final WindowList windows = getDefaultWindowList(); + final WindowList windows = getDefaultWindowListLocked(); final int N = windows.size(); for (int i=0; i<N; i++) { WindowState w = windows.get(i); @@ -5651,7 +5654,7 @@ public class WindowManagerService extends IWindowManager.Stub // TODO(multi-display): support multiple displays if (mStrictModeFlash == null) { mStrictModeFlash = new StrictModeFlash( - getDefaultDisplayContent().getDisplay(), mFxSession); + getDefaultDisplayContentLocked().getDisplay(), mFxSession); } mStrictModeFlash.setVisibility(on); } finally { @@ -5693,7 +5696,7 @@ public class WindowManagerService extends IWindowManager.Stub synchronized(mWindowMap) { long ident = Binder.clearCallingIdentity(); - final DisplayContent displayContent = getDisplayContent(displayId); + final DisplayContent displayContent = getDisplayContentLocked(displayId); final DisplayInfo displayInfo = displayContent.getDisplayInfo(); dw = displayInfo.logicalWidth; dh = displayInfo.logicalHeight; @@ -5764,7 +5767,7 @@ public class WindowManagerService extends IWindowManager.Stub } // The screenshot API does not apply the current screen rotation. - rot = getDefaultDisplayContent().getDisplay().getRotation(); + rot = getDefaultDisplayContentLocked().getDisplay().getRotation(); int fw = frame.width(); int fh = frame.height(); @@ -5913,7 +5916,7 @@ public class WindowManagerService extends IWindowManager.Stub synchronized(mWindowMap) { changed = updateRotationUncheckedLocked(false); if (!changed || forceRelayout) { - getDefaultDisplayContent().layoutNeeded = true; + getDefaultDisplayContentLocked().layoutNeeded = true; performLayoutAndPlaceSurfacesLocked(); } } @@ -5991,7 +5994,7 @@ public class WindowManagerService extends IWindowManager.Stub mH.removeMessages(H.WINDOW_FREEZE_TIMEOUT); mH.sendMessageDelayed(mH.obtainMessage(H.WINDOW_FREEZE_TIMEOUT), 2000); mWaitingForConfig = true; - getDefaultDisplayContent().layoutNeeded = true; + getDefaultDisplayContentLocked().layoutNeeded = true; startFreezingDisplayLocked(inTransaction, 0, 0); // We need to update our screen size information to match the new @@ -6002,7 +6005,7 @@ public class WindowManagerService extends IWindowManager.Stub // the rotation animation for the new rotation. computeScreenConfigurationLocked(null); - final DisplayContent displayContent = getDefaultDisplayContent(); + final DisplayContent displayContent = getDefaultDisplayContentLocked(); final DisplayInfo displayInfo = displayContent.getDisplayInfo(); if (!inTransaction) { if (SHOW_TRANSACTIONS) { @@ -6113,7 +6116,7 @@ public class WindowManagerService extends IWindowManager.Stub final int rotation = getRotation(); // TODO(multidisplay): Assume that such devices physical keys are on the main screen. - final DisplayContent displayContent = getDefaultDisplayContent(); + final DisplayContent displayContent = getDefaultDisplayContentLocked(); if (displayContent.mInitialDisplayWidth < displayContent.mInitialDisplayHeight) { // On devices with a natural orientation of portrait switch (rotation) { @@ -6441,7 +6444,7 @@ public class WindowManagerService extends IWindowManager.Stub throw new SecurityException("Requires RETRIEVE_WINDOW_INFO permission"); } synchronized(mWindowMap) { - DisplayContent displayContent = getDisplayContent(displayId); + DisplayContent displayContent = getDisplayContentLocked(displayId); if (displayContent.mDisplayContentChangeListeners == null) { displayContent.mDisplayContentChangeListeners = new RemoteCallbackList<IDisplayContentChangeListener>(); @@ -6457,7 +6460,7 @@ public class WindowManagerService extends IWindowManager.Stub throw new SecurityException("Requires RETRIEVE_WINDOW_INFO permission"); } synchronized(mWindowMap) { - DisplayContent displayContent = getDisplayContent(displayId); + DisplayContent displayContent = getDisplayContentLocked(displayId); if (displayContent.mDisplayContentChangeListeners != null) { displayContent.mDisplayContentChangeListeners.unregister(listener); if (displayContent.mDisplayContentChangeListeners @@ -6479,7 +6482,7 @@ public class WindowManagerService extends IWindowManager.Stub private void handleNotifyWindowTranstion(int transition, WindowInfo info) { RemoteCallbackList<IDisplayContentChangeListener> callbacks = null; synchronized (mWindowMap) { - DisplayContent displayContent = getDisplayContent(info.displayId); + DisplayContent displayContent = getDisplayContentLocked(info.displayId); if (displayContent == null) { return; } @@ -6515,7 +6518,7 @@ public class WindowManagerService extends IWindowManager.Stub private void handleNotifyRotationChanged(int displayId, int rotation) { RemoteCallbackList<IDisplayContentChangeListener> callbacks = null; synchronized (mWindowMap) { - DisplayContent displayContent = getDisplayContent(displayId); + DisplayContent displayContent = getDisplayContentLocked(displayId); if (displayContent == null) { return; } @@ -6802,7 +6805,7 @@ public class WindowManagerService extends IWindowManager.Stub } // TODO(multidisplay): For now, apply Configuration to main screen only. - final DisplayContent displayContent = getDefaultDisplayContent(); + final DisplayContent displayContent = getDefaultDisplayContentLocked(); // Use the effective "visual" dimensions based on current rotation final boolean rotated = (mRotation == Surface.ROTATION_90 @@ -7000,7 +7003,7 @@ public class WindowManagerService extends IWindowManager.Stub try { if (mDragState == null) { // TODO(multi-display): support other displays - final DisplayContent displayContent = getDefaultDisplayContent(); + final DisplayContent displayContent = getDefaultDisplayContentLocked(); final Display display = displayContent.getDisplay(); Surface surface = new Surface(session, "drag surface", width, height, PixelFormat.TRANSLUCENT, Surface.HIDDEN); @@ -7149,7 +7152,7 @@ public class WindowManagerService extends IWindowManager.Stub displayReady(Display.DEFAULT_DISPLAY); synchronized(mWindowMap) { - final DisplayContent displayContent = getDefaultDisplayContent(); + final DisplayContent displayContent = getDefaultDisplayContentLocked(); final Display display = displayContent.getDisplay(); readForcedDisplaySizeAndDensityLocked(displayContent); @@ -7159,7 +7162,7 @@ public class WindowManagerService extends IWindowManager.Stub mAnimator.initializeLocked(display.getLayerStack()); - final DisplayInfo displayInfo = getDefaultDisplayInfo(); + final DisplayInfo displayInfo = getDefaultDisplayInfoLocked(); mAnimator.setDisplayDimensions( displayInfo.logicalWidth, displayInfo.logicalHeight, displayInfo.appWidth, displayInfo.appHeight); @@ -7178,7 +7181,7 @@ public class WindowManagerService extends IWindowManager.Stub public void displayReady(int displayId) { synchronized(mWindowMap) { - final DisplayContent displayContent = getDisplayContent(displayId); + final DisplayContent displayContent = getDisplayContentLocked(displayId); final DisplayInfo displayInfo; synchronized(displayContent.mDisplaySizeLock) { // Bootstrap the default logical display from the display manager. @@ -7494,7 +7497,7 @@ public class WindowManagerService extends IWindowManager.Stub // TODO(multidisplay): Can non-default displays rotate? synchronized (mWindowMap) { Slog.w(TAG, "Window freeze timeout expired."); - final WindowList windows = getDefaultWindowList(); + final WindowList windows = getDefaultWindowListLocked(); int i = windows.size(); while (i > 0) { i--; @@ -7769,7 +7772,7 @@ public class WindowManagerService extends IWindowManager.Stub int idx = findDesiredInputMethodWindowIndexLocked(false); if (idx > 0) { // TODO(multidisplay): IMEs are only supported on the default display. - WindowState imFocus = getDefaultWindowList().get(idx-1); + WindowState imFocus = getDefaultWindowListLocked().get(idx-1); if (DEBUG_INPUT_METHOD) { Slog.i(TAG, "Desired input method target: " + imFocus); Slog.i(TAG, "Current focus: " + mCurrentFocus); @@ -7825,7 +7828,7 @@ public class WindowManagerService extends IWindowManager.Stub public void getInitialDisplaySize(int displayId, Point size) { // TODO(cmautner): Access to DisplayContent should be locked on mWindowMap. Doing that // could lead to deadlock since this is called from ActivityManager. - final DisplayContent displayContent = getDisplayContent(displayId); + final DisplayContent displayContent = getDisplayContentLocked(displayId); synchronized(displayContent.mDisplaySizeLock) { size.x = displayContent.mInitialDisplayWidth; size.y = displayContent.mInitialDisplayHeight; @@ -7839,7 +7842,7 @@ public class WindowManagerService extends IWindowManager.Stub final int MIN_WIDTH = 200; final int MIN_HEIGHT = 200; final int MAX_SCALE = 2; - final DisplayContent displayContent = getDisplayContent(displayId); + final DisplayContent displayContent = getDisplayContentLocked(displayId); width = Math.min(Math.max(width, MIN_WIDTH), displayContent.mInitialDisplayWidth * MAX_SCALE); @@ -7857,7 +7860,7 @@ public class WindowManagerService extends IWindowManager.Stub mBlackFrame = null; } // TODO(multidisplay): For now rotations are only main screen. - final DisplayContent displayContent = getDefaultDisplayContent(); + final DisplayContent displayContent = getDefaultDisplayContentLocked(); final Display display = displayContent.getDisplay(); if (displayContent.mBaseDisplayWidth < displayContent.mInitialDisplayWidth || displayContent.mBaseDisplayHeight < displayContent.mInitialDisplayHeight) { @@ -7949,7 +7952,7 @@ public class WindowManagerService extends IWindowManager.Stub public void clearForcedDisplaySize(int displayId) { synchronized(mWindowMap) { - final DisplayContent displayContent = getDisplayContent(displayId); + final DisplayContent displayContent = getDisplayContentLocked(displayId); setForcedDisplaySizeLocked(displayContent, displayContent.mInitialDisplayWidth, displayContent.mInitialDisplayHeight); Settings.Global.putString(mContext.getContentResolver(), @@ -7959,7 +7962,7 @@ public class WindowManagerService extends IWindowManager.Stub public void setForcedDisplayDensity(int displayId, int density) { synchronized(mWindowMap) { - final DisplayContent displayContent = getDisplayContent(displayId); + final DisplayContent displayContent = getDisplayContentLocked(displayId); setForcedDisplayDensityLocked(displayContent, density); Settings.Global.putString(mContext.getContentResolver(), Settings.Global.DISPLAY_DENSITY_FORCED, Integer.toString(density)); @@ -7977,7 +7980,7 @@ public class WindowManagerService extends IWindowManager.Stub public void clearForcedDisplayDensity(int displayId) { synchronized(mWindowMap) { - final DisplayContent displayContent = getDisplayContent(displayId); + final DisplayContent displayContent = getDisplayContentLocked(displayId); setForcedDisplayDensityLocked(displayContent, displayContent.mInitialDisplayDensity); Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.DISPLAY_DENSITY_FORCED, ""); @@ -8660,7 +8663,7 @@ public class WindowManagerService extends IWindowManager.Stub mNextAppTransitionThumbnail.getHeight()); try { // TODO(multi-display): support other displays - final DisplayContent displayContent = getDefaultDisplayContent(); + final DisplayContent displayContent = getDefaultDisplayContentLocked(); final Display display = displayContent.getDisplay(); Surface surface = new Surface(mFxSession, "thumbnail anim", @@ -8704,10 +8707,11 @@ public class WindowManagerService extends IWindowManager.Stub // a new layout to get them all up-to-date. changes |= WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT | WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG; - getDefaultDisplayContent().layoutNeeded = true; + getDefaultDisplayContentLocked().layoutNeeded = true; // TODO(multidisplay): IMEs are only supported on the default display. - if (windows == getDefaultWindowList() && !moveInputMethodWindowsIfNeededLocked(true)) { + if (windows == getDefaultWindowListLocked() + && !moveInputMethodWindowsIfNeededLocked(true)) { assignLayersLocked(windows); } updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES, false /*updateInputWindows*/); @@ -8957,7 +8961,7 @@ public class WindowManagerService extends IWindowManager.Stub mInnerFields.mButtonBrightness = -1; mTransactionSequence++; - final DisplayContent defaultDisplay = getDefaultDisplayContent(); + final DisplayContent defaultDisplay = getDefaultDisplayContentLocked(); final DisplayInfo defaultInfo = defaultDisplay.getDisplayInfo(); final int defaultDw = defaultInfo.logicalWidth; final int defaultDh = defaultInfo.logicalHeight; @@ -9381,7 +9385,7 @@ public class WindowManagerService extends IWindowManager.Stub } if (wallpaperDestroyed && (adjustWallpaperWindowsLocked() != 0)) { - getDefaultDisplayContent().layoutNeeded = true; + getDefaultDisplayContentLocked().layoutNeeded = true; } DisplayContentsIterator iterator = new DisplayContentsIterator(); @@ -9666,7 +9670,8 @@ public class WindowManagerService extends IWindowManager.Stub doRequest = true; } for (int i = 0; i < count; ++i) { - final DisplayContent displayContent = getDisplayContent(pendingLayouts.keyAt(i)); + final DisplayContent displayContent = + getDisplayContentLocked(pendingLayouts.keyAt(i)); displayContent.pendingLayoutChanges |= pendingLayouts.valueAt(i); } @@ -9797,14 +9802,14 @@ public class WindowManagerService extends IWindowManager.Stub int focusChanged = mPolicy.focusChangedLw(oldFocus, newFocus); // TODO(multidisplay): Focused windows on default display only. - final DisplayContent displayContent = getDefaultDisplayContent(); + final DisplayContent displayContent = getDefaultDisplayContentLocked(); final WindowState imWindow = mInputMethodWindow; if (newFocus != imWindow && oldFocus != imWindow) { if (moveInputMethodWindowsIfNeededLocked( mode != UPDATE_FOCUS_WILL_ASSIGN_LAYERS && mode != UPDATE_FOCUS_WILL_PLACE_SURFACES)) { - getDefaultDisplayContent().layoutNeeded = true; + getDefaultDisplayContentLocked().layoutNeeded = true; } if (mode == UPDATE_FOCUS_PLACING_SURFACES) { performLayoutLockedInner(displayContent, true /*initial*/, updateInputWindows); @@ -9818,7 +9823,7 @@ public class WindowManagerService extends IWindowManager.Stub if ((focusChanged & WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT) != 0) { // The change in focus caused us to need to do a layout. Okay. - getDefaultDisplayContent().layoutNeeded = true; + getDefaultDisplayContentLocked().layoutNeeded = true; if (mode == UPDATE_FOCUS_PLACING_SURFACES) { performLayoutLockedInner(displayContent, true /*initial*/, updateInputWindows); } @@ -9854,7 +9859,7 @@ public class WindowManagerService extends IWindowManager.Stub ? mAppTokens.get(nextAppIndex) : null; // TODO(multidisplay): IMEs are only supported on the default display. - WindowList windows = getDefaultWindowList(); + WindowList windows = getDefaultWindowListLocked(); for (int i = windows.size() - 1; i >= 0; i--) { win = windows.get(i); @@ -9952,7 +9957,7 @@ public class WindowManagerService extends IWindowManager.Stub } // TODO(multidisplay): rotation on main screen only. - final DisplayContent displayContent = getDefaultDisplayContent(); + final DisplayContent displayContent = getDefaultDisplayContentLocked(); final Display display = displayContent.getDisplay(); final DisplayInfo displayInfo = displayContent.getDisplayInfo(); mAnimator.mScreenRotationAnimation = new ScreenRotationAnimation(mContext, @@ -9990,7 +9995,7 @@ public class WindowManagerService extends IWindowManager.Stub && mAnimator.mScreenRotationAnimation.hasScreenshot()) { if (DEBUG_ORIENTATION) Slog.i(TAG, "**** Dismissing screen rotation animation"); // TODO(multidisplay): rotation on main screen only. - DisplayInfo displayInfo = getDefaultDisplayContent().getDisplayInfo(); + DisplayInfo displayInfo = getDefaultDisplayContentLocked().getDisplayInfo(); if (mAnimator.mScreenRotationAnimation.dismiss(mFxSession, MAX_ANIMATION_DURATION, mTransitionAnimationScale, displayInfo.logicalWidth, displayInfo.logicalHeight)) { @@ -10072,7 +10077,7 @@ public class WindowManagerService extends IWindowManager.Stub if (line != null) { String[] toks = line.split("%"); if (toks != null && toks.length > 0) { - mWatermark = new Watermark(getDefaultDisplayContent().getDisplay(), + mWatermark = new Watermark(getDefaultDisplayContentLocked().getDisplay(), mRealDisplayMetrics, mFxSession, toks); } } @@ -10106,7 +10111,7 @@ public class WindowManagerService extends IWindowManager.Stub // TOOD(multidisplay): StatusBar on multiple screens? void updateStatusBarVisibilityLocked(int visibility) { mInputManager.setSystemUiVisibility(visibility); - final WindowList windows = getDefaultWindowList(); + final WindowList windows = getDefaultWindowListLocked(); final int N = windows.size(); for (int i = 0; i < N; i++) { WindowState ws = windows.get(i); @@ -10177,7 +10182,7 @@ public class WindowManagerService extends IWindowManager.Stub public void saveLastInputMethodWindowForTransition() { synchronized (mWindowMap) { // TODO(multidisplay): Pass in the displayID. - DisplayContent displayContent = getDefaultDisplayContent(); + DisplayContent displayContent = getDefaultDisplayContentLocked(); if (mInputMethodWindow != null) { mPolicy.setLastInputMethodWindowLw(mInputMethodWindow, mInputMethodTarget); } @@ -10775,7 +10780,7 @@ public class WindowManagerService extends IWindowManager.Stub } } - public void createDisplayContent(final Display display) { + public void createDisplayContentLocked(final Display display) { if (display == null) { throw new IllegalArgumentException("getDisplayContent: display must not be null"); } @@ -10783,7 +10788,7 @@ public class WindowManagerService extends IWindowManager.Stub mDisplayContents.put(display.getDisplayId(), displayContent); } - public DisplayContent getDisplayContent(final int displayId) { + public DisplayContent getDisplayContentLocked(final int displayId) { DisplayContent displayContent = mDisplayContents.get(displayId); if (displayContent == null) { displayContent = new DisplayContent(mDisplayManager.getDisplay(displayId)); @@ -10873,20 +10878,20 @@ public class WindowManagerService extends IWindowManager.Stub } } - public DisplayContent getDefaultDisplayContent() { - return getDisplayContent(Display.DEFAULT_DISPLAY); + public DisplayContent getDefaultDisplayContentLocked() { + return getDisplayContentLocked(Display.DEFAULT_DISPLAY); } - public WindowList getDefaultWindowList() { - return getDefaultDisplayContent().getWindowList(); + public WindowList getDefaultWindowListLocked() { + return getDefaultDisplayContentLocked().getWindowList(); } - public DisplayInfo getDefaultDisplayInfo() { - return getDefaultDisplayContent().getDisplayInfo(); + public DisplayInfo getDefaultDisplayInfoLocked() { + return getDefaultDisplayContentLocked().getDisplayInfo(); } - public WindowList getWindowList(final Display display) { - return getDisplayContent(display.getDisplayId()).getWindowList(); + public WindowList getWindowListLocked(final Display display) { + return getDisplayContentLocked(display.getDisplayId()).getWindowList(); } @Override @@ -10895,7 +10900,7 @@ public class WindowManagerService extends IWindowManager.Stub } private void handleDisplayAddedLocked(int displayId) { - createDisplayContent(mDisplayManager.getDisplay(displayId)); + createDisplayContentLocked(mDisplayManager.getDisplay(displayId)); } @Override @@ -10904,7 +10909,7 @@ public class WindowManagerService extends IWindowManager.Stub } private void handleDisplayRemovedLocked(int displayId) { - final DisplayContent displayContent = getDisplayContent(displayId); + final DisplayContent displayContent = getDisplayContentLocked(displayId); mDisplayContents.delete(displayId); WindowList windows = displayContent.getWindowList(); for (int i = windows.size() - 1; i >= 0; --i) { @@ -10919,7 +10924,7 @@ public class WindowManagerService extends IWindowManager.Stub } private void handleDisplayChangedLocked(int displayId) { - final DisplayContent displayContent = getDisplayContent(displayId); + final DisplayContent displayContent = getDisplayContentLocked(displayId); if (displayContent != null) { displayContent.updateDisplayInfo(); } diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java index 478475d..a06ee3b 100644 --- a/services/java/com/android/server/wm/WindowState.java +++ b/services/java/com/android/server/wm/WindowState.java @@ -806,7 +806,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { return mViewVisibility == View.GONE || !mRelayoutCalled || (atoken == null && mRootToken.hidden) - || (atoken != null && (atoken.hiddenRequested || atoken.hidden)) + || (atoken != null && atoken.hiddenRequested) || mAttachedHidden || mExiting || mDestroying; } |
