Tweaking mechanism for adding keyguard widgets

-> Fix for issue 7173877
-> Fix for issue 7173587

Change-Id: I266cafcf175c98e0c8a8401e11faa5dd2e2fa885
This commit is contained in:
Adam Cohen
2012-09-18 13:26:29 -07:00
parent 221e4356e1
commit 1dd0024327

View File

@@ -459,8 +459,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK); Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK);
// Found in KeyguardHostView.java // Found in KeyguardHostView.java
final int KEYGUARD_HOST_ID = 0x4B455947; final int KEYGUARD_HOST_ID = 0x4B455947;
int appWidgetId = AppWidgetHost.allocateAppWidgetIdForHost( int appWidgetId = AppWidgetHost.allocateAppWidgetIdForSystem(KEYGUARD_HOST_ID);
"com.android.internal.policy.impl.keyguard", KEYGUARD_HOST_ID);
if (appWidgetId != -1) { if (appWidgetId != -1) {
pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_SORT, false); pickIntent.putExtra(AppWidgetManager.EXTRA_CUSTOM_SORT, false);
@@ -592,7 +591,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
// Otherwise just add it // Otherwise just add it
if (noWidget) { if (noWidget) {
// If we selected "none", delete the allocated id // If we selected "none", delete the allocated id
AppWidgetHost.deleteAppWidgetIdForHost(appWidgetId); AppWidgetHost.deleteAppWidgetIdForSystem(appWidgetId);
data.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); data.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
} else { } else {
onActivityResult(REQUEST_CREATE_APPWIDGET, Activity.RESULT_OK, data); onActivityResult(REQUEST_CREATE_APPWIDGET, Activity.RESULT_OK, data);
@@ -603,13 +602,13 @@ public class SecuritySettings extends SettingsPreferenceFragment
// If a widget existed before, delete it // If a widget existed before, delete it
int oldAppWidgetId = getUserSelectedAppWidgetId(); int oldAppWidgetId = getUserSelectedAppWidgetId();
if (oldAppWidgetId != -1) { if (oldAppWidgetId != -1) {
AppWidgetHost.deleteAppWidgetIdForHost(oldAppWidgetId); AppWidgetHost.deleteAppWidgetIdForSystem(oldAppWidgetId);
} }
Settings.Secure.putString(getContentResolver(), Settings.Secure.putString(getContentResolver(),
Settings.Secure.LOCK_SCREEN_USER_SELECTED_APPWIDGET_ID, Settings.Secure.LOCK_SCREEN_USER_SELECTED_APPWIDGET_ID,
Integer.toString(appWidgetId)); Integer.toString(appWidgetId));
} else { } else {
AppWidgetHost.deleteAppWidgetIdForHost(appWidgetId); AppWidgetHost.deleteAppWidgetIdForSystem(appWidgetId);
} }
} }
createPreferenceHierarchy(); createPreferenceHierarchy();