am f1424272: am 1aad5be9: am 835579e8: Merge "Removing sticky widgets in lockscreen" into jb-mr1-lockscreen-dev
* commit 'f142427244dde3e467b126df4840f496e09cef56': Removing sticky widgets in lockscreen
This commit is contained in:
@@ -110,6 +110,11 @@ public class LockPatternUtils {
|
|||||||
*/
|
*/
|
||||||
public static final String KEYGUARD_SHOW_SECURITY_CHALLENGE = "showsecuritychallenge";
|
public static final String KEYGUARD_SHOW_SECURITY_CHALLENGE = "showsecuritychallenge";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells the keyguard to show the widget with the specified id when the keyguard is created.
|
||||||
|
*/
|
||||||
|
public static final String KEYGUARD_SHOW_APPWIDGET = "showappwidget";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options used to lock the device upon user switch.
|
* Options used to lock the device upon user switch.
|
||||||
*/
|
*/
|
||||||
@@ -1183,21 +1188,6 @@ public class LockPatternUtils {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStickyAppWidgetIndex() {
|
|
||||||
return Settings.Secure.getIntForUser(
|
|
||||||
mContentResolver,
|
|
||||||
Settings.Secure.LOCK_SCREEN_STICKY_APPWIDGET,
|
|
||||||
-1,
|
|
||||||
UserHandle.USER_CURRENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStickyAppWidgetIndex(int value) {
|
|
||||||
Settings.Secure.putIntForUser(mContentResolver,
|
|
||||||
Settings.Secure.LOCK_SCREEN_STICKY_APPWIDGET,
|
|
||||||
value,
|
|
||||||
UserHandle.USER_CURRENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
private long getLong(String secureSettingKey, long defaultValue) {
|
private long getLong(String secureSettingKey, long defaultValue) {
|
||||||
try {
|
try {
|
||||||
return getLockSettings().getLong(secureSettingKey, defaultValue,
|
return getLockSettings().getLong(secureSettingKey, defaultValue,
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ import android.os.Looper;
|
|||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -75,6 +73,7 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
private boolean mIsVerifyUnlockOnly;
|
private boolean mIsVerifyUnlockOnly;
|
||||||
private boolean mEnableFallback; // TODO: This should get the value from KeyguardPatternView
|
private boolean mEnableFallback; // TODO: This should get the value from KeyguardPatternView
|
||||||
private SecurityMode mCurrentSecuritySelection = SecurityMode.Invalid;
|
private SecurityMode mCurrentSecuritySelection = SecurityMode.Invalid;
|
||||||
|
private int mAppWidgetToShow;
|
||||||
|
|
||||||
protected Runnable mLaunchRunnable;
|
protected Runnable mLaunchRunnable;
|
||||||
|
|
||||||
@@ -84,7 +83,6 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
private KeyguardSecurityModel mSecurityModel;
|
private KeyguardSecurityModel mSecurityModel;
|
||||||
private KeyguardViewStateManager mViewStateManager;
|
private KeyguardViewStateManager mViewStateManager;
|
||||||
|
|
||||||
int mLocalStickyWidget = -1;
|
|
||||||
boolean mPersitentStickyWidgetLoaded = false;
|
boolean mPersitentStickyWidgetLoaded = false;
|
||||||
|
|
||||||
private Rect mTempRect = new Rect();
|
private Rect mTempRect = new Rect();
|
||||||
@@ -768,7 +766,6 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
// Once the screen turns off, we no longer consider this to be first boot and we want the
|
// Once the screen turns off, we no longer consider this to be first boot and we want the
|
||||||
// biometric unlock to start next time keyguard is shown.
|
// biometric unlock to start next time keyguard is shown.
|
||||||
KeyguardUpdateMonitor.getInstance(mContext).setAlternateUnlockEnabled(true);
|
KeyguardUpdateMonitor.getInstance(mContext).setAlternateUnlockEnabled(true);
|
||||||
saveStickyWidgetIndex();
|
|
||||||
checkAppWidgetConsistency();
|
checkAppWidgetConsistency();
|
||||||
showPrimarySecurityScreen(true);
|
showPrimarySecurityScreen(true);
|
||||||
getSecurityView(mCurrentSecuritySelection).onPause();
|
getSecurityView(mCurrentSecuritySelection).onPause();
|
||||||
@@ -967,7 +964,7 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
initializeTransportControl();
|
initializeTransportControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeTransportFromWidgetPager() {
|
private boolean removeTransportFromWidgetPager() {
|
||||||
int page = getWidgetPosition(R.id.keyguard_transport_control);
|
int page = getWidgetPosition(R.id.keyguard_transport_control);
|
||||||
if (page != -1) {
|
if (page != -1) {
|
||||||
mAppWidgetContainer.removeWidget(mTransportControl);
|
mAppWidgetContainer.removeWidget(mTransportControl);
|
||||||
@@ -976,8 +973,9 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
KeyguardHostView.this.addView(mTransportControl);
|
KeyguardHostView.this.addView(mTransportControl);
|
||||||
mTransportControl.setVisibility(View.GONE);
|
mTransportControl.setVisibility(View.GONE);
|
||||||
mViewStateManager.setTransportState(KeyguardViewStateManager.TRANSPORT_GONE);
|
mViewStateManager.setTransportState(KeyguardViewStateManager.TRANSPORT_GONE);
|
||||||
mTransportControl.post(mSwitchPageRunnable);
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTransportToWidgetPager() {
|
private void addTransportToWidgetPager() {
|
||||||
@@ -1006,8 +1004,9 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
mTransportControl.setKeyguardCallback(new TransportCallback() {
|
mTransportControl.setKeyguardCallback(new TransportCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onListenerDetached() {
|
public void onListenerDetached() {
|
||||||
removeTransportFromWidgetPager();
|
if (removeTransportFromWidgetPager()) {
|
||||||
mTransportControl.post(mSwitchPageRunnable);
|
mTransportControl.post(mSwitchPageRunnable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1183,7 +1182,6 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
@Override
|
@Override
|
||||||
public Parcelable onSaveInstanceState() {
|
public Parcelable onSaveInstanceState() {
|
||||||
if (DEBUG) Log.d(TAG, "onSaveInstanceState");
|
if (DEBUG) Log.d(TAG, "onSaveInstanceState");
|
||||||
saveStickyWidgetIndex();
|
|
||||||
Parcelable superState = super.onSaveInstanceState();
|
Parcelable superState = super.onSaveInstanceState();
|
||||||
SavedState ss = new SavedState(superState);
|
SavedState ss = new SavedState(superState);
|
||||||
ss.transportState = mViewStateManager.getTransportState();
|
ss.transportState = mViewStateManager.getTransportState();
|
||||||
@@ -1207,9 +1205,7 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
public void onWindowFocusChanged(boolean hasWindowFocus) {
|
public void onWindowFocusChanged(boolean hasWindowFocus) {
|
||||||
super.onWindowFocusChanged(hasWindowFocus);
|
super.onWindowFocusChanged(hasWindowFocus);
|
||||||
if (DEBUG) Log.d(TAG, "Window is " + (hasWindowFocus ? "focused" : "unfocused"));
|
if (DEBUG) Log.d(TAG, "Window is " + (hasWindowFocus ? "focused" : "unfocused"));
|
||||||
if (!hasWindowFocus) {
|
if (hasWindowFocus && mShowSecurityWhenReturn) {
|
||||||
saveStickyWidgetIndex();
|
|
||||||
} else if (mShowSecurityWhenReturn) {
|
|
||||||
SlidingChallengeLayout slider =
|
SlidingChallengeLayout slider =
|
||||||
(SlidingChallengeLayout) findViewById(R.id.sliding_layout);
|
(SlidingChallengeLayout) findViewById(R.id.sliding_layout);
|
||||||
if (slider != null) {
|
if (slider != null) {
|
||||||
@@ -1243,31 +1239,13 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getStickyWidget() {
|
private boolean isWidgetPage(int pageIndex) {
|
||||||
// The first time we query the persistent state. From that point, we use a locally updated
|
View v = mAppWidgetContainer.getChildAt(pageIndex);
|
||||||
// notion of the sticky widget page.
|
if (v != null && v instanceof KeyguardWidgetFrame) {
|
||||||
if (!mPersitentStickyWidgetLoaded) {
|
KeyguardWidgetFrame kwf = (KeyguardWidgetFrame) v;
|
||||||
mLocalStickyWidget = mLockPatternUtils.getStickyAppWidgetIndex();
|
return kwf.getContentAppWidgetId() != AppWidgetManager.INVALID_APPWIDGET_ID;
|
||||||
mPersitentStickyWidgetLoaded = true;
|
|
||||||
}
|
}
|
||||||
return mLocalStickyWidget;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
public void updateStickyWidget(int index) {
|
|
||||||
if (index < 0 || index >= mAppWidgetContainer.getChildCount()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mAppWidgetContainer.isAddPage(index)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mAppWidgetContainer.isCameraPage(index)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isMusicPage(index)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mLocalStickyWidget = index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isMusicPage(int pageIndex) {
|
boolean isMusicPage(int pageIndex) {
|
||||||
@@ -1276,23 +1254,23 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
|
|
||||||
private int getAppropriateWidgetPage(boolean isMusicPlaying) {
|
private int getAppropriateWidgetPage(boolean isMusicPlaying) {
|
||||||
// assumes at least one widget (besides camera + add)
|
// assumes at least one widget (besides camera + add)
|
||||||
|
if (mAppWidgetToShow != AppWidgetManager.INVALID_APPWIDGET_ID) {
|
||||||
|
final int childCount = mAppWidgetContainer.getChildCount();
|
||||||
|
for (int i = 0; i < childCount; i++) {
|
||||||
|
if (mAppWidgetContainer.getWidgetPageAt(i).getContentAppWidgetId()
|
||||||
|
== mAppWidgetToShow) {
|
||||||
|
mAppWidgetToShow = AppWidgetManager.INVALID_APPWIDGET_ID;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mAppWidgetToShow = AppWidgetManager.INVALID_APPWIDGET_ID;
|
||||||
|
}
|
||||||
// if music playing, show transport
|
// if music playing, show transport
|
||||||
if (isMusicPlaying) {
|
if (isMusicPlaying) {
|
||||||
if (DEBUG) Log.d(TAG, "Music playing, show transport");
|
if (DEBUG) Log.d(TAG, "Music playing, show transport");
|
||||||
return mAppWidgetContainer.getWidgetPageIndex(mTransportControl);
|
return mAppWidgetContainer.getWidgetPageIndex(mTransportControl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we have a valid sticky widget, show it
|
|
||||||
int stickyWidgetIndex = getStickyWidget();
|
|
||||||
if (stickyWidgetIndex > -1
|
|
||||||
&& stickyWidgetIndex < mAppWidgetContainer.getChildCount()
|
|
||||||
&& !mAppWidgetContainer.isAddPage(stickyWidgetIndex)
|
|
||||||
&& !mAppWidgetContainer.isCameraPage(stickyWidgetIndex)) {
|
|
||||||
if (DEBUG) Log.d(TAG, "Valid sticky widget found, show page " + stickyWidgetIndex);
|
|
||||||
return stickyWidgetIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
// else show the right-most widget (except for camera)
|
// else show the right-most widget (except for camera)
|
||||||
int rightMost = mAppWidgetContainer.getChildCount() - 1;
|
int rightMost = mAppWidgetContainer.getChildCount() - 1;
|
||||||
if (mAppWidgetContainer.isCameraPage(rightMost)) {
|
if (mAppWidgetContainer.isCameraPage(rightMost)) {
|
||||||
@@ -1302,13 +1280,6 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
return rightMost;
|
return rightMost;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveStickyWidgetIndex() {
|
|
||||||
if (DEBUG) Log.d(TAG, "saveStickyWidgetIndex: " + mLocalStickyWidget);
|
|
||||||
if (mPersitentStickyWidgetLoaded && mLocalStickyWidget >= 0) {
|
|
||||||
mLockPatternUtils.setStickyAppWidgetIndex(mLocalStickyWidget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enableUserSelectorIfNecessary() {
|
private void enableUserSelectorIfNecessary() {
|
||||||
if (!UserManager.supportsMultipleUsers()) {
|
if (!UserManager.supportsMultipleUsers()) {
|
||||||
return; // device doesn't support multi-user mode
|
return; // device doesn't support multi-user mode
|
||||||
@@ -1380,6 +1351,11 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
mAppWidgetContainer.setCurrentPage(getWidgetPosition(R.id.keyguard_multi_user_selector));
|
mAppWidgetContainer.setCurrentPage(getWidgetPosition(R.id.keyguard_multi_user_selector));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void goToWidget(int appWidgetId) {
|
||||||
|
mAppWidgetToShow = appWidgetId;
|
||||||
|
mSwitchPageRunnable.run();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean handleMenuKey() {
|
public boolean handleMenuKey() {
|
||||||
// The following enables the MENU key to work for testing automation
|
// The following enables the MENU key to work for testing automation
|
||||||
if (shouldEnableMenuKey()) {
|
if (shouldEnableMenuKey()) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.internal.policy.impl.keyguard;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
import android.appwidget.AppWidgetManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@@ -240,6 +241,11 @@ public class KeyguardViewManager {
|
|||||||
if (options.getBoolean(LockPatternUtils.KEYGUARD_SHOW_SECURITY_CHALLENGE)) {
|
if (options.getBoolean(LockPatternUtils.KEYGUARD_SHOW_SECURITY_CHALLENGE)) {
|
||||||
mKeyguardView.showNextSecurityScreenIfPresent();
|
mKeyguardView.showNextSecurityScreenIfPresent();
|
||||||
}
|
}
|
||||||
|
int widgetToShow = options.getInt(LockPatternUtils.KEYGUARD_SHOW_APPWIDGET,
|
||||||
|
AppWidgetManager.INVALID_APPWIDGET_ID);
|
||||||
|
if (widgetToShow != AppWidgetManager.INVALID_APPWIDGET_ID) {
|
||||||
|
mKeyguardView.goToWidget(widgetToShow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,10 +147,6 @@ public class KeyguardViewStateManager implements
|
|||||||
// We only modify the page state if it is not currently under control by the slider.
|
// We only modify the page state if it is not currently under control by the slider.
|
||||||
// This prevents conflicts.
|
// This prevents conflicts.
|
||||||
|
|
||||||
if (mKeyguardHostView != null) {
|
|
||||||
mKeyguardHostView.updateStickyWidget(newPageIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the page hasn't switched, don't bother with any of this
|
// If the page hasn't switched, don't bother with any of this
|
||||||
if (mCurrentPage == newPageIndex) return;
|
if (mCurrentPage == newPageIndex) return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user