diff options
Diffstat (limited to 'services/java/com')
5 files changed, 101 insertions, 39 deletions
diff --git a/services/java/com/android/server/BluetoothManagerService.java b/services/java/com/android/server/BluetoothManagerService.java index 69ccbc7..ea91875 100755 --- a/services/java/com/android/server/BluetoothManagerService.java +++ b/services/java/com/android/server/BluetoothManagerService.java @@ -775,8 +775,18 @@ class BluetoothManagerService extends IBluetoothManager.Stub { // Send BT state broadcast to update // the BT icon correctly - bluetoothStateChangeHandler(BluetoothAdapter.STATE_ON, - BluetoothAdapter.STATE_TURNING_OFF); + if ((mState == BluetoothAdapter.STATE_TURNING_ON) || + (mState == BluetoothAdapter.STATE_ON)) { + bluetoothStateChangeHandler(BluetoothAdapter.STATE_ON, + BluetoothAdapter.STATE_TURNING_OFF); + mState = BluetoothAdapter.STATE_TURNING_OFF; + } + if (mState == BluetoothAdapter.STATE_TURNING_OFF) { + bluetoothStateChangeHandler(BluetoothAdapter.STATE_TURNING_OFF, + BluetoothAdapter.STATE_OFF); + } + + mHandler.removeMessages(MESSAGE_BLUETOOTH_STATE_CHANGE); mState = BluetoothAdapter.STATE_OFF; } break; @@ -820,20 +830,33 @@ class BluetoothManagerService extends IBluetoothManager.Stub { } } } - mHandler.removeMessages(MESSAGE_BLUETOOTH_STATE_CHANGE); + + if (mState == BluetoothAdapter.STATE_TURNING_OFF) { + // MESSAGE_USER_SWITCHED happened right after MESSAGE_ENABLE + bluetoothStateChangeHandler(mState, BluetoothAdapter.STATE_OFF); + mState = BluetoothAdapter.STATE_OFF; + } + if (mState == BluetoothAdapter.STATE_OFF) { + bluetoothStateChangeHandler(mState, BluetoothAdapter.STATE_TURNING_ON); + mState = BluetoothAdapter.STATE_TURNING_ON; + } waitForOnOff(true, false); - bluetoothStateChangeHandler(mState, BluetoothAdapter.STATE_ON); + if (mState == BluetoothAdapter.STATE_TURNING_ON) { + bluetoothStateChangeHandler(mState, BluetoothAdapter.STATE_ON); + } // disable handleDisable(false); + // Pbap service need receive STATE_TURNING_OFF intent to close + bluetoothStateChangeHandler(BluetoothAdapter.STATE_ON, + BluetoothAdapter.STATE_TURNING_OFF); waitForOnOff(false, true); - bluetoothStateChangeHandler(BluetoothAdapter.STATE_ON, + bluetoothStateChangeHandler(BluetoothAdapter.STATE_TURNING_OFF, BluetoothAdapter.STATE_OFF); - mState = BluetoothAdapter.STATE_OFF; sendBluetoothServiceDownCallback(); synchronized (mConnection) { if (mBluetooth != null) { @@ -844,6 +867,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub { } SystemClock.sleep(100); + mHandler.removeMessages(MESSAGE_BLUETOOTH_STATE_CHANGE); + mState = BluetoothAdapter.STATE_OFF; // enable handleEnable(false, mQuietEnable); } else if (mBinding || mBluetooth != null) { @@ -982,14 +1007,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub { sendBluetoothStateCallback(isUp); //If Bluetooth is off, send service down event to proxy objects, and unbind - if (!isUp) { - //Only unbind with mEnable flag not set - //For race condition: disable and enable back-to-back - //Avoid unbind right after enable due to callback from disable - if ((!mEnable) && (mBluetooth != null)) { - sendBluetoothServiceDownCallback(); - unbindAndFinish(); - } + if (!isUp && canUnbindBluetoothService()) { + sendBluetoothServiceDownCallback(); + unbindAndFinish(); } } @@ -1037,4 +1057,22 @@ class BluetoothManagerService extends IBluetoothManager.Stub { Log.e(TAG,"waitForOnOff time out"); return false; } + + private boolean canUnbindBluetoothService() { + synchronized(mConnection) { + //Only unbind with mEnable flag not set + //For race condition: disable and enable back-to-back + //Avoid unbind right after enable due to callback from disable + //Only unbind with Bluetooth at OFF state + //Only unbind without any MESSAGE_BLUETOOTH_STATE_CHANGE message + try { + if (mEnable || (mBluetooth == null)) return false; + if (mHandler.hasMessages(MESSAGE_BLUETOOTH_STATE_CHANGE)) return false; + return (mBluetooth.getState() == BluetoothAdapter.STATE_OFF); + } catch (RemoteException e) { + Log.e(TAG, "getState()", e); + } + } + return false; + } } diff --git a/services/java/com/android/server/DevicePolicyManagerService.java b/services/java/com/android/server/DevicePolicyManagerService.java index b3af35a..6a62809 100644 --- a/services/java/com/android/server/DevicePolicyManagerService.java +++ b/services/java/com/android/server/DevicePolicyManagerService.java @@ -1874,28 +1874,32 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { DeviceAdminInfo.USES_POLICY_WIPE_DATA); long ident = Binder.clearCallingIdentity(); try { - if (userHandle == UserHandle.USER_OWNER) { - wipeDataLocked(flags); - } else { - lockNowUnchecked(); - mHandler.post(new Runnable() { - public void run() { - try { - ActivityManagerNative.getDefault().switchUser(0); - ((UserManager) mContext.getSystemService(Context.USER_SERVICE)) - .removeUser(userHandle); - } catch (RemoteException re) { - // Shouldn't happen - } - } - }); - } + wipeDeviceOrUserLocked(flags, userHandle); } finally { Binder.restoreCallingIdentity(ident); } } } + private void wipeDeviceOrUserLocked(int flags, final int userHandle) { + if (userHandle == UserHandle.USER_OWNER) { + wipeDataLocked(flags); + } else { + lockNowUnchecked(); + mHandler.post(new Runnable() { + public void run() { + try { + ActivityManagerNative.getDefault().switchUser(0); + ((UserManager) mContext.getSystemService(Context.USER_SERVICE)) + .removeUser(userHandle); + } catch (RemoteException re) { + // Shouldn't happen + } + } + }); + } + } + public void getRemoveWarning(ComponentName comp, final RemoteCallback result, int userHandle) { enforceCrossUserPermission(userHandle); mContext.enforceCallingOrSelfPermission( @@ -1995,7 +1999,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { saveSettingsLocked(userHandle); int max = getMaximumFailedPasswordsForWipe(null, userHandle); if (max > 0 && policy.mFailedPasswordAttempts >= max) { - wipeDataLocked(0); + wipeDeviceOrUserLocked(0, userHandle); } sendAdminCommandLocked(DeviceAdminReceiver.ACTION_PASSWORD_FAILED, DeviceAdminInfo.USES_POLICY_WATCH_LOGIN, userHandle); diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 51edb44..c3fc19c 100755 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -2848,7 +2848,7 @@ public class WindowManagerService extends IWindowManager.Stub } if (win.isConfigChanged()) { if (DEBUG_CONFIGURATION) Slog.i(TAG, "Window " + win - + " visible with new config: " + win.mConfiguration); + + " visible with new config: " + mCurConfiguration); outConfig.setTo(mCurConfiguration); } } @@ -3808,22 +3808,23 @@ public class WindowManagerService extends IWindowManager.Stub final WindowList windows = getDefaultWindowListLocked(); int pos = windows.size() - 1; while (pos >= 0) { - WindowState wtoken = windows.get(pos); + WindowState win = windows.get(pos); pos--; - if (wtoken.mAppToken != null) { + if (win.mAppToken != null) { // We hit an application window. so the orientation will be determined by the // app window. No point in continuing further. return (mLastWindowForcedOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } - if (!wtoken.isVisibleLw() || !wtoken.mPolicyVisibilityAfterAnim) { + if (!win.isVisibleLw() || !win.mPolicyVisibilityAfterAnim) { continue; } - int req = wtoken.mAttrs.screenOrientation; + int req = win.mAttrs.screenOrientation; if((req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) || (req == ActivityInfo.SCREEN_ORIENTATION_BEHIND)){ continue; } + if (DEBUG_ORIENTATION) Slog.v(TAG, win + " forcing orientation to " + req); return (mLastWindowForcedOrientation=req); } return (mLastWindowForcedOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); @@ -9407,7 +9408,7 @@ public class WindowManagerService extends IWindowManager.Stub + " / " + mCurConfiguration + " / 0x" + Integer.toHexString(diff)); } - win.mConfiguration = mCurConfiguration; + win.setConfiguration(mCurConfiguration); if (DEBUG_ORIENTATION && winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING) Slog.i( TAG, "Resizing " + win + " WITH DRAW PENDING"); diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java index 35bebbe..3dce939 100644 --- a/services/java/com/android/server/wm/WindowState.java +++ b/services/java/com/android/server/wm/WindowState.java @@ -21,6 +21,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW; import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; +import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD; import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; import com.android.server.input.InputWindowHandle; @@ -112,6 +113,9 @@ final class WindowState implements WindowManagerPolicy.WindowState { int mLayoutSeq = -1; Configuration mConfiguration = null; + // Sticky answer to isConfigChanged(), remains true until new Configuration is assigned. + // Used only on {@link #TYPE_KEYGUARD}. + private boolean mConfigHasChanged; /** * Actual frame shown on-screen (may be modified by animation). These @@ -627,6 +631,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { : WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS; } + @Override public boolean hasAppShownWindows() { return mAppToken != null && (mAppToken.firstWindowDrawn || mAppToken.startingDisplayed); } @@ -857,9 +862,17 @@ final class WindowState implements WindowManagerPolicy.WindowState { } boolean isConfigChanged() { - return mConfiguration != mService.mCurConfiguration + boolean configChanged = mConfiguration != mService.mCurConfiguration && (mConfiguration == null || (mConfiguration.diff(mService.mCurConfiguration) != 0)); + + if (mAttrs.type == TYPE_KEYGUARD) { + // Retain configuration changed status until resetConfiguration called. + mConfigHasChanged |= configChanged; + configChanged = mConfigHasChanged; + } + + return configChanged; } boolean isConfigDiff(int mask) { @@ -886,6 +899,11 @@ final class WindowState implements WindowManagerPolicy.WindowState { } } + void setConfiguration(final Configuration newConfig) { + mConfiguration = newConfig; + mConfigHasChanged = false; + } + void setInputChannel(InputChannel inputChannel) { if (mInputChannel != null) { throw new IllegalStateException("Window already has an input channel."); @@ -907,6 +925,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { } private class DeathRecipient implements IBinder.DeathRecipient { + @Override public void binderDied() { try { synchronized(mService.mWindowMap) { diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java index 7b30c89..e33b7b7 100644 --- a/services/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/java/com/android/server/wm/WindowStateAnimator.java @@ -803,7 +803,7 @@ class WindowStateAnimator { mSurfaceShown = false; mSurface = null; - mWin.mHasSurface =false; + mWin.mHasSurface = false; mDrawState = NO_SURFACE; } } |
