diff options
Diffstat (limited to 'services')
3 files changed, 87 insertions, 35 deletions
diff --git a/services/java/com/android/server/HeadsetObserver.java b/services/java/com/android/server/HeadsetObserver.java index 43de36b..a935131 100644 --- a/services/java/com/android/server/HeadsetObserver.java +++ b/services/java/com/android/server/HeadsetObserver.java @@ -49,7 +49,6 @@ class HeadsetObserver extends UEventObserver { private int mHeadsetState; private int mPrevHeadsetState; private String mHeadsetName; - private boolean mPendingIntent; private final Context mContext; private final WakeLock mWakeLock; // held while there is a pending route change @@ -114,7 +113,6 @@ class HeadsetObserver extends UEventObserver { mHeadsetName = newName; mPrevHeadsetState = mHeadsetState; mHeadsetState = headsetState; - mPendingIntent = true; if (headsetState == 0) { Intent intent = new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY); @@ -126,25 +124,28 @@ class HeadsetObserver extends UEventObserver { // This could be improved once the audio sub-system provides an // interface to clear the audio pipeline. mWakeLock.acquire(); - mHandler.sendEmptyMessageDelayed(0, 1000); + mHandler.sendMessageDelayed(mHandler.obtainMessage(0, + mHeadsetState, + mPrevHeadsetState, + mHeadsetName), + 1000); } else { - sendIntents(); - mPendingIntent = false; + sendIntents(mHeadsetState, mPrevHeadsetState, mHeadsetName); } } - private synchronized final void sendIntents() { + private synchronized final void sendIntents(int headsetState, int prevHeadsetState, String headsetName) { int allHeadsets = SUPPORTED_HEADSETS; for (int curHeadset = 1; allHeadsets != 0; curHeadset <<= 1) { if ((curHeadset & allHeadsets) != 0) { - sendIntent(curHeadset); + sendIntent(curHeadset, headsetState, prevHeadsetState, headsetName); allHeadsets &= ~curHeadset; } } } - private final void sendIntent(int headset) { - if ((mHeadsetState & headset) != (mPrevHeadsetState & headset)) { + private final void sendIntent(int headset, int headsetState, int prevHeadsetState, String headsetName) { + if ((headsetState & headset) != (prevHeadsetState & headset)) { // Pack up the values and broadcast them to everyone Intent intent = new Intent(Intent.ACTION_HEADSET_PLUG); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); @@ -154,14 +155,14 @@ class HeadsetObserver extends UEventObserver { if ((headset & HEADSETS_WITH_MIC) != 0) { microphone = 1; } - if ((mHeadsetState & headset) != 0) { + if ((headsetState & headset) != 0) { state = 1; } intent.putExtra("state", state); - intent.putExtra("name", mHeadsetName); + intent.putExtra("name", headsetName); intent.putExtra("microphone", microphone); - if (LOG) Log.v(TAG, "Intent.ACTION_HEADSET_PLUG: state: "+state+" name: "+mHeadsetName+" mic: "+microphone); + if (LOG) Log.v(TAG, "Intent.ACTION_HEADSET_PLUG: state: "+state+" name: "+headsetName+" mic: "+microphone); // TODO: Should we require a permission? ActivityManagerNative.broadcastStickyIntent(intent, null); } @@ -170,12 +171,8 @@ class HeadsetObserver extends UEventObserver { private final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { - if (mPendingIntent) { - sendIntents(); - mPendingIntent = false; - } + sendIntents(msg.arg1, msg.arg2, (String)msg.obj); mWakeLock.release(); } }; - } diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index f05cdc4..e312df6 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -133,6 +133,7 @@ public class WindowManagerService extends IWindowManager.Stub static final boolean DEBUG = false; static final boolean DEBUG_FOCUS = false; static final boolean DEBUG_ANIM = false; + static final boolean DEBUG_LAYOUT = false; static final boolean DEBUG_LAYERS = false; static final boolean DEBUG_INPUT = false; static final boolean DEBUG_INPUT_METHOD = false; @@ -2288,10 +2289,7 @@ public class WindowManagerService extends IWindowManager.Stub attrChanges = win.mAttrs.copyFrom(attrs); } - if (localLOGV) Log.v( - TAG, "Relayout given client " + client.asBinder() - + " (" + win.mAttrs.getTitle() + ")"); - + if (DEBUG_LAYOUT) Log.v(TAG, "Relayout " + win + ": " + win.mAttrs); if ((attrChanges & WindowManager.LayoutParams.ALPHA_CHANGED) != 0) { win.mAlpha = attrs.alpha; @@ -2307,6 +2305,8 @@ public class WindowManagerService extends IWindowManager.Stub (attrs.width / (float)requestedWidth) : 1.0f; win.mVScale = (attrs.height != requestedHeight) ? (attrs.height / (float)requestedHeight) : 1.0f; + } else { + win.mHScale = win.mVScale = 1; } boolean imMayMove = (flagChanges&( @@ -2378,6 +2378,18 @@ public class WindowManagerService extends IWindowManager.Stub mInputMethodWindow = win; imMayMove = true; } + if (win.mAttrs.type == TYPE_BASE_APPLICATION + && win.mAppToken != null + && win.mAppToken.startingWindow != null) { + // Special handling of starting window over the base + // window of the app: propagate lock screen flags to it, + // to provide the correct semantics while starting. + final int mask = + WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED + | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD; + WindowManager.LayoutParams sa = win.mAppToken.startingWindow.mAttrs; + sa.flags = (sa.flags&~mask) | (win.mAttrs.flags&mask); + } } else { win.mEnterAnimationPending = false; if (win.mSurface != null) { @@ -3485,10 +3497,12 @@ public class WindowManagerService extends IWindowManager.Stub + ": hidden=" + wtoken.hidden + " hiddenRequested=" + wtoken.hiddenRequested); - if (changed && performLayout) { + if (changed) { mLayoutNeeded = true; - updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES); - performLayoutAndPlaceSurfacesLocked(); + if (performLayout) { + updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES); + performLayoutAndPlaceSurfacesLocked(); + } } } @@ -5082,7 +5096,9 @@ public class WindowManagerService extends IWindowManager.Stub // If we are on top of the wallpaper, then the wallpaper also // gets to see this movement. - if (mWallpaperTarget == target || mSendingPointersToWallpaper) { + if ((mWallpaperTarget == target && + target.mAttrs.type != WindowManager.LayoutParams.TYPE_KEYGUARD) + || mSendingPointersToWallpaper) { sendPointerToWallpaperLocked(null, ev, eventTime); } @@ -6011,18 +6027,18 @@ public class WindowManagerService extends IWindowManager.Stub res.offsetLocation(-win.mFrame.left, -win.mFrame.top); } } - - if (res != null && returnWhat == RETURN_PENDING_POINTER) { - synchronized (mWindowMap) { - if ((mWallpaperTarget == win && - win.mAttrs.type != WindowManager.LayoutParams.TYPE_KEYGUARD) - || mSendingPointersToWallpaper) { - sendPointerToWallpaperLocked(win, res, res.getEventTime()); - } + } + + if (res != null && returnWhat == RETURN_PENDING_POINTER) { + synchronized (mWindowMap) { + if ((mWallpaperTarget == win && + win.mAttrs.type != WindowManager.LayoutParams.TYPE_KEYGUARD) + || mSendingPointersToWallpaper) { + sendPointerToWallpaperLocked(win, res, res.getEventTime()); } } } - + return res; } @@ -7447,6 +7463,12 @@ public class WindowManagerService extends IWindowManager.Stub if (c.mSurface != null && c.mAttachedHidden) { c.mAttachedHidden = false; c.performShowLocked(); + // It hadn't been shown, which means layout not + // performed on it, so now we want to make sure to + // do a layout. If called from within the transaction + // loop, this will cause it to restart with a new + // layout. + mLayoutNeeded = true; } } @@ -8083,6 +8105,9 @@ public class WindowManagerService extends IWindowManager.Stub pw.print(mPolicyVisibilityAfterAnim); pw.print(" mAttachedHidden="); pw.println(mAttachedHidden); } + if (!mRelayoutCalled) { + pw.print(prefix); pw.print("mRelayoutCalled="); pw.println(mRelayoutCalled); + } pw.print(prefix); pw.print("Requested w="); pw.print(mRequestedWidth); pw.print(" h="); pw.println(mRequestedHeight); if (mXOffset != 0 || mYOffset != 0) { @@ -9219,6 +9244,9 @@ public class WindowManagerService extends IWindowManager.Stub int repeats = 0; int i; + if (DEBUG_LAYOUT) Log.v(TAG, "performLayout: needed=" + + mLayoutNeeded + " dw=" + dw + " dh=" + dh); + // FIRST LOOP: Perform a layout, if needed. while (mLayoutNeeded) { @@ -9241,6 +9269,18 @@ public class WindowManagerService extends IWindowManager.Stub || win.mAttachedHidden || win.mExiting || win.mDestroying; + if (win.mLayoutAttached) { + if (DEBUG_LAYOUT) Log.v(TAG, "First pass " + win + + ": gone=" + gone + " mHaveFrame=" + win.mHaveFrame + + " mLayoutAttached=" + win.mLayoutAttached); + if (DEBUG_LAYOUT && gone) Log.v(TAG, " (mViewVisibility=" + + win.mViewVisibility + " mRelayoutCalled=" + + win.mRelayoutCalled + " hidden=" + + win.mRootToken.hidden + " hiddenRequested=" + + (atoken != null && atoken.hiddenRequested) + + " mAttachedHidden=" + win.mAttachedHidden); + } + // If this view is GONE, then skip it -- keep the current // frame, and let the caller know so they can ignore it // if they want. (We do the normal layout for INVISIBLE @@ -9249,6 +9289,10 @@ public class WindowManagerService extends IWindowManager.Stub if (!gone || !win.mHaveFrame) { if (!win.mLayoutAttached) { mPolicy.layoutWindowLw(win, win.mAttrs, null); + if (DEBUG_LAYOUT) Log.v(TAG, "-> mFrame=" + + win.mFrame + " mContainingFrame=" + + win.mContainingFrame + " mDisplayFrame=" + + win.mDisplayFrame); } else { if (topAttached < 0) topAttached = i; } @@ -9268,9 +9312,17 @@ public class WindowManagerService extends IWindowManager.Stub // windows, since that means "perform layout as normal, // just don't display"). if (win.mLayoutAttached) { + if (DEBUG_LAYOUT) Log.v(TAG, "Second pass " + win + + " mHaveFrame=" + win.mHaveFrame + + " mViewVisibility=" + win.mViewVisibility + + " mRelayoutCalled=" + win.mRelayoutCalled); if ((win.mViewVisibility != View.GONE && win.mRelayoutCalled) || !win.mHaveFrame) { mPolicy.layoutWindowLw(win, win.mAttrs, win.mAttachedWindow); + if (DEBUG_LAYOUT) Log.v(TAG, "-> mFrame=" + + win.mFrame + " mContainingFrame=" + + win.mContainingFrame + " mDisplayFrame=" + + win.mDisplayFrame); } } } @@ -9295,8 +9347,11 @@ public class WindowManagerService extends IWindowManager.Stub } } } else { + if (DEBUG_LAYOUT) Log.v(TAG, "Repeating layout because changes=0x" + + Integer.toHexString(changes)); repeats++; if ((changes&WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG) != 0) { + if (DEBUG_LAYOUT) Log.v(TAG, "Computing new config from layout"); Configuration newConfig = updateOrientationFromAppTokensLocked( null, null); if (newConfig != null) { diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 3612a9b..f3cba69 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -12919,7 +12919,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen try { if (DEBUG_SWITCH) Log.i(TAG, "Switch is restarting resumed " + r); r.app.thread.scheduleRelaunchActivity(r, results, newIntents, - changes, !andResume); + changes, !andResume, mConfiguration); // Note: don't need to call pauseIfSleepingLocked() here, because // the caller will only pass in 'andResume' if this activity is // currently resumed, which implies we aren't sleeping. |