summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/SecuritySettings.java
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2012-10-30 15:32:27 -0700
committerMichael Jurka <mikejurka@google.com>2012-10-31 16:46:24 -0700
commit0b2bd8d11d6947a6ce71db0691ba341aec7a2964 (patch)
treeb42898609dd5e8a3dd2966dd550ca4f406c26f82 /src/com/android/settings/SecuritySettings.java
parent523d9dc460d3af22372860f4d3f83a4529257545 (diff)
downloadpackages_apps_Settings-0b2bd8d11d6947a6ce71db0691ba341aec7a2964.zip
packages_apps_Settings-0b2bd8d11d6947a6ce71db0691ba341aec7a2964.tar.gz
packages_apps_Settings-0b2bd8d11d6947a6ce71db0691ba341aec7a2964.tar.bz2
New widget picker for keyguard widgets
New layout for widget picker is still not up to final design, but this change prepares all the backend work Also, remove use of features filter from the picker, since this is being removed from the API Change-Id: I9b332e22cf34b98c20c720602c920d28aed01d6c
Diffstat (limited to 'src/com/android/settings/SecuritySettings.java')
-rw-r--r--src/com/android/settings/SecuritySettings.java131
1 files changed, 0 insertions, 131 deletions
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 7a5118b..22812b2 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -22,20 +22,12 @@ import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
-import android.appwidget.AppWidgetHost;
-import android.appwidget.AppWidgetManager;
-import android.appwidget.AppWidgetProviderInfo;
-import android.content.ActivityNotFoundException;
-import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
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.preference.CheckBoxPreference;
import android.preference.ListPreference;
@@ -47,8 +39,6 @@ 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;
@@ -65,8 +55,6 @@ 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_WIDGET =
- "choose_user_selected_lockscreen_widget";
private static final String KEY_BIOMETRIC_WEAK_IMPROVE_MATCHING =
"biometric_weak_improve_matching";
private static final String KEY_BIOMETRIC_WEAK_LIVELINESS = "biometric_weak_liveliness";
@@ -76,12 +64,9 @@ public class SecuritySettings extends SettingsPreferenceFragment
private static final String KEY_DEVICE_ADMIN_CATEGORY = "device_admin_category";
private static final String KEY_LOCK_AFTER_TIMEOUT = "lock_after_timeout";
private static final String KEY_OWNER_INFO_SETTINGS = "owner_info_settings";
- private static final String EXTRA_DEFAULT_WIDGET = "com.android.settings.DEFAULT_WIDGET";
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_APPWIDGET = 126;
- private static final int REQUEST_CREATE_APPWIDGET = 127;
// Misc Settings
private static final String KEY_SIM_LOCK = "sim_lock";
@@ -421,68 +406,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
}
}
- void startActivityForResultSafely(Intent intent, int requestCode) {
- try {
- startActivityForResult(intent, requestCode);
- } catch (ActivityNotFoundException e) {
- Toast.makeText(getActivity(), R.string.activity_not_found, Toast.LENGTH_SHORT).show();
- } catch (SecurityException e) {
- Toast.makeText(getActivity(), R.string.activity_not_found, Toast.LENGTH_SHORT).show();
- Log.e(TAG, "Settings does not have the permission to launch " + intent, e);
- }
- }
-
- private void launchPickActivityIntent(int featuresFilter, int defaultLabelId, int defaultIconId,
- ComponentName defaultComponentName, String defaultTag, int widgetType) {
- // Create intent to pick widget
- Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK);
-
- // Found in KeyguardHostView.java
- final int KEYGUARD_HOST_ID = 0x4B455947;
- int appWidgetId = AppWidgetHost.allocateAppWidgetIdForSystem(KEYGUARD_HOST_ID);
- if (appWidgetId != -1) {
- pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
- pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_SORT, false);
- pickIntent.putExtra(AppWidgetManager.EXTRA_CATEGORY_FILTER,
- AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD);
- if (featuresFilter != AppWidgetProviderInfo.WIDGET_FEATURES_NONE) {
- pickIntent.putExtra(AppWidgetManager.EXTRA_FEATURES_FILTER, featuresFilter);
- }
-
- // Add an entry for "none" to let someone select no widget
- AppWidgetProviderInfo defaultInfo = new AppWidgetProviderInfo();
- ArrayList<AppWidgetProviderInfo> extraInfos = new ArrayList<AppWidgetProviderInfo>();
- defaultInfo.label = getResources().getString(defaultLabelId);
- defaultInfo.icon = defaultIconId;
- defaultInfo.provider = defaultComponentName;
- extraInfos.add(defaultInfo);
-
- ArrayList<Bundle> extraExtras = new ArrayList<Bundle>();
- Bundle b = new Bundle();
- b.putBoolean(defaultTag, true);
- extraExtras.add(b);
-
- // Launch the widget picker
- pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_INFO, extraInfos);
- pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_EXTRAS, extraExtras);
- pickIntent.putExtra(Intent.EXTRA_INTENT, getBaseIntent());
- startActivityForResult(pickIntent, widgetType);
- } else {
- Log.e(TAG, "Unable to allocate an AppWidget id in lock screen");
- }
- }
-
- private Intent getBaseIntent() {
- Intent baseIntent = new Intent(Intent.ACTION_MAIN, null);
- baseIntent.addCategory(Intent.CATEGORY_DEFAULT);
-
- Bundle options = new Bundle();
- options.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY,
- AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD);
- baseIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
- return baseIntent;
- }
-
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
final String key = preference.getKey();
@@ -491,18 +414,6 @@ 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_LOCKSCREEN_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_NONE,
- R.string.widget_default, defaultIconId, clock, EXTRA_DEFAULT_WIDGET,
- REQUEST_PICK_APPWIDGET);
} else if (KEY_BIOMETRIC_WEAK_IMPROVE_MATCHING.equals(key)) {
ChooseLockSettingsHelper helper =
new ChooseLockSettingsHelper(this.getActivity(), this);
@@ -583,48 +494,6 @@ 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_APPWIDGET || requestCode == REQUEST_CREATE_APPWIDGET) {
- int appWidgetId = (data == null) ? -1 : data.getIntExtra(
- AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
- if ((requestCode == REQUEST_PICK_APPWIDGET) &&
- resultCode == Activity.RESULT_OK) {
- AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity());
- boolean defaultWidget = data.getBooleanExtra(EXTRA_DEFAULT_WIDGET, false);
-
- AppWidgetProviderInfo appWidget = null;
- if (!defaultWidget) {
- appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId);
- }
-
- if (!defaultWidget && 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, REQUEST_CREATE_APPWIDGET);
- } else {
- // Otherwise just add it
- if (defaultWidget) {
- // If we selected "none", delete the allocated id
- AppWidgetHost.deleteAppWidgetIdForSystem(appWidgetId);
- data.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
- LockPatternUtils.ID_DEFAULT_STATUS_WIDGET);
- }
- onActivityResult(REQUEST_CREATE_APPWIDGET, Activity.RESULT_OK, data);
- }
- } 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) {
- }
- } else {
- AppWidgetHost.deleteAppWidgetIdForSystem(appWidgetId);
- }
}
createPreferenceHierarchy();
}