summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2013-02-13 14:24:59 +0000
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2013-02-15 00:30:09 +0000
commit4815d6e5a658bb1b301f7724c8e8fff6bc764bba (patch)
tree66f6e6484d239545197d73bcca8ad2505246c981 /policy
parenteaa7d1835c8691dd656fea99ae3d61b039ebe1b7 (diff)
parent763ef60466ac752a3031719fb86b08486c9946b1 (diff)
downloadframeworks_base-4815d6e5a658bb1b301f7724c8e8fff6bc764bba.zip
frameworks_base-4815d6e5a658bb1b301f7724c8e8fff6bc764bba.tar.gz
frameworks_base-4815d6e5a658bb1b301f7724c8e8fff6bc764bba.tar.bz2
Merge commit 'android-4.2.2_r1' into mr1.1-staging
Conflicts: core/java/android/os/Trace.java core/java/android/widget/Toast.java core/res/res/values-cs/strings.xml core/res/res/values-el/strings.xml core/res/res/values-iw/strings.xml core/res/res/values/config.xml core/res/res/values/symbols.xml media/java/android/media/AudioService.java packages/SystemUI/res/values-sv/strings.xml packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java policy/src/com/android/internal/policy/impl/keyguard/KeyguardMessageArea.java policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java services/java/com/android/server/NotificationManagerService.java services/java/com/android/server/power/ElectronBeam.java Change-Id: I60b8ddf20a1d7bcf9dc7b1a4ed841aaa4d953294
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindowManager.java30
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/CameraWidgetFrame.java290
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/FaceUnlock.java19
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardCircleFramedDrawable.java1
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java101
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardMessageArea.java17
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardTransportControlView.java2
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java28
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java33
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java17
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetCarousel.java46
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetFrame.java9
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java83
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/PagedView.java35
14 files changed, 452 insertions, 259 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index dccd24d..8998d57 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -464,6 +464,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
boolean mForceStatusBar;
boolean mForceStatusBarFromKeyguard;
boolean mHideLockScreen;
+ boolean mForcingShowNavBar;
+ int mForcingShowNavBarLayer;
// States of keyguard dismiss.
private static final int DISMISS_KEYGUARD_NONE = 0; // Keyguard not being dismissed.
@@ -3372,6 +3374,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mTopFullscreenOpaqueWindowState = null;
mForceStatusBar = false;
mForceStatusBarFromKeyguard = false;
+ mForcingShowNavBar = false;
+ mForcingShowNavBarLayer = -1;
mHideLockScreen = false;
mAllowLockscreenWhenOn = false;
@@ -3386,6 +3390,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
WindowManager.LayoutParams attrs) {
if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw="
+ win.isVisibleOrBehindKeyguardLw());
+ if (mTopFullscreenOpaqueWindowState == null && (win.getAttrs().privateFlags
+ &WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_NAV_BAR) != 0) {
+ if (mForcingShowNavBarLayer < 0) {
+ mForcingShowNavBar = true;
+ mForcingShowNavBarLayer = win.getSurfaceLayer();
+ }
+ }
if (mTopFullscreenOpaqueWindowState == null &&
win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw()) {
if ((attrs.flags & FLAG_FORCE_NOT_FULLSCREEN) != 0) {
@@ -4228,6 +4239,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// and then updates our own bookkeeping based on the now-
// current user.
mSettingsObserver.onChange(false);
+
+ // force a re-application of focused window sysui visibility.
+ // the window may never have been shown for this user
+ // e.g. the keyguard when going through the new-user setup flow
+ synchronized(mLock) {
+ mLastSystemUiFlags = 0;
+ updateSystemUiVisibilityLw();
+ }
}
}
};
@@ -4991,9 +5010,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// will quickly lose focus once it correctly gets hidden.
return 0;
}
- final int visibility = mFocusedWindow.getSystemUiVisibility()
+ int tmpVisibility = mFocusedWindow.getSystemUiVisibility()
& ~mResettingSystemUiFlags
& ~mForceClearedSystemUiFlags;
+ if (mForcingShowNavBar && mFocusedWindow.getSurfaceLayer() < mForcingShowNavBarLayer) {
+ tmpVisibility &= ~View.SYSTEM_UI_CLEARABLE_FLAGS;
+ }
+ final int visibility = tmpVisibility;
int diff = visibility ^ mLastSystemUiFlags;
final boolean needsMenu = mFocusedWindow.getNeedsMenuLw(mTopFullscreenOpaqueWindowState);
if (diff == 0 && mLastFocusNeedsMenu == needsMenu
@@ -5180,6 +5203,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState=");
pw.println(mTopFullscreenOpaqueWindowState);
}
+ if (mForcingShowNavBar) {
+ pw.print(prefix); pw.print("mForcingShowNavBar=");
+ pw.println(mForcingShowNavBar); pw.print( "mForcingShowNavBarLayer=");
+ pw.println(mForcingShowNavBarLayer);
+ }
pw.print(prefix); pw.print("mTopIsFullscreen="); pw.print(mTopIsFullscreen);
pw.print(" mHideLockScreen="); pw.println(mHideLockScreen);
pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/CameraWidgetFrame.java b/policy/src/com/android/internal/policy/impl/keyguard/CameraWidgetFrame.java
index dbd9999..762711d 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/CameraWidgetFrame.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/CameraWidgetFrame.java
@@ -18,10 +18,9 @@ package com.android.internal.policy.impl.keyguard;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Point;
+import android.graphics.Rect;
import android.os.Handler;
import android.os.SystemClock;
import android.util.Log;
@@ -53,17 +52,20 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
private final Handler mHandler = new Handler();
private final KeyguardActivityLauncher mActivityLauncher;
private final Callbacks mCallbacks;
+ private final CameraWidgetInfo mWidgetInfo;
private final WindowManager mWindowManager;
private final Point mRenderedSize = new Point();
- private final int[] mScreenLocation = new int[2];
+ private final int[] mTmpLoc = new int[2];
+ private final Rect mTmpRect = new Rect();
- private View mWidgetView;
private long mLaunchCameraStart;
private boolean mActive;
private boolean mTransitioning;
- private boolean mRecovering;
private boolean mDown;
+ private FixedSizeFrameLayout mPreview;
+ private View mFullscreenPreview;
+
private final Runnable mTransitionToCameraRunnable = new Runnable() {
@Override
public void run() {
@@ -81,19 +83,16 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
mActivityLauncher.launchCamera(worker, mSecureCameraActivityStartedRunnable);
}};
- private final Runnable mRecoverRunnable = new Runnable() {
+ private final Runnable mPostTransitionToCameraEndAction = new Runnable() {
@Override
public void run() {
- recover();
+ mHandler.post(mTransitionToCameraEndAction);
}};
- private final Runnable mRecoverEndAction = new Runnable() {
+ private final Runnable mRecoverRunnable = new Runnable() {
@Override
public void run() {
- if (!mRecovering)
- return;
- mCallbacks.onCameraLaunchedUnsuccessfully();
- reset();
+ recover();
}};
private final Runnable mRenderRunnable = new Runnable() {
@@ -119,13 +118,43 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
};
};
+ private static final class FixedSizeFrameLayout extends FrameLayout {
+ int width;
+ int height;
+
+ FixedSizeFrameLayout(Context context) {
+ super(context);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ measureChildren(
+ MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
+ setMeasuredDimension(width, height);
+ }
+ }
+
private CameraWidgetFrame(Context context, Callbacks callbacks,
- KeyguardActivityLauncher activityLauncher) {
+ KeyguardActivityLauncher activityLauncher,
+ CameraWidgetInfo widgetInfo, View previewWidget) {
super(context);
mCallbacks = callbacks;
mActivityLauncher = activityLauncher;
+ mWidgetInfo = widgetInfo;
mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
KeyguardUpdateMonitor.getInstance(context).registerCallback(mCallback);
+
+ mPreview = new FixedSizeFrameLayout(context);
+ mPreview.addView(previewWidget);
+ addView(mPreview);
+
+ View clickBlocker = new View(context);
+ clickBlocker.setBackgroundColor(Color.TRANSPARENT);
+ clickBlocker.setOnClickListener(this);
+ addView(clickBlocker);
+
+ setContentDescription(context.getString(R.string.keyguard_accessibility_camera));
if (DEBUG) Log.d(TAG, "new CameraWidgetFrame instance " + instanceId());
}
@@ -137,24 +166,17 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
CameraWidgetInfo widgetInfo = launcher.getCameraWidgetInfo();
if (widgetInfo == null)
return null;
- View widgetView = widgetInfo.layoutId > 0 ?
- inflateWidgetView(context, widgetInfo) :
- inflateGenericWidgetView(context);
- if (widgetView == null)
+ View previewWidget = getPreviewWidget(context, widgetInfo);
+ if (previewWidget == null)
return null;
- ImageView preview = new ImageView(context);
- preview.setLayoutParams(new FrameLayout.LayoutParams(
- FrameLayout.LayoutParams.MATCH_PARENT,
- FrameLayout.LayoutParams.MATCH_PARENT));
- preview.setScaleType(ScaleType.FIT_CENTER);
- preview.setContentDescription(preview.getContext().getString(
- R.string.keyguard_accessibility_camera));
- CameraWidgetFrame cameraWidgetFrame = new CameraWidgetFrame(context, callbacks, launcher);
- cameraWidgetFrame.addView(preview);
- cameraWidgetFrame.mWidgetView = widgetView;
- preview.setOnClickListener(cameraWidgetFrame);
- return cameraWidgetFrame;
+ return new CameraWidgetFrame(context, callbacks, launcher, widgetInfo, previewWidget);
+ }
+
+ private static View getPreviewWidget(Context context, CameraWidgetInfo widgetInfo) {
+ return widgetInfo.layoutId > 0 ?
+ inflateWidgetView(context, widgetInfo) :
+ inflateGenericWidgetView(context);
}
private static View inflateWidgetView(Context context, CameraWidgetInfo widgetInfo) {
@@ -188,119 +210,99 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
return iv;
}
- public void render() {
- final Throwable[] thrown = new Throwable[1];
- final Bitmap[] offscreen = new Bitmap[1];
- try {
- final int width = getRootView().getWidth();
- final int height = getRootView().getHeight();
- if (mRenderedSize.x == width && mRenderedSize.y == height) {
- if (DEBUG) Log.d(TAG, String.format("Already rendered at size=%sx%s",
- width, height));
- return;
- }
- if (width == 0 || height == 0) {
- return;
- }
- final long start = SystemClock.uptimeMillis();
- offscreen[0] = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- final Canvas c = new Canvas(offscreen[0]);
- mWidgetView.measure(
- MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
- mWidgetView.layout(0, 0, width, height);
- mWidgetView.draw(c);
-
- final long end = SystemClock.uptimeMillis();
- if (DEBUG) Log.d(TAG, String.format(
- "Rendered camera widget in %sms size=%sx%s instance=%s at %s",
- end - start,
- width, height,
- instanceId(),
- end));
- mRenderedSize.set(width, height);
- } catch (Throwable t) {
- thrown[0] = t;
+ private void render() {
+ final View root = getRootView();
+ final int width = root.getWidth();
+ final int height = root.getHeight();
+ if (mRenderedSize.x == width && mRenderedSize.y == height) {
+ if (DEBUG) Log.d(TAG, String.format("Already rendered at size=%sx%s", width, height));
+ return;
+ }
+ if (width == 0 || height == 0) {
+ return;
}
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- if (thrown[0] == null) {
- try {
- ((ImageView) getChildAt(0)).setImageBitmap(offscreen[0]);
- } catch (Throwable t) {
- thrown[0] = t;
- }
- }
- if (thrown[0] == null)
- return;
-
- Log.w(TAG, "Error rendering camera widget", thrown[0]);
- try {
- removeAllViews();
- final View genericView = inflateGenericWidgetView(mContext);
- addView(genericView);
- } catch (Throwable t) {
- Log.w(TAG, "Error inflating generic camera widget", t);
- }
- }});
- }
-
- private void transitionToCamera() {
- if (mTransitioning || mDown) return;
+ mPreview.width = width;
+ mPreview.height = height;
+ mPreview.requestLayout();
- mTransitioning = true;
+ final int thisWidth = getWidth() - getPaddingLeft() - getPaddingRight();
+ final int thisHeight = getHeight() - getPaddingTop() - getPaddingBottom();
- final View child = getChildAt(0);
- final View root = getRootView();
+ final float pvScaleX = (float) thisWidth / width;
+ final float pvScaleY = (float) thisHeight / height;
+ final float pvScale = Math.min(pvScaleX, pvScaleY);
- final int startWidth = child.getWidth();
- final int startHeight = child.getHeight();
+ final int pvWidth = (int) (pvScale * width);
+ final int pvHeight = (int) (pvScale * height);
- final int finishWidth = root.getWidth();
- final int finishHeight = root.getHeight();
+ final float pvTransX = pvWidth < thisWidth ? (thisWidth - pvWidth) / 2 : 0;
+ final float pvTransY = pvHeight < thisHeight ? (thisHeight - pvHeight) / 2 : 0;
- final float scaleX = (float) finishWidth / startWidth;
- final float scaleY = (float) finishHeight / startHeight;
- final float scale = Math.round( Math.max(scaleX, scaleY) * 100) / 100f;
+ mPreview.setPivotX(0);
+ mPreview.setPivotY(0);
+ mPreview.setScaleX(pvScale);
+ mPreview.setScaleY(pvScale);
+ mPreview.setTranslationX(pvTransX);
+ mPreview.setTranslationY(pvTransY);
- final int[] loc = new int[2];
- root.getLocationInWindow(loc);
- final int finishCenter = loc[1] + finishHeight / 2;
+ mRenderedSize.set(width, height);
+ if (DEBUG) Log.d(TAG, String.format("Rendered camera widget size=%sx%s instance=%s",
+ width, height, instanceId()));
+ }
- child.getLocationInWindow(loc);
- final int startCenter = loc[1] + startHeight / 2;
+ private void transitionToCamera() {
+ if (mTransitioning || mDown) return;
- if (DEBUG) Log.d(TAG, String.format("Transitioning to camera. " +
- "(start=%sx%s, finish=%sx%s, scale=%s,%s, startCenter=%s, finishCenter=%s)",
- startWidth, startHeight,
- finishWidth, finishHeight,
- scaleX, scaleY,
- startCenter, finishCenter));
+ mTransitioning = true;
enableWindowExitAnimation(false);
- animate()
- .scaleX(scale)
- .scaleY(scale)
- .translationY(finishCenter - startCenter)
- .setDuration(WIDGET_ANIMATION_DURATION)
- .withEndAction(mTransitionToCameraEndAction)
- .start();
- mCallbacks.onLaunchingCamera();
- }
+ mPreview.getLocationInWindow(mTmpLoc);
+ final float pvHeight = mPreview.getHeight() * mPreview.getScaleY();
+ final float pvCenter = mTmpLoc[1] + pvHeight / 2f;
- private void recover() {
- if (DEBUG) Log.d(TAG, "recovering at " + SystemClock.uptimeMillis());
- mRecovering = true;
- animate()
+ final ViewGroup root = (ViewGroup) getRootView();
+ if (mFullscreenPreview == null) {
+ mFullscreenPreview = getPreviewWidget(mContext, mWidgetInfo);
+ mFullscreenPreview.setClickable(false);
+ root.addView(mFullscreenPreview);
+ }
+
+ root.getWindowVisibleDisplayFrame(mTmpRect);
+ final float fsHeight = mTmpRect.height();
+ final float fsCenter = mTmpRect.top + fsHeight / 2;
+
+ final float fsScaleY = pvHeight / fsHeight;
+ final float fsTransY = pvCenter - fsCenter;
+ final float fsScaleX = mPreview.getScaleX();
+
+ mPreview.setVisibility(View.GONE);
+ mFullscreenPreview.setVisibility(View.VISIBLE);
+ mFullscreenPreview.setTranslationY(fsTransY);
+ mFullscreenPreview.setScaleX(fsScaleX);
+ mFullscreenPreview.setScaleY(fsScaleY);
+ mFullscreenPreview
+ .animate()
.scaleX(1)
.scaleY(1)
+ .translationX(0)
.translationY(0)
.setDuration(WIDGET_ANIMATION_DURATION)
- .withEndAction(mRecoverEndAction)
+ .withEndAction(mPostTransitionToCameraEndAction)
.start();
+ mCallbacks.onLaunchingCamera();
+ }
+
+ private void recover() {
+ if (DEBUG) Log.d(TAG, "recovering at " + SystemClock.uptimeMillis());
+ mCallbacks.onCameraLaunchedUnsuccessfully();
+ reset();
+ }
+
+ @Override
+ public void setOnLongClickListener(OnLongClickListener l) {
+ // ignore
}
@Override
@@ -340,8 +342,8 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
return true;
}
- getLocationOnScreen(mScreenLocation);
- int rawBottom = mScreenLocation[1] + getHeight();
+ getLocationOnScreen(mTmpLoc);
+ int rawBottom = mTmpLoc[1] + getHeight();
if (event.getRawY() > rawBottom) {
if (DEBUG) Log.d(TAG, "onUserInteraction eaten: below widget");
return true;
@@ -388,14 +390,14 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
if (DEBUG) Log.d(TAG, "reset at " + SystemClock.uptimeMillis());
mLaunchCameraStart = 0;
mTransitioning = false;
- mRecovering = false;
mDown = false;
cancelTransitionToCamera();
mHandler.removeCallbacks(mRecoverRunnable);
- animate().cancel();
- setScaleX(1);
- setScaleY(1);
- setTranslationY(0);
+ mPreview.setVisibility(View.VISIBLE);
+ if (mFullscreenPreview != null) {
+ mFullscreenPreview.animate().cancel();
+ mFullscreenPreview.setVisibility(View.GONE);
+ }
enableWindowExitAnimation(true);
}
@@ -403,11 +405,18 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
if (DEBUG) Log.d(TAG, String.format("onSizeChanged new=%sx%s old=%sx%s at %s",
w, h, oldw, oldh, SystemClock.uptimeMillis()));
- final Handler worker = getWorkerHandler();
- (worker != null ? worker : mHandler).post(mRenderRunnable);
+ mHandler.post(mRenderRunnable);
super.onSizeChanged(w, h, oldw, oldh);
}
+ @Override
+ public void onBouncerShowing(boolean showing) {
+ if (showing) {
+ mTransitioning = false;
+ mHandler.post(mRecoverRunnable);
+ }
+ }
+
private void enableWindowExitAnimation(boolean isEnabled) {
View root = getRootView();
ViewGroup.LayoutParams lp = root.getLayoutParams();
@@ -427,15 +436,14 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
if (DEBUG) Log.d(TAG, "onKeyguardVisibilityChanged " + showing
+ " at " + SystemClock.uptimeMillis());
if (mTransitioning && !showing) {
- mTransitioning = false;
- mRecovering = false;
- mHandler.removeCallbacks(mRecoverRunnable);
- if (mLaunchCameraStart > 0) {
- long launchTime = SystemClock.uptimeMillis() - mLaunchCameraStart;
- if (DEBUG) Log.d(TAG, String.format("Camera took %sms to launch", launchTime));
- mLaunchCameraStart = 0;
- onCameraLaunched();
- }
+ mTransitioning = false;
+ mHandler.removeCallbacks(mRecoverRunnable);
+ if (mLaunchCameraStart > 0) {
+ long launchTime = SystemClock.uptimeMillis() - mLaunchCameraStart;
+ if (DEBUG) Log.d(TAG, String.format("Camera took %sms to launch", launchTime));
+ mLaunchCameraStart = 0;
+ onCameraLaunched();
+ }
}
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/FaceUnlock.java b/policy/src/com/android/internal/policy/impl/keyguard/FaceUnlock.java
index 259f1e4..830471a 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/FaceUnlock.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/FaceUnlock.java
@@ -31,6 +31,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
import android.os.RemoteException;
+import android.os.UserHandle;
import android.util.Log;
import android.view.View;
@@ -214,7 +215,7 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback {
handleServiceDisconnected();
break;
case MSG_UNLOCK:
- handleUnlock();
+ handleUnlock(msg.arg1);
break;
case MSG_CANCEL:
handleCancel();
@@ -297,11 +298,18 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback {
/**
* Stops the Face Unlock service and tells the device to grant access to the user.
*/
- void handleUnlock() {
+ void handleUnlock(int authenticatedUserId) {
if (DEBUG) Log.d(TAG, "handleUnlock()");
stop();
- mKeyguardScreenCallback.reportSuccessfulUnlockAttempt();
- mKeyguardScreenCallback.dismiss(true);
+ int currentUserId = mLockPatternUtils.getCurrentUser();
+ if (authenticatedUserId == currentUserId) {
+ if (DEBUG) Log.d(TAG, "Unlocking for user " + authenticatedUserId);
+ mKeyguardScreenCallback.reportSuccessfulUnlockAttempt();
+ mKeyguardScreenCallback.dismiss(true);
+ } else {
+ Log.d(TAG, "Ignoring unlock for authenticated user (" + authenticatedUserId +
+ ") because the current user is " + currentUserId);
+ }
}
/**
@@ -420,7 +428,8 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback {
*/
public void unlock() {
if (DEBUG) Log.d(TAG, "unlock()");
- mHandler.sendEmptyMessage(MSG_UNLOCK);
+ Message message = mHandler.obtainMessage(MSG_UNLOCK, UserHandle.getCallingUserId(), -1);
+ mHandler.sendMessage(message);
}
/**
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardCircleFramedDrawable.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardCircleFramedDrawable.java
index 29124c4..79b66f4 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardCircleFramedDrawable.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardCircleFramedDrawable.java
@@ -134,7 +134,6 @@ class KeyguardCircleFramedDrawable extends Drawable {
}
public void setScale(float scale) {
- Log.i("KFD", "scale: " + scale);
mScale = scale;
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
index 73580cf..f11d444 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -28,7 +28,6 @@ import android.appwidget.AppWidgetHost;
import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
-import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -91,6 +90,7 @@ public class KeyguardHostView extends KeyguardViewBase {
private int mAppWidgetToShow;
private boolean mCheckAppWidgetConsistencyOnBootCompleted = false;
+ private boolean mCleanupAppWidgetsOnBootCompleted = false;
protected OnDismissAction mDismissAction;
@@ -100,8 +100,6 @@ public class KeyguardHostView extends KeyguardViewBase {
private KeyguardSecurityModel mSecurityModel;
private KeyguardViewStateManager mViewStateManager;
- boolean mPersitentStickyWidgetLoaded = false;
-
private Rect mTempRect = new Rect();
private int mDisabledFeatures;
@@ -110,7 +108,11 @@ public class KeyguardHostView extends KeyguardViewBase {
private boolean mSafeModeEnabled;
- /*package*/ interface TransportCallback {
+ private boolean mUserSetupCompleted;
+ // User for whom this host view was created
+ private int mUserId;
+
+ /*package*/ interface TransportCallback {
void onListenerDetached();
void onListenerAttached();
void onPlayStateChanged();
@@ -135,8 +137,12 @@ public class KeyguardHostView extends KeyguardViewBase {
public KeyguardHostView(Context context, AttributeSet attrs) {
super(context, attrs);
mLockPatternUtils = new LockPatternUtils(context);
+ mUserId = mLockPatternUtils.getCurrentUser();
mAppWidgetHost = new AppWidgetHost(
context, APPWIDGET_HOST_ID, mOnClickHandler, Looper.myLooper());
+ mAppWidgetHost.setUserId(mUserId);
+ cleanupAppWidgetIds();
+
mAppWidgetManager = AppWidgetManager.getInstance(mContext);
mSecurityModel = new KeyguardSecurityModel(context);
@@ -150,6 +156,8 @@ public class KeyguardHostView extends KeyguardViewBase {
}
mSafeModeEnabled = LockPatternUtils.isSafeModeEnabled();
+ mUserSetupCompleted = Settings.Secure.getIntForUser(mContext.getContentResolver(),
+ Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0;
if (mSafeModeEnabled) {
Log.v(TAG, "Keyguard widgets disabled by safe mode");
@@ -162,6 +170,39 @@ public class KeyguardHostView extends KeyguardViewBase {
}
}
+ private void cleanupAppWidgetIds() {
+ // Since this method may delete a widget (which we can't do until boot completed) we
+ // may have to defer it until after boot complete.
+ if (!KeyguardUpdateMonitor.getInstance(mContext).hasBootCompleted()) {
+ mCleanupAppWidgetsOnBootCompleted = true;
+ return;
+ }
+ // Clean up appWidgetIds that are bound to lockscreen, but not actually used
+ // This is only to clean up after another bug: we used to not call
+ // deleteAppWidgetId when a user manually deleted a widget in keyguard. This code
+ // shouldn't have to run more than once per user. AppWidgetProviders rely on callbacks
+ // that are triggered by deleteAppWidgetId, which is why we're doing this
+ int[] appWidgetIdsInKeyguardSettings = mLockPatternUtils.getAppWidgets();
+ int[] appWidgetIdsBoundToHost = mAppWidgetHost.getAppWidgetIds();
+ for (int i = 0; i < appWidgetIdsBoundToHost.length; i++) {
+ int appWidgetId = appWidgetIdsBoundToHost[i];
+ if (!contains(appWidgetIdsInKeyguardSettings, appWidgetId)) {
+ Log.d(TAG, "Found a appWidgetId that's not being used by keyguard, deleting id "
+ + appWidgetId);
+ mAppWidgetHost.deleteAppWidgetId(appWidgetId);
+ }
+ }
+ }
+
+ private static boolean contains(int[] array, int target) {
+ for (int value : array) {
+ if (value == target) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private KeyguardUpdateMonitorCallback mUpdateMonitorCallbacks =
new KeyguardUpdateMonitorCallback() {
@Override
@@ -171,6 +212,10 @@ public class KeyguardHostView extends KeyguardViewBase {
mSwitchPageRunnable.run();
mCheckAppWidgetConsistencyOnBootCompleted = false;
}
+ if (mCleanupAppWidgetsOnBootCompleted) {
+ cleanupAppWidgetIds();
+ mCleanupAppWidgetsOnBootCompleted = false;
+ }
}
};
@@ -241,8 +286,8 @@ public class KeyguardHostView extends KeyguardViewBase {
addDefaultWidgets();
addWidgetsFromSettings();
- if (numWidgets() >= MAX_WIDGETS) {
- setAddWidgetEnabled(false);
+ if (!shouldEnableAddWidget()) {
+ mAppWidgetContainer.setAddWidgetEnabled(false);
}
checkAppWidgetConsistency();
mSwitchPageRunnable.run();
@@ -298,6 +343,10 @@ public class KeyguardHostView extends KeyguardViewBase {
}
}
+ private boolean shouldEnableAddWidget() {
+ return numWidgets() < MAX_WIDGETS && mUserSetupCompleted;
+ }
+
private int getDisabledFeatures(DevicePolicyManager dpm) {
int disabledFeatures = DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_NONE;
if (dpm != null) {
@@ -347,14 +396,14 @@ public class KeyguardHostView extends KeyguardViewBase {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
- mAppWidgetHost.startListening();
+ mAppWidgetHost.startListeningAsUser(mUserId);
KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallbacks);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
- mAppWidgetHost.stopListening();
+ mAppWidgetHost.stopListeningAsUser(mUserId);
KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateMonitorCallbacks);
}
@@ -380,15 +429,26 @@ public class KeyguardHostView extends KeyguardViewBase {
@Override
public void onAddView(View v) {
- if (numWidgets() >= MAX_WIDGETS) {
- setAddWidgetEnabled(false);
+ if (!shouldEnableAddWidget()) {
+ mAppWidgetContainer.setAddWidgetEnabled(false);
}
- };
+ }
+
+ @Override
+ public void onRemoveView(View v, boolean deletePermanently) {
+ if (deletePermanently) {
+ final int appWidgetId = ((KeyguardWidgetFrame) v).getContentAppWidgetId();
+ if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID &&
+ appWidgetId != LockPatternUtils.ID_DEFAULT_STATUS_WIDGET) {
+ mAppWidgetHost.deleteAppWidgetId(appWidgetId);
+ }
+ }
+ }
@Override
- public void onRemoveView(View v) {
- if (numWidgets() < MAX_WIDGETS) {
- setAddWidgetEnabled(true);
+ public void onRemoveViewAnimationCompleted() {
+ if (shouldEnableAddWidget()) {
+ mAppWidgetContainer.setAddWidgetEnabled(true);
}
}
};
@@ -877,6 +937,7 @@ public class KeyguardHostView extends KeyguardViewBase {
mViewStateManager.showUsabilityHints();
}
minimizeChallengeIfDesired();
+ requestFocus();
}
@Override
@@ -896,6 +957,7 @@ public class KeyguardHostView extends KeyguardViewBase {
if (cameraPage != null) {
cameraPage.onScreenTurnedOff();
}
+ clearFocus();
}
public void clearAppWidgetToShow() {
@@ -1060,15 +1122,6 @@ public class KeyguardHostView extends KeyguardViewBase {
return widgetCount;
}
-
- private void setAddWidgetEnabled(boolean clickable) {
- View addWidget = mAppWidgetContainer.findViewById(R.id.keyguard_add_widget);
- if (addWidget != null) {
- View addWidgetButton = addWidget.findViewById(R.id.keyguard_add_widget_view);
- addWidgetButton.setEnabled(clickable);
- }
- }
-
private void addDefaultWidgets() {
LayoutInflater inflater = LayoutInflater.from(mContext);
inflater.inflate(R.layout.keyguard_transport_control_view, this, true);
@@ -1089,7 +1142,7 @@ public class KeyguardHostView extends KeyguardViewBase {
// We currently disable cameras in safe mode because we support loading 3rd party
// cameras we can't trust. TODO: plumb safe mode into camera creation code and only
// inflate system-provided camera?
- if (!mSafeModeEnabled && !cameraDisabledByDpm()
+ if (!mSafeModeEnabled && !cameraDisabledByDpm() && mUserSetupCompleted
&& mContext.getResources().getBoolean(R.bool.kg_enable_camera_default_widget)) {
View cameraWidget =
CameraWidgetFrame.create(mContext, mCameraWidgetCallbacks, mActivityLauncher);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMessageArea.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMessageArea.java
index 68a9645..c4628c0 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMessageArea.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMessageArea.java
@@ -56,7 +56,7 @@ class KeyguardMessageArea extends TextView {
boolean mShowingBouncer = false;
// last known plugged in state
- boolean mPluggedIn = false;
+ boolean mCharging = false;
// last known battery level
int mBatteryLevel = 100;
@@ -138,9 +138,8 @@ class KeyguardMessageArea extends TextView {
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
@Override
public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) {
- // Use the status instead of plugged attribute
- mPluggedIn = status.status == BatteryManager.BATTERY_STATUS_CHARGING ||
- status.status == BatteryManager.BATTERY_STATUS_FULL;
+ mCharging = status.status == BatteryManager.BATTERY_STATUS_CHARGING
+ || status.status == BatteryManager.BATTERY_STATUS_FULL;
mBatteryLevel = status.level;
mBatteryCharged = status.isCharged();
mBatteryIsLow = status.isBatteryLow();
@@ -231,11 +230,11 @@ class KeyguardMessageArea extends TextView {
CharSequence string = null;
if (mShowingBatteryInfo && !mShowingMessage) {
// Battery status
- if (mPluggedIn) {
- // Charging, charged.
- string = getContext().getString(mBatteryCharged ?
- com.android.internal.R.string.lockscreen_charged
- :com.android.internal.R.string.lockscreen_plugged_in, mBatteryLevel);
+ if (mCharging) {
+ // Charging, charged or waiting to charge.
+ string = getContext().getString(mBatteryCharged
+ ? com.android.internal.R.string.lockscreen_charged
+ : com.android.internal.R.string.lockscreen_plugged_in, mBatteryLevel);
icon.value = CHARGING_ICON;
} else if (mBatteryIsLow) {
// Battery is low
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardTransportControlView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardTransportControlView.java
index d284602..ffa88d5 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardTransportControlView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardTransportControlView.java
@@ -189,7 +189,7 @@ public class KeyguardTransportControlView extends FrameLayout implements OnClick
public KeyguardTransportControlView(Context context, AttributeSet attrs) {
super(context, attrs);
- Log.v(TAG, "Create TCV " + this);
+ if (DEBUG) Log.v(TAG, "Create TCV " + this);
mAudioManager = new AudioManager(mContext);
mCurrentPlayState = RemoteControlClient.PLAYSTATE_NONE; // until we get a callback
mIRCD = new IRemoteControlDisplayWeak(mHandler);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
index 5346ecd..d446646 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
@@ -37,6 +37,7 @@ import android.os.Handler;
import android.os.IRemoteCallback;
import android.os.Message;
import android.os.RemoteException;
+import android.os.UserHandle;
import android.provider.Settings;
import com.android.internal.telephony.IccCardConstants;
@@ -113,7 +114,7 @@ public class KeyguardUpdateMonitor {
private final ArrayList<WeakReference<KeyguardUpdateMonitorCallback>>
mCallbacks = Lists.newArrayList();
- private ContentObserver mContentObserver;
+ private ContentObserver mDeviceProvisionedObserver;
private final Handler mHandler = new Handler() {
@Override
@@ -322,9 +323,7 @@ public class KeyguardUpdateMonitor {
private KeyguardUpdateMonitor(Context context) {
mContext = context;
- mDeviceProvisioned = Settings.Global.getInt(
- mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0;
-
+ mDeviceProvisioned = isDeviceProvisionedInSettingsDb();
// Since device can't be un-provisioned, we only need to register a content observer
// to update mDeviceProvisioned when we are...
if (!mDeviceProvisioned) {
@@ -373,13 +372,17 @@ public class KeyguardUpdateMonitor {
}
}
+ private boolean isDeviceProvisionedInSettingsDb() {
+ return Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.DEVICE_PROVISIONED, 0) != 0;
+ }
+
private void watchForDeviceProvisioning() {
- mContentObserver = new ContentObserver(mHandler) {
+ mDeviceProvisionedObserver = new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
- mDeviceProvisioned = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.DEVICE_PROVISIONED, 0) != 0;
+ mDeviceProvisioned = isDeviceProvisionedInSettingsDb();
if (mDeviceProvisioned) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_DEVICE_PROVISIONED));
}
@@ -389,12 +392,11 @@ public class KeyguardUpdateMonitor {
mContext.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED),
- false, mContentObserver);
+ false, mDeviceProvisionedObserver);
// prevent a race condition between where we check the flag and where we register the
// observer by grabbing the value once again...
- boolean provisioned = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.DEVICE_PROVISIONED, 0) != 0;
+ boolean provisioned = isDeviceProvisionedInSettingsDb();
if (provisioned != mDeviceProvisioned) {
mDeviceProvisioned = provisioned;
if (mDeviceProvisioned) {
@@ -475,10 +477,10 @@ public class KeyguardUpdateMonitor {
cb.onDeviceProvisioned();
}
}
- if (mContentObserver != null) {
+ if (mDeviceProvisionedObserver != null) {
// We don't need the observer anymore...
- mContext.getContentResolver().unregisterContentObserver(mContentObserver);
- mContentObserver = null;
+ mContext.getContentResolver().unregisterContentObserver(mDeviceProvisionedObserver);
+ mDeviceProvisionedObserver = null;
}
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
index 2d12d12..b8f3c10 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
@@ -26,6 +26,7 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.media.AudioManager;
+import android.graphics.Rect;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
@@ -134,14 +135,27 @@ public class KeyguardViewManager {
}
@Override
+ protected boolean fitSystemWindows(Rect insets) {
+ Log.v("TAG", "bug 7643792: fitSystemWindows(" + insets.toShortString() + ")");
+ return super.fitSystemWindows(insets);
+ }
+
+ @Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- if (mKeyguardHost.getVisibility() == View.VISIBLE) {
- // only propagate configuration messages if we're currently showing
- maybeCreateKeyguardLocked(shouldEnableScreenRotation(), true, null);
- } else {
- if (DEBUG) Log.v(TAG, "onConfigurationChanged: view not visible");
- }
+ post(new Runnable() {
+ @Override
+ public void run() {
+ synchronized (KeyguardViewManager.this) {
+ if (mKeyguardHost.getVisibility() == View.VISIBLE) {
+ // only propagate configuration messages if we're currently showing
+ maybeCreateKeyguardLocked(shouldEnableScreenRotation(), true, null);
+ } else {
+ if (DEBUG) Log.v(TAG, "onConfigurationChanged: view not visible");
+ }
+ }
+ }
+ });
}
@Override
@@ -342,6 +356,7 @@ public class KeyguardViewManager {
if (force || mKeyguardView == null) {
inflateKeyguardView(options);
+ mKeyguardView.requestFocus();
}
updateUserActivityTimeoutInWindowLayoutParams();
mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams);
@@ -376,12 +391,6 @@ public class KeyguardViewManager {
}
if (options != null) {
- if (options.getBoolean(LockPatternUtils.KEYGUARD_SHOW_USER_SWITCHER)) {
- mKeyguardView.goToUserSwitcher();
- }
- if (options.getBoolean(LockPatternUtils.KEYGUARD_SHOW_SECURITY_CHALLENGE)) {
- mKeyguardView.showNextSecurityScreenIfPresent();
- }
int widgetToShow = options.getInt(LockPatternUtils.KEYGUARD_SHOW_APPWIDGET,
AppWidgetManager.INVALID_APPWIDGET_ID);
if (widgetToShow != AppWidgetManager.INVALID_APPWIDGET_ID) {
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
index 03be9ce..a39b2f7 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
@@ -24,6 +24,7 @@ import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Profile;
import android.app.ProfileManager;
+import android.app.SearchManager;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
@@ -168,6 +169,9 @@ public class KeyguardViewMediator {
/** UserManager for querying number of users */
private UserManager mUserManager;
+ /** SearchManager for determining whether or not search assistant is available */
+ private SearchManager mSearchManager;
+
/**
* Used to keep the device awake while to ensure the keyguard finishes opening before
* we sleep.
@@ -317,10 +321,7 @@ public class KeyguardViewMediator {
// We need to force a reset of the views, since lockNow (called by
// ActivityManagerService) will not reconstruct the keyguard if it is already showing.
synchronized (KeyguardViewMediator.this) {
- Bundle options = new Bundle();
- options.putBoolean(LockPatternUtils.KEYGUARD_SHOW_USER_SWITCHER, true);
- options.putBoolean(LockPatternUtils.KEYGUARD_SHOW_SECURITY_CHALLENGE, true);
- resetStateLocked(options);
+ resetStateLocked(null);
adjustStatusBarLocked();
// Disable face unlock when the user switches.
KeyguardUpdateMonitor.getInstance(mContext).setAlternateUnlockEnabled(false);
@@ -535,6 +536,7 @@ public class KeyguardViewMediator {
* Let us know that the system is ready after startup.
*/
public void onSystemReady() {
+ mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
synchronized (this) {
if (DEBUG) Log.d(TAG, "onSystemReady");
mSystemReady = true;
@@ -1354,6 +1356,9 @@ public class KeyguardViewMediator {
// showing secure lockscreen; disable ticker.
flags |= StatusBarManager.DISABLE_NOTIFICATION_TICKER;
}
+ if (!isAssistantAvailable()) {
+ flags |= StatusBarManager.DISABLE_SEARCH;
+ }
}
if (DEBUG) {
@@ -1451,4 +1456,8 @@ public class KeyguardViewMediator {
mKeyguardViewManager.showAssistant();
}
+ private boolean isAssistantAvailable() {
+ return mSearchManager != null
+ && mSearchManager.getAssistIntent(mContext, UserHandle.USER_CURRENT) != null;
+ }
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetCarousel.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetCarousel.java
index debf765..257fd27 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetCarousel.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetCarousel.java
@@ -16,7 +16,6 @@
package com.android.internal.policy.impl.keyguard;
import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
@@ -27,10 +26,10 @@ import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
-import java.util.ArrayList;
-
import com.android.internal.R;
+import java.util.ArrayList;
+
public class KeyguardWidgetCarousel extends KeyguardWidgetPager {
private float mAdjacentPagesAngle;
@@ -56,17 +55,30 @@ public class KeyguardWidgetCarousel extends KeyguardWidgetPager {
return MAX_SCROLL_PROGRESS;
}
- public float getAlphaForPage(int screenCenter, int index) {
+ public float getAlphaForPage(int screenCenter, int index, boolean showSidePages) {
View child = getChildAt(index);
if (child == null) return 0f;
+ boolean inVisibleRange = index >= getNextPage() - 1 && index <= getNextPage() + 1;
float scrollProgress = getScrollProgress(screenCenter, child, index);
- if (!isOverScrollChild(index, scrollProgress)) {
+
+ if (isOverScrollChild(index, scrollProgress)) {
+ return 1.0f;
+ } else if ((showSidePages && inVisibleRange) || index == getNextPage()) {
scrollProgress = getBoundedScrollProgress(screenCenter, child, index);
float alpha = 1.0f - 1.0f * Math.abs(scrollProgress / MAX_SCROLL_PROGRESS);
return alpha;
} else {
- return 1.0f;
+ return 0f;
+ }
+ }
+
+ public float getOutlineAlphaForPage(int screenCenter, int index, boolean showSidePages) {
+ boolean inVisibleRange = index >= getNextPage() - 1 && index <= getNextPage() + 1;
+ if (inVisibleRange) {
+ return super.getOutlineAlphaForPage(screenCenter, index, showSidePages);
+ } else {
+ return 0f;
}
}
@@ -75,24 +87,32 @@ public class KeyguardWidgetCarousel extends KeyguardWidgetPager {
mChildrenOutlineFadeAnimation.cancel();
mChildrenOutlineFadeAnimation = null;
}
+ boolean showSidePages = mShowingInitialHints || isPageMoving();
if (!isReordering(false)) {
for (int i = 0; i < getChildCount(); i++) {
KeyguardWidgetFrame child = getWidgetPageAt(i);
if (child != null) {
- child.setBackgroundAlpha(getOutlineAlphaForPage(screenCenter, i));
- child.setContentAlpha(getAlphaForPage(screenCenter, i));
+ float outlineAlpha = getOutlineAlphaForPage(screenCenter, i, showSidePages);
+ float contentAlpha = getAlphaForPage(screenCenter, i,showSidePages);
+ child.setBackgroundAlpha(outlineAlpha);
+ child.setContentAlpha(contentAlpha);
}
}
}
}
public void showInitialPageHints() {
+ mShowingInitialHints = true;
int count = getChildCount();
for (int i = 0; i < count; i++) {
+ boolean inVisibleRange = i >= getNextPage() - 1 && i <= getNextPage() + 1;
KeyguardWidgetFrame child = getWidgetPageAt(i);
- if (i >= mCurrentPage - 1 && i <= mCurrentPage + 1) {
- child.fadeFrame(this, true, KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER,
- CHILDREN_OUTLINE_FADE_IN_DURATION);
+ if (inVisibleRange) {
+ child.setBackgroundAlpha(KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER);
+ child.setContentAlpha(1f);
+ } else {
+ child.setBackgroundAlpha(0f);
+ child.setContentAlpha(0f);
}
}
}
@@ -220,8 +240,8 @@ public class KeyguardWidgetCarousel extends KeyguardWidgetPager {
for (int i = 0; i < count; i++) {
KeyguardWidgetFrame child = getWidgetPageAt(i);
- float finalAlpha = getAlphaForPage(mScreenCenter, i);
- float finalOutlineAlpha = getOutlineAlphaForPage(mScreenCenter, i);
+ float finalAlpha = getAlphaForPage(mScreenCenter, i, true);
+ float finalOutlineAlpha = getOutlineAlphaForPage(mScreenCenter, i, true);
getTransformForPage(mScreenCenter, i, mTmpTransform);
boolean inVisibleRange = (i >= mCurrentPage - 1 && i <= mCurrentPage + 1);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetFrame.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetFrame.java
index 3c79206..babb9cb 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetFrame.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetFrame.java
@@ -424,7 +424,9 @@ public class KeyguardWidgetFrame extends FrameLayout {
mBgAlphaController = caller;
}
- if (mBgAlphaController != caller) return;
+ if (mBgAlphaController != caller && mBgAlphaController != null) {
+ return;
+ }
if (mFrameFade != null) {
mFrameFade.cancel();
@@ -512,6 +514,10 @@ public class KeyguardWidgetFrame extends FrameLayout {
return false;
}
+ public void onBouncerShowing(boolean showing) {
+ // hook for subclasses
+ }
+
public void setWorkerHandler(Handler workerHandler) {
mWorkerHandler = workerHandler;
}
@@ -519,4 +525,5 @@ public class KeyguardWidgetFrame extends FrameLayout {
public Handler getWorkerHandler() {
return mWorkerHandler;
}
+
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java
index 2d36d05..db87a291 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java
@@ -75,6 +75,12 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
private Callbacks mCallbacks;
private int mWidgetToResetAfterFadeOut;
+ protected boolean mShowingInitialHints = false;
+
+ // A temporary handle to the Add-Widget view
+ private View mAddWidgetView;
+ private int mLastWidthMeasureSpec;
+ private int mLastHeightMeasureSpec;
// Bouncer
private int mBouncerZoomInOutDuration = 250;
@@ -252,18 +258,18 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
public void userActivity();
public void onUserActivityTimeoutChanged();
public void onAddView(View v);
- public void onRemoveView(View v);
+ public void onRemoveView(View v, boolean deletePermanently);
+ public void onRemoveViewAnimationCompleted();
}
public void addWidget(View widget) {
addWidget(widget, -1);
}
-
- public void onRemoveView(View v) {
+ public void onRemoveView(View v, final boolean deletePermanently) {
final int appWidgetId = ((KeyguardWidgetFrame) v).getContentAppWidgetId();
if (mCallbacks != null) {
- mCallbacks.onRemoveView(v);
+ mCallbacks.onRemoveView(v, deletePermanently);
}
mBackgroundWorkerHandler.post(new Runnable() {
@Override
@@ -273,6 +279,13 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
});
}
+ @Override
+ public void onRemoveViewAnimationCompleted() {
+ if (mCallbacks != null) {
+ mCallbacks.onRemoveViewAnimationCompleted();
+ }
+ }
+
public void onAddView(View v, final int index) {
final int appWidgetId = ((KeyguardWidgetFrame) v).getContentAppWidgetId();
final int[] pagesRange = new int[mTempVisiblePagesRange.length];
@@ -473,12 +486,21 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
private void updatePageAlphaValues(int screenCenter) {
}
- public float getAlphaForPage(int screenCenter, int index) {
- return 1f;
+ public float getAlphaForPage(int screenCenter, int index, boolean showSidePages) {
+ if (showSidePages) {
+ return 1f;
+ } else {
+ return index == mCurrentPage ? 1.0f : 0f;
+ }
}
- public float getOutlineAlphaForPage(int screenCenter, int index) {
- return getAlphaForPage(screenCenter, index) * KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER;
+ public float getOutlineAlphaForPage(int screenCenter, int index, boolean showSidePages) {
+ if (showSidePages) {
+ return getAlphaForPage(screenCenter, index, showSidePages)
+ * KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER;
+ } else {
+ return 0f;
+ }
}
protected boolean isOverScrollChild(int index, float scrollProgress) {
@@ -578,12 +600,12 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
}
public void showInitialPageHints() {
+ mShowingInitialHints = true;
int count = getChildCount();
for (int i = 0; i < count; i++) {
KeyguardWidgetFrame child = getWidgetPageAt(i);
if (i != mCurrentPage) {
- child.fadeFrame(this, true, KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER,
- CHILDREN_OUTLINE_FADE_IN_DURATION);
+ child.setBackgroundAlpha(KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER);
child.setContentAlpha(0f);
} else {
child.setBackgroundAlpha(0f);
@@ -592,10 +614,6 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
}
}
- public void showSidePageHints() {
- animateOutlinesAndSidePages(true, -1);
- }
-
@Override
void setCurrentPage(int currentPage) {
super.setCurrentPage(currentPage);
@@ -608,12 +626,10 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
mHasMeasure = false;
}
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- super.onLayout(changed, left, top, right, bottom);
- }
-
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ mLastWidthMeasureSpec = widthMeasureSpec;
+ mLastHeightMeasureSpec = heightMeasureSpec;
+
int maxChallengeTop = -1;
View parent = (View) getParent();
boolean challengeShowing = false;
@@ -674,7 +690,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
for (int i = 0; i < count; i++) {
float finalContentAlpha;
if (show) {
- finalContentAlpha = getAlphaForPage(mScreenCenter, i);
+ finalContentAlpha = getAlphaForPage(mScreenCenter, i, true);
} else if (!show && i == curPage) {
finalContentAlpha = 1f;
} else {
@@ -686,7 +702,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
ObjectAnimator a = ObjectAnimator.ofPropertyValuesHolder(child, alpha);
anims.add(a);
- float finalOutlineAlpha = show ? getOutlineAlphaForPage(mScreenCenter, i) : 0f;
+ float finalOutlineAlpha = show ? getOutlineAlphaForPage(mScreenCenter, i, true) : 0f;
child.fadeFrame(this, show, finalOutlineAlpha, duration);
}
@@ -712,6 +728,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
frame.resetSize();
}
mWidgetToResetAfterFadeOut = -1;
+ mShowingInitialHints = false;
}
updateWidgetFramesImportantForAccessibility();
}
@@ -791,6 +808,9 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
mZoomInOutAnim.setInterpolator(new DecelerateInterpolator(1.5f));
mZoomInOutAnim.start();
}
+ if (currentPage instanceof KeyguardWidgetFrame) {
+ ((KeyguardWidgetFrame)currentPage).onBouncerShowing(false);
+ }
}
// Zoom out after the bouncer is initiated
@@ -816,6 +836,27 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
mZoomInOutAnim.setInterpolator(new DecelerateInterpolator(1.5f));
mZoomInOutAnim.start();
}
+ if (currentPage instanceof KeyguardWidgetFrame) {
+ ((KeyguardWidgetFrame)currentPage).onBouncerShowing(true);
+ }
+ }
+
+ void setAddWidgetEnabled(boolean enabled) {
+ if (mAddWidgetView != null && enabled) {
+ addView(mAddWidgetView, 0);
+ // We need to force measure the PagedView so that the calls to update the scroll
+ // position below work
+ measure(mLastWidthMeasureSpec, mLastHeightMeasureSpec);
+ // Bump up the current page to account for the addition of the new page
+ setCurrentPage(mCurrentPage + 1);
+ mAddWidgetView = null;
+ } else if (mAddWidgetView == null && !enabled) {
+ View addWidget = findViewById(com.android.internal.R.id.keyguard_add_widget);
+ if (addWidget != null) {
+ mAddWidgetView = addWidget;
+ removeView(addWidget);
+ }
+ }
}
boolean isAddPage(int pageIndex) {
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java b/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java
index 3900ab4..539ec1a 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/PagedView.java
@@ -1019,15 +1019,22 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
return (x > (getViewportOffsetX() + getViewportWidth() - getRelativeChildOffset(mCurrentPage) + mPageSpacing));
}
- /** Returns whether x and y originated within the buffered/unbuffered viewport */
- private boolean isTouchPointInViewport(int x, int y, boolean buffer) {
- if (buffer) {
- mTmpRect.set(mViewport.left - mViewport.width() / 2, mViewport.top,
- mViewport.right + mViewport.width() / 2, mViewport.bottom);
+ /** Returns whether x and y originated within the buffered viewport */
+ private boolean isTouchPointInViewportWithBuffer(int x, int y) {
+ mTmpRect.set(mViewport.left - mViewport.width() / 2, mViewport.top,
+ mViewport.right + mViewport.width() / 2, mViewport.bottom);
+ return mTmpRect.contains(x, y);
+ }
+
+ /** Returns whether x and y originated within the current page view bounds */
+ private boolean isTouchPointInCurrentPage(int x, int y) {
+ View v = getPageAt(getCurrentPage());
+ if (v != null) {
+ mTmpRect.set((v.getLeft() - getScrollX()), 0, (v.getRight() - getScrollX()),
+ v.getBottom());
return mTmpRect.contains(x, y);
- } else {
- return mViewport.contains(x, y);
}
+ return false;
}
@Override
@@ -1108,7 +1115,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
mTouchState = TOUCH_STATE_REST;
mScroller.abortAnimation();
} else {
- if (isTouchPointInViewport((int) mDownMotionX, (int) mDownMotionY, true)) {
+ if (isTouchPointInViewportWithBuffer((int) mDownMotionX, (int) mDownMotionY)) {
mTouchState = TOUCH_STATE_SCROLLING;
} else {
mTouchState = TOUCH_STATE_REST;
@@ -1135,7 +1142,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
case MotionEvent.ACTION_CANCEL:
resetTouchState();
// Just intercept the touch event on up if we tap outside the strict viewport
- if (!isTouchPointInViewport((int) mLastMotionX, (int) mLastMotionY, false)) {
+ if (!isTouchPointInCurrentPage((int) mLastMotionX, (int) mLastMotionY)) {
return true;
}
break;
@@ -1169,7 +1176,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// Disallow scrolling if we started the gesture from outside the viewport
final float x = ev.getX(pointerIndex);
final float y = ev.getY(pointerIndex);
- if (!isTouchPointInViewport((int) x, (int) y, true)) return;
+ if (!isTouchPointInViewportWithBuffer((int) x, (int) y)) return;
// If we're only allowing edge swipes, we break out early if the down event wasn't
// at the edge.
@@ -1457,7 +1464,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
removeView(mDragView);
- onRemoveView(mDragView);
+ onRemoveView(mDragView, false);
addView(mDragView, pageUnderPointIndex);
onAddView(mDragView, pageUnderPointIndex);
mSidePageHoverIndex = -1;
@@ -1587,7 +1594,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
//public abstract void onFlingToDelete(View v);
- public abstract void onRemoveView(View v);
+ public abstract void onRemoveView(View v, boolean deletePermanently);
+ public abstract void onRemoveViewAnimationCompleted();
public abstract void onAddView(View v, int index);
private void resetTouchState() {
@@ -2383,6 +2391,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
public void run() {
mDeferringForDelete = false;
onEndReordering();
+ onRemoveViewAnimationCompleted();
}
};
zoomIn(onCompleteRunnable);
@@ -2391,7 +2400,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
slideAnimations.start();
removeView(dragView);
- onRemoveView(dragView);
+ onRemoveView(dragView, true);
}
};
}