Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ffe2ab43 authored by The Android Open Source Project's avatar The Android Open Source Project
Browse files

auto import from //branches/cupcake/...@132276

parent 5a9453de
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -56,6 +56,11 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
    private static final String LOCK_PATTERN_CLASS =
    private static final String LOCK_PATTERN_CLASS =
            "com.android.settings.ChooseLockPattern";
            "com.android.settings.ChooseLockPattern";


    /**
     * The amount of millis to stay awake once this screen detects activity
     */
    private static final int AWAKE_POKE_MILLIS = 30000;

    private final KeyguardScreenCallback mCallback;
    private final KeyguardScreenCallback mCallback;
    private final LockPatternUtils mLockPatternUtils;
    private final LockPatternUtils mLockPatternUtils;
    private IAccountsService mAccountsService;
    private IAccountsService mAccountsService;
@@ -116,7 +121,7 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
    }
    }


    public void onTextChanged(CharSequence s, int start, int before, int count) {
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        mCallback.pokeWakelock();
        mCallback.pokeWakelock(AWAKE_POKE_MILLIS);
    }
    }


    @Override
    @Override
+100 −22
Original line number Original line Diff line number Diff line
@@ -52,7 +52,7 @@ import android.view.HapticFeedbackConstants;
import android.view.IWindowManager;
import android.view.IWindowManager;
import android.view.KeyEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.OrientationListener;
import android.view.WindowOrientationListener;
import android.view.RawInputEvent;
import android.view.RawInputEvent;
import android.view.Surface;
import android.view.Surface;
import android.view.View;
import android.view.View;
@@ -141,7 +141,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    // Vibrator pattern for haptic feedback of a long press.
    // Vibrator pattern for haptic feedback of a long press.
    private static final long[] LONG_PRESS_VIBE_PATTERN = {0, 1, 40, 41};
    private static final long[] LONG_PRESS_VIBE_PATTERN = {0, 1, 40, 41};
    // Vibrator pattern for haptic feedback of a zoom ring tick
    // Vibrator pattern for haptic feedback of a zoom ring tick
    private static final long[] ZOOM_RING_TICK_VIBE_PATTERN = {0, 1, 40, 41};
    private static final long[] ZOOM_RING_TICK_VIBE_PATTERN = {0, 10};
    
    
    Context mContext;
    Context mContext;
    IWindowManager mWindowManager;
    IWindowManager mWindowManager;
@@ -254,7 +254,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
        }
    }
    }
    
    
    class MyOrientationListener extends OrientationListener {
    class MyOrientationListener extends WindowOrientationListener {
        private static final int _LOWER_THRESHOLD = 30;
        private static final int _UPPER_THRESHOLD = 60;
        
        
        MyOrientationListener(Context context) {
        MyOrientationListener(Context context) {
            super(context);
            super(context);
@@ -262,14 +264,27 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        
        
        @Override
        @Override
        public void onOrientationChanged(int orientation) {
        public void onOrientationChanged(int orientation) {
            // ignore orientation changes unless the value is in a range that
            // ignore orientation changes unless the value is in a range 
            // matches portrait or landscape
            // When switching from portrait to landscape try to use a lower threshold limit
            // portrait range is 270+45 to 359 and 0 to 45
            // Use upper threshold limit when switching from landscape to portrait
            // landscape range is 270-45 to 270+45
            // this is to delay the switch as much as we can
            if ((orientation >= 0 && orientation <= 45) || (orientation >= 270 - 45)) {
            int rotation;
                int rotation =  (orientation >= 270 - 45
            int threshold = (mSensorRotation == Surface.ROTATION_90) ? _UPPER_THRESHOLD :
                        && orientation <= 270 + 45)
                    _LOWER_THRESHOLD;
            
            if ((orientation >= 0 && orientation <= _UPPER_THRESHOLD) ||
                    (orientation >= 270 - _LOWER_THRESHOLD)) {
                rotation =  (orientation >= 270 - _LOWER_THRESHOLD
                        && orientation <= 270 + threshold)
                        ? Surface.ROTATION_90 : Surface.ROTATION_0;
                        ? Surface.ROTATION_90 : Surface.ROTATION_0;
            } else if (orientation == WindowOrientationListener.ORIENTATION_FLAT) {
                // return portrait 
                rotation = Surface.ROTATION_0;
            } else {
                // ignore orientation value
                return;
            }
            // Send updates based on orientation value
            if (rotation != mSensorRotation) {
            if (rotation != mSensorRotation) {
                if(localLOGV) Log.i(TAG, "onOrientationChanged, rotation changed from "+rotation+" to "+mSensorRotation);
                if(localLOGV) Log.i(TAG, "onOrientationChanged, rotation changed from "+rotation+" to "+mSensorRotation);
                // Update window manager.  The lid rotation hasn't changed,
                // Update window manager.  The lid rotation hasn't changed,
@@ -284,7 +299,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            }
            }
        }                                      
        }                                      
    }
    }
    }
    MyOrientationListener mOrientationListener;
    MyOrientationListener mOrientationListener;


    boolean useSensorForOrientation() {
    boolean useSensorForOrientation() {
@@ -1355,6 +1369,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        final boolean isWakeKey = isWakeKeyTq(event);
        final boolean isWakeKey = isWakeKeyTq(event);
        final boolean keyguardShowing = keyguardIsShowingTq();
        final boolean keyguardShowing = keyguardIsShowingTq();


        if (false) {
            Log.d(TAG, "interceptKeyTq event=" + event + " keycode=" + event.keycode
                  + " screenIsOn=" + screenIsOn + " keyguardShowing=" + keyguardShowing);
        }

        if (keyguardShowing) {
        if (keyguardShowing) {
            if (screenIsOn) {
            if (screenIsOn) {
                // when the screen is on, always give the event to the keyguard
                // when the screen is on, always give the event to the keyguard
@@ -1458,6 +1477,65 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    mBroadcastWakeLock.acquire();
                    mBroadcastWakeLock.acquire();
                    mHandler.post(new PassHeadsetKey(keyEvent));
                    mHandler.post(new PassHeadsetKey(keyEvent));
                }
                }
            } else if (code == KeyEvent.KEYCODE_CALL) {
                // If an incoming call is ringing, answer it!
                // (We handle this key here, rather than in the InCallScreen, to make
                // sure we'll respond to the key even if the InCallScreen hasn't come to
                // the foreground yet.)

                // We answer the call on the DOWN event, to agree with
                // the "fallback" behavior in the InCallScreen.
                if (down) {
                    try {
                        ITelephony phoneServ = getPhoneInterface();
                        if (phoneServ != null) {
                            if (phoneServ.isRinging()) {
                                Log.i(TAG, "interceptKeyTq:"
                                      + " CALL key-down while ringing: Answer the call!");
                                phoneServ.answerRingingCall();

                                // And *don't* pass this key thru to the current activity
                                // (which is presumably the InCallScreen.)
                                result &= ~ACTION_PASS_TO_USER;
                            }
                        } else {
                            Log.w(TAG, "CALL button: Unable to find ITelephony interface");
                        }
                    } catch (RemoteException ex) {
                        Log.w(TAG, "CALL button: RemoteException from getPhoneInterface()", ex);
                    }
                }
            } else if ((code == KeyEvent.KEYCODE_VOLUME_UP)
                       || (code == KeyEvent.KEYCODE_VOLUME_DOWN)) {
                // If an incoming call is ringing, either VOLUME key means
                // "silence ringer".  We handle these keys here, rather than
                // in the InCallScreen, to make sure we'll respond to them
                // even if the InCallScreen hasn't come to the foreground yet.

                // Look for the DOWN event here, to agree with the "fallback"
                // behavior in the InCallScreen.
                if (down) {
                    try {
                        ITelephony phoneServ = getPhoneInterface();
                        if (phoneServ != null) {
                            if (phoneServ.isRinging()) {
                                Log.i(TAG, "interceptKeyTq:"
                                      + " VOLUME key-down while ringing: Silence ringer!");
                                // Silence the ringer.  (It's safe to call this
                                // even if the ringer has already been silenced.)
                                phoneServ.silenceRinger();

                                // And *don't* pass this key thru to the current activity
                                // (which is probably the InCallScreen.)
                                result &= ~ACTION_PASS_TO_USER;
                            }
                        } else {
                            Log.w(TAG, "VOLUME button: Unable to find ITelephony interface");
                        }
                    } catch (RemoteException ex) {
                        Log.w(TAG, "VOLUME button: RemoteException from getPhoneInterface()", ex);
                    }
                }
            }
            }
        }
        }


+1 −6
Original line number Original line Diff line number Diff line
@@ -16,14 +16,10 @@


package com.android.internal.policy.impl;
package com.android.internal.policy.impl;


import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
import android.content.ServiceConnection;
import android.content.ServiceConnection;
import android.os.CountDownTimer;
import android.os.CountDownTimer;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemClock;
import android.util.Log;
import android.view.KeyEvent;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View;
@@ -304,8 +300,7 @@ class UnlockScreen extends LinearLayoutWithDefaultTouchRecepient
                    mCallback.reportFailedPatternAttempt();
                    mCallback.reportFailedPatternAttempt();
                }
                }
                if (mFailedPatternAttemptsSinceLastTimeout >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
                if (mFailedPatternAttemptsSinceLastTimeout >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
                    long deadline = SystemClock.elapsedRealtime() + LockPatternUtils.FAILED_ATTEMPT_TIMEOUT_MS;
                    long deadline = mLockPatternUtils.setLockoutAttemptDeadline();
                    mLockPatternUtils.setLockoutAttemptDeadline(deadline);
                    handleAttemptLockout(deadline);
                    handleAttemptLockout(deadline);
                    return;
                    return;
                }
                }