diff options
Diffstat (limited to 'policy')
-rwxr-xr-x | policy/com/android/internal/policy/impl/PhoneWindowManager.java | 202 |
1 files changed, 150 insertions, 52 deletions
diff --git a/policy/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/com/android/internal/policy/impl/PhoneWindowManager.java index e9acc23..ba5ea74 100755 --- a/policy/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/com/android/internal/policy/impl/PhoneWindowManager.java @@ -31,6 +31,7 @@ import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; +import android.graphics.PixelFormat; import android.graphics.Rect; import android.os.BatteryManager; import android.os.Handler; @@ -44,6 +45,7 @@ import android.os.SystemProperties; import android.os.Vibrator; import android.provider.Settings; +import com.android.common.ui.PointerLocationView; import com.android.internal.policy.PolicyManager; import com.android.internal.telephony.ITelephony; import android.util.Config; @@ -173,12 +175,18 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Vibrator pattern for haptic feedback of virtual key press. long[] mVirtualKeyVibePattern; + // Vibrator pattern for a short vibration. + long[] mKeyboardTapVibePattern; + // Vibrator pattern for haptic feedback during boot when safe mode is disabled. long[] mSafeModeDisabledVibePattern; // Vibrator pattern for haptic feedback during boot when safe mode is enabled. long[] mSafeModeEnabledVibePattern; + // Vibrator pattern for haptic feedback when the user hits a touch scroll barrier. + long[] mScrollBarrierVibePattern; + /** If true, hitting shift & menu will broadcast Intent.ACTION_BUG_REPORT */ boolean mEnableShiftMenuBugReports = false; @@ -194,6 +202,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { final IntentFilter mBatteryStatusFilter = new IntentFilter(); + boolean mSystemReady; boolean mLidOpen; int mPlugged; boolean mRegisteredBatteryReceiver; @@ -214,6 +223,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mAccelerometerDefault = DEFAULT_ACCELEROMETER_ROTATION; boolean mHasSoftInput = false; + int mPointerLocationMode = 0; + PointerLocationView mPointerLocationView = null; + // The current size of the screen. int mW, mH; // During layout, the current screen borders with all outer decoration @@ -280,15 +292,17 @@ public class PhoneWindowManager implements WindowManagerPolicy { Settings.System.ACCELEROMETER_ROTATION), false, this); resolver.registerContentObserver(Settings.System.getUriFor( Settings.System.SCREEN_OFF_TIMEOUT), false, this); + resolver.registerContentObserver(Settings.System.getUriFor( + Settings.System.POINTER_LOCATION), false, this); resolver.registerContentObserver(Settings.Secure.getUriFor( Settings.Secure.DEFAULT_INPUT_METHOD), false, this); resolver.registerContentObserver(Settings.System.getUriFor( "fancy_rotation_anim"), false, this); - update(); + updateSettings(); } @Override public void onChange(boolean selfChange) { - update(); + updateSettings(); try { mWindowManager.setRotation(USE_LAST_ROTATION, false, mFancyRotationAnimation); @@ -296,36 +310,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Ignore } } - - public void update() { - ContentResolver resolver = mContext.getContentResolver(); - boolean updateRotation = false; - synchronized (mLock) { - mEndcallBehavior = Settings.System.getInt(resolver, - Settings.System.END_BUTTON_BEHAVIOR, DEFAULT_ENDCALL_BEHAVIOR); - mFancyRotationAnimation = Settings.System.getInt(resolver, - "fancy_rotation_anim", 0) != 0 ? 0x80 : 0; - int accelerometerDefault = Settings.System.getInt(resolver, - Settings.System.ACCELEROMETER_ROTATION, DEFAULT_ACCELEROMETER_ROTATION); - if (mAccelerometerDefault != accelerometerDefault) { - mAccelerometerDefault = accelerometerDefault; - updateOrientationListenerLp(); - } - // use screen off timeout setting as the timeout for the lockscreen - mLockScreenTimeout = Settings.System.getInt(resolver, - Settings.System.SCREEN_OFF_TIMEOUT, 0); - String imId = Settings.Secure.getString(resolver, - Settings.Secure.DEFAULT_INPUT_METHOD); - boolean hasSoftInput = imId != null && imId.length() > 0; - if (mHasSoftInput != hasSoftInput) { - mHasSoftInput = hasSoftInput; - updateRotation = true; - } - } - if (updateRotation) { - updateRotation(0); - } - } } class MyOrientationListener extends WindowOrientationListener { @@ -558,12 +542,85 @@ public class PhoneWindowManager implements WindowManagerPolicy { com.android.internal.R.array.config_longPressVibePattern); mVirtualKeyVibePattern = getLongIntArray(mContext.getResources(), com.android.internal.R.array.config_virtualKeyVibePattern); + mKeyboardTapVibePattern = getLongIntArray(mContext.getResources(), + com.android.internal.R.array.config_keyboardTapVibePattern); mSafeModeDisabledVibePattern = getLongIntArray(mContext.getResources(), com.android.internal.R.array.config_safeModeDisabledVibePattern); mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(), com.android.internal.R.array.config_safeModeEnabledVibePattern); + mScrollBarrierVibePattern = getLongIntArray(mContext.getResources(), + com.android.internal.R.array.config_scrollBarrierVibePattern); } + public void updateSettings() { + ContentResolver resolver = mContext.getContentResolver(); + boolean updateRotation = false; + View addView = null; + View removeView = null; + synchronized (mLock) { + mEndcallBehavior = Settings.System.getInt(resolver, + Settings.System.END_BUTTON_BEHAVIOR, DEFAULT_ENDCALL_BEHAVIOR); + mFancyRotationAnimation = Settings.System.getInt(resolver, + "fancy_rotation_anim", 0) != 0 ? 0x80 : 0; + int accelerometerDefault = Settings.System.getInt(resolver, + Settings.System.ACCELEROMETER_ROTATION, DEFAULT_ACCELEROMETER_ROTATION); + if (mAccelerometerDefault != accelerometerDefault) { + mAccelerometerDefault = accelerometerDefault; + updateOrientationListenerLp(); + } + if (mSystemReady) { + int pointerLocation = Settings.System.getInt(resolver, + Settings.System.POINTER_LOCATION, 0); + if (mPointerLocationMode != pointerLocation) { + mPointerLocationMode = pointerLocation; + if (pointerLocation != 0) { + if (mPointerLocationView == null) { + mPointerLocationView = new PointerLocationView(mContext); + mPointerLocationView.setPrintCoords(false); + addView = mPointerLocationView; + } + } else { + removeView = mPointerLocationView; + mPointerLocationView = null; + } + } + } + // use screen off timeout setting as the timeout for the lockscreen + mLockScreenTimeout = Settings.System.getInt(resolver, + Settings.System.SCREEN_OFF_TIMEOUT, 0); + String imId = Settings.Secure.getString(resolver, + Settings.Secure.DEFAULT_INPUT_METHOD); + boolean hasSoftInput = imId != null && imId.length() > 0; + if (mHasSoftInput != hasSoftInput) { + mHasSoftInput = hasSoftInput; + updateRotation = true; + } + } + if (updateRotation) { + updateRotation(0); + } + if (addView != null) { + WindowManager.LayoutParams lp = new WindowManager.LayoutParams( + WindowManager.LayoutParams.MATCH_PARENT, + WindowManager.LayoutParams.MATCH_PARENT); + lp.type = WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; + lp.flags = + WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| + WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| + WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; + lp.format = PixelFormat.TRANSLUCENT; + lp.setTitle("PointerLocation"); + WindowManagerImpl wm = (WindowManagerImpl) + mContext.getSystemService(Context.WINDOW_SERVICE); + wm.addView(addView, lp); + } + if (removeView != null) { + WindowManagerImpl wm = (WindowManagerImpl) + mContext.getSystemService(Context.WINDOW_SERVICE); + wm.removeView(removeView); + } + } + void updatePlugged(Intent powerIntent) { if (localLOGV) Log.v(TAG, "New battery status: " + powerIntent.getExtras()); if (powerIntent != null) { @@ -692,6 +749,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { return false; } + public void dispatchedPointerEventLw(MotionEvent ev, int targetX, int targetY) { + if (mPointerLocationView == null) { + return; + } + synchronized (mLock) { + if (mPointerLocationView == null) { + return; + } + ev.offsetLocation(targetX, targetY); + mPointerLocationView.addTouchEvent(ev); + ev.offsetLocation(-targetX, -targetY); + } + } + /** {@inheritDoc} */ public int windowTypeToLayerLw(int type) { if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) { @@ -2106,6 +2177,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { android.os.SystemProperties.set("dev.bootcomplete", "1"); synchronized (mLock) { updateOrientationListenerLp(); + mSystemReady = true; + mHandler.post(new Runnable() { + public void run() { + updateSettings(); + } + }); } } @@ -2262,16 +2339,21 @@ public class PhoneWindowManager implements WindowManagerPolicy { // This code brings home to the front or, if it is already // at the front, puts the device to sleep. try { - ActivityManagerNative.getDefault().stopAppSwitches(); - sendCloseSystemWindows(); - Intent dock = createHomeDockIntent(); - if (dock != null) { - int result = ActivityManagerNative.getDefault() - .startActivity(null, dock, - dock.resolveTypeIfNeeded(mContext.getContentResolver()), - null, 0, null, null, 0, true /* onlyIfNeeded*/, false); - if (result == IActivityManager.START_RETURN_INTENT_TO_CALLER) { - return false; + if (SystemProperties.getInt("persist.sys.uts-test-mode", 0) == 1) { + /// Roll back EndcallBehavior as the cupcake design to pass P1 lab entry. + Log.d(TAG, "UTS-TEST-MODE"); + } else { + ActivityManagerNative.getDefault().stopAppSwitches(); + sendCloseSystemWindows(); + Intent dock = createHomeDockIntent(); + if (dock != null) { + int result = ActivityManagerNative.getDefault() + .startActivity(null, dock, + dock.resolveTypeIfNeeded(mContext.getContentResolver()), + null, 0, null, null, 0, true /* onlyIfNeeded*/, false); + if (result == IActivityManager.START_RETURN_INTENT_TO_CALLER) { + return false; + } } } int result = ActivityManagerNative.getDefault() @@ -2296,28 +2378,44 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } } - + public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) { final boolean hapticsDisabled = Settings.System.getInt(mContext.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) == 0; if (!always && (hapticsDisabled || mKeyguardMediator.isShowingAndNotHidden())) { return false; } + long[] pattern = null; switch (effectId) { case HapticFeedbackConstants.LONG_PRESS: - mVibrator.vibrate(mLongPressVibePattern, -1); - return true; + pattern = mLongPressVibePattern; + break; case HapticFeedbackConstants.VIRTUAL_KEY: - mVibrator.vibrate(mVirtualKeyVibePattern, -1); - return true; + pattern = mVirtualKeyVibePattern; + break; + case HapticFeedbackConstants.KEYBOARD_TAP: + pattern = mKeyboardTapVibePattern; + break; case HapticFeedbackConstants.SAFE_MODE_DISABLED: - mVibrator.vibrate(mSafeModeDisabledVibePattern, -1); - return true; + pattern = mSafeModeDisabledVibePattern; + break; case HapticFeedbackConstants.SAFE_MODE_ENABLED: - mVibrator.vibrate(mSafeModeEnabledVibePattern, -1); - return true; + pattern = mSafeModeEnabledVibePattern; + break; + case HapticFeedbackConstants.SCROLL_BARRIER: + pattern = mScrollBarrierVibePattern; + break; + default: + return false; } - return false; + if (pattern.length == 1) { + // One-shot vibration + mVibrator.vibrate(pattern[0]); + } else { + // Pattern vibration + mVibrator.vibrate(pattern, -1); + } + return true; } public void keyFeedbackFromInput(KeyEvent event) { |