Loading core/java/android/view/WindowManagerPolicy.java +17 −1 Original line number Diff line number Diff line Loading @@ -379,6 +379,10 @@ public interface WindowManagerPolicy { public static final int LID_CLOSED = 0; public static final int LID_OPEN = 1; public static final int CAMERA_LENS_COVER_ABSENT = -1; public static final int CAMERA_LENS_UNCOVERED = 0; public static final int CAMERA_LENS_COVERED = 1; /** * Ask the window manager to re-evaluate the system UI flags. */ Loading @@ -398,6 +402,11 @@ public interface WindowManagerPolicy { */ public int getLidState(); /** * Returns a code that descripbes whether the camera lens is covered or not. */ public int getCameraLensCoverState(); /** * Switch the keyboard layout for the given device. * Direction should be +1 or -1 to go to the next or previous keyboard layout. Loading Loading @@ -952,6 +961,13 @@ public interface WindowManagerPolicy { */ public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen); /** * Tell the policy that the camera lens has been covered or uncovered. * @param whenNanos The time when the change occurred in uptime nanoseconds. * @param lensCovered True if the lens is covered. */ public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered); /** * Tell the policy if anyone is requesting that keyguard not come on. * Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +32 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import android.os.SystemProperties; import android.os.UEventObserver; import android.os.UserHandle; import android.os.Vibrator; import android.provider.MediaStore; import android.provider.Settings; import android.service.dreams.DreamManagerInternal; import android.service.dreams.DreamService; Loading Loading @@ -127,6 +128,9 @@ import static android.view.WindowManager.LayoutParams.*; import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT; import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN; import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED; import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVER_ABSENT; import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_UNCOVERED; import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVERED; /** * WindowManagerPolicy implementation for the Android phone UI. This Loading Loading @@ -315,6 +319,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mLanguageSwitchKeyPressed; int mLidState = LID_ABSENT; int mCameraLensCoverState = CAMERA_LENS_COVER_ABSENT; boolean mHaveBuiltInKeyboard; boolean mSystemReady; Loading Loading @@ -1525,6 +1530,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { mLidState = mWindowManagerFuncs.getLidState(); } private void readCameraLensCoverState() { mCameraLensCoverState = mWindowManagerFuncs.getCameraLensCoverState(); } private boolean isHidden(int accessibilityMode) { switch (accessibilityMode) { case 1: Loading Loading @@ -4055,6 +4064,27 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } @Override public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered) { int lensCoverState = lensCovered ? CAMERA_LENS_COVERED : CAMERA_LENS_UNCOVERED; if (mCameraLensCoverState == lensCoverState) { return; } if (mCameraLensCoverState == CAMERA_LENS_COVERED && lensCoverState == CAMERA_LENS_UNCOVERED) { Intent intent; final boolean keyguardActive = mKeyguardDelegate == null ? false : mKeyguardDelegate.isShowing(); if (keyguardActive) { intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE); } else { intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); } mContext.startActivityAsUser(intent, UserHandle.CURRENT_OR_SELF); } mCameraLensCoverState = lensCoverState; } void setHdmiPlugged(boolean plugged) { if (mHdmiPlugged != plugged) { mHdmiPlugged = plugged; Loading Loading @@ -5132,6 +5162,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mKeyguardDelegate = new KeyguardServiceDelegate(mContext, null); mKeyguardDelegate.onSystemReady(); readCameraLensCoverState(); updateUiMode(); synchronized (mLock) { updateOrientationListenerLp(); Loading Loading @@ -5783,6 +5814,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { pw.print(" mSystemBooted="); pw.println(mSystemBooted); pw.print(prefix); pw.print("mLidState="); pw.print(mLidState); pw.print(" mLidOpenRotation="); pw.print(mLidOpenRotation); pw.print(" mCameraLensCoverState="); pw.print(mCameraLensCoverState); pw.print(" mHdmiPlugged="); pw.println(mHdmiPlugged); if (mLastSystemUiFlags != 0 || mResettingSystemUiFlags != 0 || mForceClearedSystemUiFlags != 0) { Loading services/core/java/com/android/server/input/InputManagerService.java +11 −0 Original line number Diff line number Diff line Loading @@ -241,6 +241,9 @@ public class InputManagerService extends IInputManager.Stub /** Switch code: Headphone/Microphone Jack. When set, something is inserted. */ public static final int SW_JACK_PHYSICAL_INSERT = 0x07; /** Switch code: Camera lens cover. When set the lens is covered. */ public static final int SW_CAMERA_LENS_COVER = 0x09; public static final int SW_LID_BIT = 1 << SW_LID; public static final int SW_KEYPAD_SLIDE_BIT = 1 << SW_KEYPAD_SLIDE; public static final int SW_HEADPHONE_INSERT_BIT = 1 << SW_HEADPHONE_INSERT; Loading @@ -249,6 +252,7 @@ public class InputManagerService extends IInputManager.Stub public static final int SW_JACK_PHYSICAL_INSERT_BIT = 1 << SW_JACK_PHYSICAL_INSERT; public static final int SW_JACK_BITS = SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_JACK_PHYSICAL_INSERT_BIT | SW_LINEOUT_INSERT_BIT; public static final int SW_CAMERA_LENS_COVER_BIT = 1 << SW_CAMERA_LENS_COVER; /** Whether to use the dev/input/event or uevent subsystem for the audio jack. */ final boolean mUseDevInputEventForAudioJack; Loading Loading @@ -1380,6 +1384,11 @@ public class InputManagerService extends IInputManager.Stub mWindowManagerCallbacks.notifyLidSwitchChanged(whenNanos, lidOpen); } if ((switchMask & SW_CAMERA_LENS_COVER_BIT) != 0) { final boolean lensCovered = ((switchValues & SW_CAMERA_LENS_COVER_BIT) == 0); mWindowManagerCallbacks.notifyCameraLensCoverSwitchChanged(whenNanos, lensCovered); } if (mUseDevInputEventForAudioJack && (switchMask & SW_JACK_BITS) != 0) { mWiredAccessoryCallbacks.notifyWiredAccessoryChanged(whenNanos, switchValues, switchMask); Loading Loading @@ -1575,6 +1584,8 @@ public class InputManagerService extends IInputManager.Stub public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen); public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered); public void notifyInputChannelBroken(InputWindowHandle inputWindowHandle); public long notifyANR(InputApplicationHandle inputApplicationHandle, Loading services/core/java/com/android/server/wm/InputMonitor.java +6 −0 Original line number Diff line number Diff line Loading @@ -352,6 +352,12 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { mService.mPolicy.notifyLidSwitchChanged(whenNanos, lidOpen); } /* Notifies that the camera lens cover state has changed. */ @Override public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered) { mService.mPolicy.notifyCameraLensCoverSwitchChanged(whenNanos, lensCovered); } /* Provides an opportunity for the window manager policy to intercept early key * processing as soon as the key has been read from the device. */ @Override Loading services/core/java/com/android/server/wm/WindowManagerService.java +17 −0 Original line number Diff line number Diff line Loading @@ -5432,6 +5432,23 @@ public class WindowManagerService extends IWindowManager.Stub } } // Called by window manager policy. Not exposed externally. @Override public int getCameraLensCoverState() { int sw = mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, InputManagerService.SW_CAMERA_LENS_COVER); if (sw > 0) { // Switch state: AKEY_STATE_DOWN or AKEY_STATE_VIRTUAL. return CAMERA_LENS_COVERED; } else if (sw == 0) { // Switch state: AKEY_STATE_UP. return CAMERA_LENS_UNCOVERED; } else { // Switch state: AKEY_STATE_UNKNOWN. return CAMERA_LENS_COVER_ABSENT; } } // Called by window manager policy. Not exposed externally. @Override public void switchKeyboardLayout(int deviceId, int direction) { Loading Loading
core/java/android/view/WindowManagerPolicy.java +17 −1 Original line number Diff line number Diff line Loading @@ -379,6 +379,10 @@ public interface WindowManagerPolicy { public static final int LID_CLOSED = 0; public static final int LID_OPEN = 1; public static final int CAMERA_LENS_COVER_ABSENT = -1; public static final int CAMERA_LENS_UNCOVERED = 0; public static final int CAMERA_LENS_COVERED = 1; /** * Ask the window manager to re-evaluate the system UI flags. */ Loading @@ -398,6 +402,11 @@ public interface WindowManagerPolicy { */ public int getLidState(); /** * Returns a code that descripbes whether the camera lens is covered or not. */ public int getCameraLensCoverState(); /** * Switch the keyboard layout for the given device. * Direction should be +1 or -1 to go to the next or previous keyboard layout. Loading Loading @@ -952,6 +961,13 @@ public interface WindowManagerPolicy { */ public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen); /** * Tell the policy that the camera lens has been covered or uncovered. * @param whenNanos The time when the change occurred in uptime nanoseconds. * @param lensCovered True if the lens is covered. */ public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered); /** * Tell the policy if anyone is requesting that keyguard not come on. * Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +32 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import android.os.SystemProperties; import android.os.UEventObserver; import android.os.UserHandle; import android.os.Vibrator; import android.provider.MediaStore; import android.provider.Settings; import android.service.dreams.DreamManagerInternal; import android.service.dreams.DreamService; Loading Loading @@ -127,6 +128,9 @@ import static android.view.WindowManager.LayoutParams.*; import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT; import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN; import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED; import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVER_ABSENT; import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_UNCOVERED; import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVERED; /** * WindowManagerPolicy implementation for the Android phone UI. This Loading Loading @@ -315,6 +319,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mLanguageSwitchKeyPressed; int mLidState = LID_ABSENT; int mCameraLensCoverState = CAMERA_LENS_COVER_ABSENT; boolean mHaveBuiltInKeyboard; boolean mSystemReady; Loading Loading @@ -1525,6 +1530,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { mLidState = mWindowManagerFuncs.getLidState(); } private void readCameraLensCoverState() { mCameraLensCoverState = mWindowManagerFuncs.getCameraLensCoverState(); } private boolean isHidden(int accessibilityMode) { switch (accessibilityMode) { case 1: Loading Loading @@ -4055,6 +4064,27 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } @Override public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered) { int lensCoverState = lensCovered ? CAMERA_LENS_COVERED : CAMERA_LENS_UNCOVERED; if (mCameraLensCoverState == lensCoverState) { return; } if (mCameraLensCoverState == CAMERA_LENS_COVERED && lensCoverState == CAMERA_LENS_UNCOVERED) { Intent intent; final boolean keyguardActive = mKeyguardDelegate == null ? false : mKeyguardDelegate.isShowing(); if (keyguardActive) { intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE); } else { intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); } mContext.startActivityAsUser(intent, UserHandle.CURRENT_OR_SELF); } mCameraLensCoverState = lensCoverState; } void setHdmiPlugged(boolean plugged) { if (mHdmiPlugged != plugged) { mHdmiPlugged = plugged; Loading Loading @@ -5132,6 +5162,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mKeyguardDelegate = new KeyguardServiceDelegate(mContext, null); mKeyguardDelegate.onSystemReady(); readCameraLensCoverState(); updateUiMode(); synchronized (mLock) { updateOrientationListenerLp(); Loading Loading @@ -5783,6 +5814,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { pw.print(" mSystemBooted="); pw.println(mSystemBooted); pw.print(prefix); pw.print("mLidState="); pw.print(mLidState); pw.print(" mLidOpenRotation="); pw.print(mLidOpenRotation); pw.print(" mCameraLensCoverState="); pw.print(mCameraLensCoverState); pw.print(" mHdmiPlugged="); pw.println(mHdmiPlugged); if (mLastSystemUiFlags != 0 || mResettingSystemUiFlags != 0 || mForceClearedSystemUiFlags != 0) { Loading
services/core/java/com/android/server/input/InputManagerService.java +11 −0 Original line number Diff line number Diff line Loading @@ -241,6 +241,9 @@ public class InputManagerService extends IInputManager.Stub /** Switch code: Headphone/Microphone Jack. When set, something is inserted. */ public static final int SW_JACK_PHYSICAL_INSERT = 0x07; /** Switch code: Camera lens cover. When set the lens is covered. */ public static final int SW_CAMERA_LENS_COVER = 0x09; public static final int SW_LID_BIT = 1 << SW_LID; public static final int SW_KEYPAD_SLIDE_BIT = 1 << SW_KEYPAD_SLIDE; public static final int SW_HEADPHONE_INSERT_BIT = 1 << SW_HEADPHONE_INSERT; Loading @@ -249,6 +252,7 @@ public class InputManagerService extends IInputManager.Stub public static final int SW_JACK_PHYSICAL_INSERT_BIT = 1 << SW_JACK_PHYSICAL_INSERT; public static final int SW_JACK_BITS = SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_JACK_PHYSICAL_INSERT_BIT | SW_LINEOUT_INSERT_BIT; public static final int SW_CAMERA_LENS_COVER_BIT = 1 << SW_CAMERA_LENS_COVER; /** Whether to use the dev/input/event or uevent subsystem for the audio jack. */ final boolean mUseDevInputEventForAudioJack; Loading Loading @@ -1380,6 +1384,11 @@ public class InputManagerService extends IInputManager.Stub mWindowManagerCallbacks.notifyLidSwitchChanged(whenNanos, lidOpen); } if ((switchMask & SW_CAMERA_LENS_COVER_BIT) != 0) { final boolean lensCovered = ((switchValues & SW_CAMERA_LENS_COVER_BIT) == 0); mWindowManagerCallbacks.notifyCameraLensCoverSwitchChanged(whenNanos, lensCovered); } if (mUseDevInputEventForAudioJack && (switchMask & SW_JACK_BITS) != 0) { mWiredAccessoryCallbacks.notifyWiredAccessoryChanged(whenNanos, switchValues, switchMask); Loading Loading @@ -1575,6 +1584,8 @@ public class InputManagerService extends IInputManager.Stub public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen); public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered); public void notifyInputChannelBroken(InputWindowHandle inputWindowHandle); public long notifyANR(InputApplicationHandle inputApplicationHandle, Loading
services/core/java/com/android/server/wm/InputMonitor.java +6 −0 Original line number Diff line number Diff line Loading @@ -352,6 +352,12 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { mService.mPolicy.notifyLidSwitchChanged(whenNanos, lidOpen); } /* Notifies that the camera lens cover state has changed. */ @Override public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered) { mService.mPolicy.notifyCameraLensCoverSwitchChanged(whenNanos, lensCovered); } /* Provides an opportunity for the window manager policy to intercept early key * processing as soon as the key has been read from the device. */ @Override Loading
services/core/java/com/android/server/wm/WindowManagerService.java +17 −0 Original line number Diff line number Diff line Loading @@ -5432,6 +5432,23 @@ public class WindowManagerService extends IWindowManager.Stub } } // Called by window manager policy. Not exposed externally. @Override public int getCameraLensCoverState() { int sw = mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, InputManagerService.SW_CAMERA_LENS_COVER); if (sw > 0) { // Switch state: AKEY_STATE_DOWN or AKEY_STATE_VIRTUAL. return CAMERA_LENS_COVERED; } else if (sw == 0) { // Switch state: AKEY_STATE_UP. return CAMERA_LENS_UNCOVERED; } else { // Switch state: AKEY_STATE_UNKNOWN. return CAMERA_LENS_COVER_ABSENT; } } // Called by window manager policy. Not exposed externally. @Override public void switchKeyboardLayout(int deviceId, int direction) { Loading