summaryrefslogtreecommitdiffstats
path: root/core/java/android/appwidget
diff options
context:
space:
mode:
authorJim Miller <jaggies@google.com>2012-09-12 20:32:50 -0700
committerMichael Jurka <mikejurka@google.com>2012-09-14 12:31:24 -0700
commitf229e4d3eb8f910c181f96416c6798f6f305a395 (patch)
treed480cb618c10712a3f3498037f2a4084a5300a07 /core/java/android/appwidget
parent49321ec4fb30ab0c709c1e808701f63f38f8cbe7 (diff)
downloadframeworks_base-f229e4d3eb8f910c181f96416c6798f6f305a395.zip
frameworks_base-f229e4d3eb8f910c181f96416c6798f6f305a395.tar.gz
frameworks_base-f229e4d3eb8f910c181f96416c6798f6f305a395.tar.bz2
Add support for settings for lock widgets
Change-Id: Iade094c6f32a7653bdbbd4921d345d68f2443ff4
Diffstat (limited to 'core/java/android/appwidget')
-rw-r--r--core/java/android/appwidget/AppWidgetHost.java54
-rw-r--r--core/java/android/appwidget/AppWidgetManager.java12
2 files changed, 61 insertions, 5 deletions
diff --git a/core/java/android/appwidget/AppWidgetHost.java b/core/java/android/appwidget/AppWidgetHost.java
index c76bf91..51a81c5 100644
--- a/core/java/android/appwidget/AppWidgetHost.java
+++ b/core/java/android/appwidget/AppWidgetHost.java
@@ -24,8 +24,10 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
+import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.UserHandle;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.widget.RemoteViews;
@@ -115,18 +117,22 @@ public class AppWidgetHost {
private OnClickHandler mOnClickHandler;
public AppWidgetHost(Context context, int hostId) {
- this(context, hostId, null);
+ this(context, hostId, null, Looper.getMainLooper());
}
/**
* @hide
*/
- public AppWidgetHost(Context context, int hostId, OnClickHandler handler) {
+ public AppWidgetHost(Context context, int hostId, OnClickHandler handler, Looper looper) {
mContext = context;
mHostId = hostId;
mOnClickHandler = handler;
- mHandler = new UpdateHandler(context.getMainLooper());
+ mHandler = new UpdateHandler(looper);
mDisplayMetrics = context.getResources().getDisplayMetrics();
+ bindService();
+ }
+
+ private static void bindService() {
synchronized (sServiceLock) {
if (sService == null) {
IBinder b = ServiceManager.getService(Context.APPWIDGET_SERVICE);
@@ -190,6 +196,32 @@ public class AppWidgetHost {
}
/**
+ * Get a appWidgetId for a host in the calling process.
+ *
+ * @return a appWidgetId
+ * @hide
+ */
+ public static int allocateAppWidgetIdForHost(String packageName, int hostId) {
+ checkCallerIsSystem();
+ try {
+ if (sService == null) {
+ bindService();
+ }
+ return sService.allocateAppWidgetId(packageName, hostId);
+ } catch (RemoteException e) {
+ throw new RuntimeException("system server dead?", e);
+ }
+ }
+
+ private static void checkCallerIsSystem() {
+ int uid = Process.myUid();
+ if (UserHandle.getAppId(uid) == Process.SYSTEM_UID || uid == 0) {
+ return;
+ }
+ throw new SecurityException("Disallowed call for uid " + uid);
+ }
+
+ /**
* Stop listening to changes for this AppWidget.
*/
public void deleteAppWidgetId(int appWidgetId) {
@@ -205,6 +237,22 @@ public class AppWidgetHost {
}
/**
+ * Stop listening to changes for this AppWidget.
+ * @hide
+ */
+ public static void deleteAppWidgetIdForHost(int appWidgetId) {
+ checkCallerIsSystem();
+ try {
+ if (sService == null) {
+ bindService();
+ }
+ sService.deleteAppWidgetId(appWidgetId);
+ } catch (RemoteException e) {
+ throw new RuntimeException("system server dead?", e);
+ }
+ }
+
+ /**
* Remove all records about this host from the AppWidget manager.
* <ul>
* <li>Call this when initializing your database, as it might be because of a data wipe.</li>
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java
index 0a2a6f6..6fb6dc4 100644
--- a/core/java/android/appwidget/AppWidgetManager.java
+++ b/core/java/android/appwidget/AppWidgetManager.java
@@ -218,18 +218,26 @@ public class AppWidgetManager {
/**
* An intent extra to pass to the AppWidget picker which allows the picker to filter
* the list based on the {@link AppWidgetProviderInfo#widgetCategory}.
+ *
+ * @hide
*/
- /** @hide */
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
*/
- /** @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
+ * @hide
+ */
+ public static final String EXTRA_CUSTOM_SORT = "customSort";
+
+ /**
* A sentiel value that the AppWidget manager will never return as a appWidgetId.
*/
public static final int INVALID_APPWIDGET_ID = 0;