summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorJim Miller <jaggies@google.com>2011-08-04 16:10:50 -0700
committerJim Miller <jaggies@google.com>2011-08-04 18:00:14 -0700
commitbe8d1cf1ac9fc514fb0cc2e8ef4a85beb0197fa0 (patch)
treec2de05ba61661e179601fd66b5165c2bc63e868f /policy
parentcf27a3ecc6782b6c86f720b1df2459a160fde81a (diff)
downloadframeworks_base-be8d1cf1ac9fc514fb0cc2e8ef4a85beb0197fa0.zip
frameworks_base-be8d1cf1ac9fc514fb0cc2e8ef4a85beb0197fa0.tar.gz
frameworks_base-be8d1cf1ac9fc514fb0cc2e8ef4a85beb0197fa0.tar.bz2
Fix 5045008: replace "ring/silence" target in LockScreen with camera app
This change replaces the ring/silence target with a camera target. It is disabled and falls back to the old behavior when any device policy disables the camera. Updated with latest icons. Change-Id: I2374eba08f85ff1d1b0bad2859efa30bb166fb60
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/LockScreen.java42
1 files changed, 35 insertions, 7 deletions
diff --git a/policy/src/com/android/internal/policy/impl/LockScreen.java b/policy/src/com/android/internal/policy/impl/LockScreen.java
index 4a14dd9..9d360ac 100644
--- a/policy/src/com/android/internal/policy/impl/LockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/LockScreen.java
@@ -23,7 +23,9 @@ import com.android.internal.widget.WaveView;
import com.android.internal.widget.multiwaveview.MultiWaveView;
import android.app.ActivityManager;
+import android.content.ActivityNotFoundException;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.view.KeyEvent;
@@ -181,14 +183,33 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
UnlockWidgetCommonMethods {
private final MultiWaveView mMultiWaveView;
+ private boolean mCameraDisabled;
MultiWaveViewMethods(MultiWaveView multiWaveView) {
mMultiWaveView = multiWaveView;
+ final boolean cameraDisabled = mLockPatternUtils.getDevicePolicyManager()
+ .getCameraDisabled(null);
+ if (cameraDisabled) {
+ Log.v(TAG, "Camera disabled by Device Policy");
+ mCameraDisabled = true;
+ } else {
+ // Camera is enabled if resource is initially defined for MultiWaveView
+ // in the lockscreen layout file
+ mCameraDisabled = mMultiWaveView.getTargetResourceId()
+ != R.array.lockscreen_targets_with_camera;
+ }
}
public void updateResources() {
- mMultiWaveView.setTargetResources(mSilentMode ? R.array.lockscreen_targets_when_silent
- : R.array.lockscreen_targets_when_soundon);
+ int resId;
+ if (mCameraDisabled) {
+ // Fall back to showing ring/silence if camera is disabled by DPM...
+ resId = mSilentMode ? R.array.lockscreen_targets_when_silent
+ : R.array.lockscreen_targets_when_soundon;
+ } else {
+ resId = R.array.lockscreen_targets_with_camera;
+ }
+ mMultiWaveView.setTargetResources(resId);
}
public void onGrabbed(View v, int handle) {
@@ -200,12 +221,19 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
}
public void onTrigger(View v, int target) {
- if (target == 0) { // TODO: Use resources to determine which handle was used
+ if (target == 0 || target == 1) { // 0 = unlock/portrait, 1 = unlock/landscape
mCallback.goToUnlockScreen();
- } else if (target == 2) {
- toggleRingMode();
- mUnlockWidgetMethods.updateResources();
- mCallback.pokeWakelock();
+ } else if (target == 2 || target == 3) { // 2 = alt/portrait, 3 = alt/landscape
+ if (!mCameraDisabled) {
+ // Broadcast an intent to start the Camera
+ Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null);
+ mContext.sendOrderedBroadcast(intent, null);
+ mCallback.goToUnlockScreen();
+ } else {
+ toggleRingMode();
+ mUnlockWidgetMethods.updateResources();
+ mCallback.pokeWakelock();
+ }
}
}