diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java
index 2af65b90b84b8..3dd640c151bc2 100644
--- a/core/java/android/appwidget/AppWidgetManager.java
+++ b/core/java/android/appwidget/AppWidgetManager.java
@@ -79,6 +79,13 @@ public class AppWidgetManager {
*/
public static final String ACTION_APPWIDGET_PICK = "android.appwidget.action.APPWIDGET_PICK";
+ /**
+ * Similar to ACTION_APPWIDGET_PICK, but used from keyguard
+ * @hide
+ */
+ public static final String
+ ACTION_KEYGUARD_APPWIDGET_PICK = "android.appwidget.action.KEYGUARD_APPWIDGET_PICK";
+
/**
* Send this from your {@link AppWidgetHost} activity when you want to bind an AppWidget to
* display and bindAppWidgetIdIfAllowed returns false.
@@ -223,13 +230,6 @@ public class AppWidgetManager {
*/
public static final String EXTRA_CATEGORY_FILTER = "categoryFilter";
- /**
- * An intent extra to pass to the AppWidget picker which allows the picker to filter
- * the list based on the {@link AppWidgetProviderInfo#widgetFeatures}.
- * @hide
- */
- public static final String EXTRA_FEATURES_FILTER = "featuresFilter";
-
/**
* An intent extra to pass to the AppWidget picker to specify whether or not to sort
* the list of caller-specified extra AppWidgets along with the rest of the AppWidgets
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index f8c3b4deb4ef6..3ee3c8cb76ea4 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -129,6 +129,11 @@ public class LockPatternUtils {
*/
public static final int ID_DEFAULT_STATUS_WIDGET = -2;
+ /**
+ * Intent extra that's used to tag the default widget when using the picker
+ */
+ public static final String EXTRA_DEFAULT_WIDGET = "com.android.settings.DEFAULT_WIDGET";
+
protected final static String LOCKOUT_PERMANENT_KEY = "lockscreen.lockedoutpermanently";
protected final static String LOCKOUT_ATTEMPT_DEADLINE = "lockscreen.lockoutattemptdeadline";
protected final static String PATTERN_EVER_CHOSEN_KEY = "lockscreen.patterneverchosen";
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 92aa06a2a66ba..a5aa71331c79f 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1901,6 +1901,13 @@
android:description="@string/permdesc_bindGadget"
android:protectionLevel="signature|system" />
+
+
+
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index a86405d602ee6..8f41a7ae47107 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2065,6 +2065,15 @@
Emergency number
+
+ Clock
+
+
+ com.android.deskclock
+
+
+ com.android.deskclock.DeskClock
+
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 5a0088c7b9264..5af60c81434f4 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -479,6 +479,9 @@
+
+
+
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 96cd7ac727585..3b2ded20f2196 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -25,19 +25,22 @@ import android.appwidget.AppWidgetHost;
import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Rect;
+import android.os.Bundle;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserHandle;
import android.os.UserManager;
-import android.provider.Settings;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Slog;
@@ -54,6 +57,7 @@ import com.android.internal.policy.impl.keyguard.KeyguardSecurityModel.SecurityM
import com.android.internal.widget.LockPatternUtils;
import java.io.File;
+import java.util.ArrayList;
import java.util.List;
public class KeyguardHostView extends KeyguardViewBase {
@@ -880,14 +884,22 @@ public class KeyguardHostView extends KeyguardViewBase {
@Override
public void run() {
- Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
- intent.addFlags(
- Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_SINGLE_TOP
- | Intent.FLAG_ACTIVITY_CLEAR_TOP
- | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
- mContext.startActivityAsUser(intent,
- new UserHandle(UserHandle.USER_CURRENT));
+ int defaultIconId = 0;
+ Resources res = KeyguardHostView.this.getContext().getResources();
+ ComponentName clock = new ComponentName(
+ res.getString(R.string.widget_default_package_name),
+ res.getString(R.string.widget_default_class_name));
+ try {
+ ActivityInfo activityInfo =
+ mContext.getPackageManager().getActivityInfo(clock, 0);
+ if (activityInfo != null) {
+ defaultIconId = activityInfo.icon;
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ defaultIconId = 0;
+ }
+ launchPickActivityIntent(R.string.widget_default, defaultIconId, clock,
+ LockPatternUtils.EXTRA_DEFAULT_WIDGET);
}
});
mCallback.dismiss(false);
@@ -898,6 +910,58 @@ public class KeyguardHostView extends KeyguardViewBase {
initializeTransportControl();
}
+ private void launchPickActivityIntent(int defaultLabelId, int defaultIconId,
+ ComponentName defaultComponentName, String defaultTag) {
+ // Create intent to pick widget
+ Intent pickIntent = new Intent(AppWidgetManager.ACTION_KEYGUARD_APPWIDGET_PICK);
+
+ int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
+ 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);
+
+ // Add an custom entry for the default
+ AppWidgetProviderInfo defaultInfo = new AppWidgetProviderInfo();
+ ArrayList extraInfos = new ArrayList();
+ defaultInfo.label = getResources().getString(defaultLabelId);
+ defaultInfo.icon = defaultIconId;
+ defaultInfo.provider = defaultComponentName;
+ extraInfos.add(defaultInfo);
+
+ ArrayList extraExtras = new ArrayList();
+ 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());
+ pickIntent.addFlags(
+ Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_SINGLE_TOP
+ | Intent.FLAG_ACTIVITY_CLEAR_TOP
+ | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ mContext.startActivityAsUser(pickIntent,
+ new UserHandle(UserHandle.USER_CURRENT));
+ } 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;
+ }
+
private void removeTransportFromWidgetPager() {
int page = getWidgetPosition(R.id.keyguard_transport_control);
if (page != -1) {