diff options
author | Michael Jurka <mikejurka@google.com> | 2012-10-24 12:26:41 -0700 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2012-10-24 17:44:36 -0700 |
commit | 89a30ffc6343ce9288e9fc253108bfc749d5387f (patch) | |
tree | fd5d1a73bd3db287ec31517d9dcb289188c7f0ef | |
parent | 06545e87b5db25abcdb5790c082fca894db9d664 (diff) | |
download | packages_apps_settings-89a30ffc6343ce9288e9fc253108bfc749d5387f.zip packages_apps_settings-89a30ffc6343ce9288e9fc253108bfc749d5387f.tar.gz packages_apps_settings-89a30ffc6343ce9288e9fc253108bfc749d5387f.tar.bz2 |
Adding ability to add multiple keyguard widgets
Bug: 7381803
Change-Id: I099f47a5cc43199635fed9ad2c4d03d79004e4f4
-rw-r--r-- | res/values/strings.xml | 5 | ||||
-rw-r--r-- | res/xml/security_settings_biometric_weak.xml | 6 | ||||
-rw-r--r-- | res/xml/security_settings_chooser.xml | 6 | ||||
-rw-r--r-- | res/xml/security_settings_password.xml | 6 | ||||
-rw-r--r-- | res/xml/security_settings_pattern.xml | 6 | ||||
-rw-r--r-- | res/xml/security_settings_pin.xml | 6 | ||||
-rw-r--r-- | src/com/android/settings/SecuritySettings.java | 129 |
7 files changed, 22 insertions, 142 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 25b9413..1c7a874 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -808,11 +808,8 @@ <!-- Title for PreferenceScreen to launch picker for security method when there is none [CHAR LIMIT=22] --> <string name="unlock_set_unlock_launch_picker_title">Screen lock</string> - <!-- Title for PreferenceScreen to launch picker for a user-selected time & data widget that will live on lock screen [CHAR LIMIT=22] --> - <string name="choose_lockscreen_status_widget_picker_title">Status widget</string> - <!-- Title for PreferenceScreen to launch picker for a user-selected widget that will live on lock screen [CHAR LIMIT=22] --> - <string name="choose_user_selected_lockscreen_widget_picker_title">Other widget</string> + <string name="choose_user_selected_lockscreen_widget_picker_title">Add widget</string> <!-- String to display if there is no user-selected widget on lock screen [CHAR LIMIT=22] --> <string name="widget_none">None</string> diff --git a/res/xml/security_settings_biometric_weak.xml b/res/xml/security_settings_biometric_weak.xml index 566f8c2..489a200 100644 --- a/res/xml/security_settings_biometric_weak.xml +++ b/res/xml/security_settings_biometric_weak.xml @@ -52,12 +52,6 @@ android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/> <PreferenceScreen - android:key="choose_lockscreen_status_widget" - android:title="@string/choose_lockscreen_status_widget_picker_title" - android:summary="" - android:persistent="false"/> - - <PreferenceScreen android:key="choose_user_selected_lockscreen_widget" android:title="@string/choose_user_selected_lockscreen_widget_picker_title" android:summary="" diff --git a/res/xml/security_settings_chooser.xml b/res/xml/security_settings_chooser.xml index 08428b0..98422ba 100644 --- a/res/xml/security_settings_chooser.xml +++ b/res/xml/security_settings_chooser.xml @@ -27,12 +27,6 @@ android:persistent="false"/> <PreferenceScreen - android:key="choose_lockscreen_status_widget" - android:title="@string/choose_lockscreen_status_widget_picker_title" - android:summary="" - android:persistent="false"/> - - <PreferenceScreen android:key="choose_user_selected_lockscreen_widget" android:title="@string/choose_user_selected_lockscreen_widget_picker_title" android:summary="" diff --git a/res/xml/security_settings_password.xml b/res/xml/security_settings_password.xml index a9973fd..8374a13 100644 --- a/res/xml/security_settings_password.xml +++ b/res/xml/security_settings_password.xml @@ -39,12 +39,6 @@ android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/> <PreferenceScreen - android:key="choose_lockscreen_status_widget" - android:title="@string/choose_lockscreen_status_widget_picker_title" - android:summary="" - android:persistent="false"/> - - <PreferenceScreen android:key="choose_user_selected_lockscreen_widget" android:title="@string/choose_user_selected_lockscreen_widget_picker_title" android:summary="" diff --git a/res/xml/security_settings_pattern.xml b/res/xml/security_settings_pattern.xml index b764c13..8015785 100644 --- a/res/xml/security_settings_pattern.xml +++ b/res/xml/security_settings_pattern.xml @@ -43,12 +43,6 @@ android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/> <PreferenceScreen - android:key="choose_lockscreen_status_widget" - android:title="@string/choose_lockscreen_status_widget_picker_title" - android:summary="" - android:persistent="false"/> - - <PreferenceScreen android:key="choose_user_selected_lockscreen_widget" android:title="@string/choose_user_selected_lockscreen_widget_picker_title" android:summary="" diff --git a/res/xml/security_settings_pin.xml b/res/xml/security_settings_pin.xml index f0aacaa..70e95bd 100644 --- a/res/xml/security_settings_pin.xml +++ b/res/xml/security_settings_pin.xml @@ -39,12 +39,6 @@ android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/> <PreferenceScreen - android:key="choose_lockscreen_status_widget" - android:title="@string/choose_lockscreen_status_widget_picker_title" - android:summary="" - android:persistent="false"/> - - <PreferenceScreen android:key="choose_user_selected_lockscreen_widget" android:title="@string/choose_user_selected_lockscreen_widget_picker_title" android:summary="" diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java index 13b1d0d..d7a68fc 100644 --- a/src/com/android/settings/SecuritySettings.java +++ b/src/com/android/settings/SecuritySettings.java @@ -33,19 +33,21 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Bundle; +import android.os.IBinder; +import android.os.RemoteException; +import android.os.ServiceManager; import android.os.UserHandle; -import android.os.Vibrator; import android.preference.CheckBoxPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; -import android.preference.PreferenceCategory; import android.preference.PreferenceGroup; import android.preference.PreferenceScreen; import android.provider.Settings; import android.security.KeyStore; import android.telephony.TelephonyManager; import android.util.Log; +import android.view.IWindowManager; import android.widget.Toast; import com.android.internal.widget.LockPatternUtils; @@ -63,9 +65,7 @@ public class SecuritySettings extends SettingsPreferenceFragment // Lock Settings private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change"; - private static final String KEY_CHOOSE_LOCKSCREEN_STATUS_WIDGET = - "choose_lockscreen_status_widget"; - private static final String KEY_CHOOSE_USER_SELECTED_LOCKSCREEN_WIDGET = + private static final String KEY_CHOOSE_LOCKSCREEN_WIDGET = "choose_user_selected_lockscreen_widget"; private static final String KEY_BIOMETRIC_WEAK_IMPROVE_MATCHING = "biometric_weak_improve_matching"; @@ -81,10 +81,8 @@ public class SecuritySettings extends SettingsPreferenceFragment private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123; private static final int CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_IMPROVE_REQUEST = 124; private static final int CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_LIVELINESS_OFF = 125; - private static final int REQUEST_PICK_USER_SELECTED_APPWIDGET = 126; - private static final int REQUEST_PICK_STATUS_APPWIDGET = 127; - private static final int REQUEST_CREATE_USER_SELECTED_APPWIDGET = 128; - private static final int REQUEST_CREATE_STATUS_APPWIDGET = 129; + private static final int REQUEST_PICK_APPWIDGET = 126; + private static final int REQUEST_CREATE_APPWIDGET = 127; // Misc Settings private static final String KEY_SIM_LOCK = "sim_lock"; @@ -220,47 +218,6 @@ public class SecuritySettings extends SettingsPreferenceFragment } } - Preference pickStatusWidget = root.findPreference(KEY_CHOOSE_LOCKSCREEN_STATUS_WIDGET); - if (pickStatusWidget != null) { - AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity()); - int appWidgetId = getStatusAppWidgetId(); - if (appWidgetId == -1) { - pickStatusWidget.setSummary(getResources().getString(R.string.widget_default)); - } else { - AppWidgetProviderInfo appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId); - if (appWidget != null) { - pickStatusWidget.setSummary(appWidget.label); - } - } - // TEMP: disable this for now - PreferenceCategory security = - (PreferenceCategory) root.findPreference(KEY_SECURITY_CATEGORY); - if (security != null) { - security.removePreference(pickStatusWidget); - } - } - - Preference pickLockscreenWidget = - root.findPreference(KEY_CHOOSE_USER_SELECTED_LOCKSCREEN_WIDGET); - if (pickLockscreenWidget != null) { - AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity()); - int appWidgetId = getUserSelectedAppWidgetId(); - if (appWidgetId == -1) { - pickLockscreenWidget.setSummary(getResources().getString(R.string.widget_none)); - } else { - AppWidgetProviderInfo appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId); - if (appWidget != null) { - pickLockscreenWidget.setSummary(appWidget.label); - } - } - // TEMP: disable this for now - PreferenceCategory security = - (PreferenceCategory) root.findPreference(KEY_SECURITY_CATEGORY); - if (security != null) { - security.removePreference(pickLockscreenWidget); - } - } - // Append the rest of the settings addPreferencesFromResource(R.xml.security_settings_misc); @@ -314,26 +271,6 @@ public class SecuritySettings extends SettingsPreferenceFragment return root; } - private int getStatusAppWidgetId() { - int appWidgetId = -1; - String appWidgetIdString = Settings.Secure.getString( - getContentResolver(), Settings.Secure.LOCK_SCREEN_STATUS_APPWIDGET_ID); - if (appWidgetIdString != null) {; - appWidgetId = (int) Integer.decode(appWidgetIdString); - } - return appWidgetId; - } - - private int getUserSelectedAppWidgetId() { - int appWidgetId = -1; - String appWidgetIdString = Settings.Secure.getString( - getContentResolver(), Settings.Secure.LOCK_SCREEN_USER_SELECTED_APPWIDGET_ID); - if (appWidgetIdString != null) {; - appWidgetId = (int) Integer.decode(appWidgetIdString); - } - return appWidgetId; - } - private boolean isNonMarketAppsAllowed() { return Settings.Global.getInt(getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS, 0) > 0; @@ -555,22 +492,10 @@ public class SecuritySettings extends SettingsPreferenceFragment if (KEY_UNLOCK_SET_OR_CHANGE.equals(key)) { startFragment(this, "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment", SET_OR_CHANGE_LOCK_METHOD_REQUEST, null); - } else if (KEY_CHOOSE_USER_SELECTED_LOCKSCREEN_WIDGET.equals(key)) { + } else if (KEY_CHOOSE_LOCKSCREEN_WIDGET.equals(key)) { launchPickActivityIntent(AppWidgetProviderInfo.WIDGET_FEATURES_NONE, R.string.widget_none, 0, new ComponentName("", ""), EXTRA_NO_WIDGET, - REQUEST_PICK_USER_SELECTED_APPWIDGET); - } else if (KEY_CHOOSE_LOCKSCREEN_STATUS_WIDGET.equals(key)) { - int defaultIconId; - ComponentName clock = new ComponentName( - "com.google.android.deskclock", "com.android.deskclock.DeskClock"); - try { - defaultIconId = getActivity().getPackageManager().getActivityInfo(clock, 0).icon; - } catch (PackageManager.NameNotFoundException e) { - defaultIconId = 0; - } - launchPickActivityIntent(AppWidgetProviderInfo.WIDGET_FEATURES_STATUS, - R.string.widget_default, defaultIconId, clock, EXTRA_DEFAULT_WIDGET, - REQUEST_PICK_STATUS_APPWIDGET); + REQUEST_PICK_APPWIDGET); } else if (KEY_BIOMETRIC_WEAK_IMPROVE_MATCHING.equals(key)) { ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this.getActivity(), this); @@ -651,14 +576,10 @@ public class SecuritySettings extends SettingsPreferenceFragment // is called by grabbing the value from lockPatternUtils. We can't set it here // because mBiometricWeakLiveliness could be null return; - } else if (requestCode == REQUEST_PICK_USER_SELECTED_APPWIDGET || - requestCode == REQUEST_PICK_STATUS_APPWIDGET || - requestCode == REQUEST_CREATE_USER_SELECTED_APPWIDGET || - requestCode == REQUEST_CREATE_STATUS_APPWIDGET) { + } else if (requestCode == REQUEST_PICK_APPWIDGET || requestCode == REQUEST_CREATE_APPWIDGET) { int appWidgetId = (data == null) ? -1 : data.getIntExtra( AppWidgetManager.EXTRA_APPWIDGET_ID, -1); - if ((requestCode == REQUEST_PICK_USER_SELECTED_APPWIDGET || - requestCode == REQUEST_PICK_STATUS_APPWIDGET) && + if ((requestCode == REQUEST_PICK_APPWIDGET) && resultCode == Activity.RESULT_OK) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity()); boolean defaultOrNoWidget = data.getBooleanExtra(EXTRA_NO_WIDGET, false) || @@ -669,16 +590,13 @@ public class SecuritySettings extends SettingsPreferenceFragment appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId); } - int newRequestCode = requestCode == REQUEST_PICK_USER_SELECTED_APPWIDGET ? - REQUEST_CREATE_USER_SELECTED_APPWIDGET : - REQUEST_CREATE_STATUS_APPWIDGET; if (!defaultOrNoWidget && appWidget.configure != null) { // Launch over to configure widget, if needed Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE); intent.setComponent(appWidget.configure); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); - startActivityForResultSafely(intent, newRequestCode); + startActivityForResultSafely(intent, REQUEST_CREATE_APPWIDGET); } else { // Otherwise just add it if (defaultOrNoWidget) { @@ -686,22 +604,17 @@ public class SecuritySettings extends SettingsPreferenceFragment AppWidgetHost.deleteAppWidgetIdForSystem(appWidgetId); data.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); } - onActivityResult(newRequestCode, Activity.RESULT_OK, data); + onActivityResult(REQUEST_CREATE_APPWIDGET, Activity.RESULT_OK, data); } - } else if ((requestCode == REQUEST_CREATE_USER_SELECTED_APPWIDGET || - requestCode == REQUEST_CREATE_STATUS_APPWIDGET) && - resultCode == Activity.RESULT_OK) { - // If a widget existed before, delete it - int oldAppWidgetId = requestCode == REQUEST_CREATE_USER_SELECTED_APPWIDGET ? - getUserSelectedAppWidgetId() : getStatusAppWidgetId(); - if (oldAppWidgetId != -1) { - AppWidgetHost.deleteAppWidgetIdForSystem(oldAppWidgetId); + } else if (requestCode == REQUEST_CREATE_APPWIDGET && resultCode == Activity.RESULT_OK) { + mLockPatternUtils.addAppWidget(appWidgetId, 0); + + IBinder b = ServiceManager.getService(Context.WINDOW_SERVICE); + IWindowManager iWm = IWindowManager.Stub.asInterface(b); + try { + iWm.lockNow(null); + } catch (RemoteException e) { } - Settings.Secure.putString(getContentResolver(), - (requestCode == REQUEST_CREATE_USER_SELECTED_APPWIDGET ? - Settings.Secure.LOCK_SCREEN_USER_SELECTED_APPWIDGET_ID : - Settings.Secure.LOCK_SCREEN_STATUS_APPWIDGET_ID), - Integer.toString(appWidgetId)); } else { AppWidgetHost.deleteAppWidgetIdForSystem(appWidgetId); } |