diff --git a/Android.mk b/Android.mk
index 8da1cfc6e7cb2..8013c9360c0a1 100644
--- a/Android.mk
+++ b/Android.mk
@@ -98,9 +98,9 @@ LOCAL_SRC_FILES += \
core/java/android/view/IWindowSession.aidl \
core/java/com/android/internal/app/IBatteryStats.aidl \
core/java/com/android/internal/app/IUsageStats.aidl \
- core/java/com/android/internal/gadget/IGadgetService.aidl \
- core/java/com/android/internal/gadget/IGadgetHost.aidl \
- core/java/com/android/internal/os/IResultReceiver.aidl \
+ core/java/com/android/internal/appwidget/IAppWidgetService.aidl \
+ core/java/com/android/internal/appwidget/IAppWidgetHost.aidl \
+ core/java/com/android/internal/os/IResultReceiver.aidl \
core/java/com/android/internal/view/IInputContext.aidl \
core/java/com/android/internal/view/IInputContextCallback.aidl \
core/java/com/android/internal/view/IInputMethod.aidl \
@@ -168,7 +168,7 @@ aidl_files := \
frameworks/base/core/java/android/content/Intent.aidl \
frameworks/base/core/java/android/content/SyncStats.aidl \
frameworks/base/core/java/android/content/res/Configuration.aidl \
- frameworks/base/core/java/android/gadget/GadgetProviderInfo.aidl \
+ frameworks/base/core/java/android/appwidget/AppWidgetProviderInfo.aidl \
frameworks/base/core/java/android/net/Uri.aidl \
frameworks/base/core/java/android/os/Bundle.aidl \
frameworks/base/core/java/android/os/ParcelFileDescriptor.aidl \
diff --git a/api/3.xml b/api/3.xml
index 66cdbe8b1e134..512fef8b184f8 100644
--- a/api/3.xml
+++ b/api/3.xml
@@ -25763,17 +25763,6 @@
visibility="public"
>
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ mRecentCursor = new WeakReference(null);
private boolean mNonUserQuery = false;
+ private Handler mHandler;
+ private Runnable mInstallSuggestionAdapter;
- public SuggestionsAdapter(Context context, SearchableInfo searchable) {
+ public SuggestionsAdapter(Context context, SearchableInfo searchable,
+ Handler handler, Runnable installSuggestionAdapter) {
super(context, -1, null, null, null);
mSearchable = searchable;
+ mHandler = handler;
+ mInstallSuggestionAdapter = installSuggestionAdapter;
// set up provider resources (gives us icons, etc.)
Context activityContext = mSearchable.getActivityContext(mContext);
@@ -1414,7 +1428,11 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
}
// Now actually set up the cursor, columns, and the list view
changeCursorAndColumns(c, from, to);
- setViewResource(layout);
+ setViewResource(layout);
+ // Force the underlying ListView to discard and reload all layouts
+ // (Note, this could be optimized for cases where layout/cursor remain same)
+ mHandler.post(mInstallSuggestionAdapter);
+
} else {
// Provide some help for developers instead of just silently discarding
Log.w(LOG_TAG, "Suggestions cursor discarded due to missing required columns.");
diff --git a/core/java/android/gadget/GadgetHost.java b/core/java/android/appwidget/AppWidgetHost.java
similarity index 62%
rename from core/java/android/gadget/GadgetHost.java
rename to core/java/android/appwidget/AppWidgetHost.java
index 3d88b58499bb3..10c2b02d4c352 100644
--- a/core/java/android/gadget/GadgetHost.java
+++ b/core/java/android/appwidget/AppWidgetHost.java
@@ -1,5 +1,4 @@
/*
- * Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +13,7 @@
* limitations under the License.
*/
-package android.gadget;
+package android.appwidget;
import android.content.Context;
import android.os.Handler;
@@ -29,35 +28,35 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-import com.android.internal.gadget.IGadgetHost;
-import com.android.internal.gadget.IGadgetService;
+import com.android.internal.appwidget.IAppWidgetHost;
+import com.android.internal.appwidget.IAppWidgetService;
/**
- * GadgetHost provides the interaction with the Gadget Service for apps,
- * like the home screen, that want to embed gadgets in their UI.
+ * AppWidgetHost provides the interaction with the AppWidget service for apps,
+ * like the home screen, that want to embed AppWidgets in their UI.
*/
-public class GadgetHost {
+public class AppWidgetHost {
static final int HANDLE_UPDATE = 1;
static final int HANDLE_PROVIDER_CHANGED = 2;
static Object sServiceLock = new Object();
- static IGadgetService sService;
+ static IAppWidgetService sService;
Context mContext;
String mPackageName;
- class Callbacks extends IGadgetHost.Stub {
- public void updateGadget(int gadgetId, RemoteViews views) {
+ class Callbacks extends IAppWidgetHost.Stub {
+ public void updateAppWidget(int appWidgetId, RemoteViews views) {
Message msg = mHandler.obtainMessage(HANDLE_UPDATE);
- msg.arg1 = gadgetId;
+ msg.arg1 = appWidgetId;
msg.obj = views;
msg.sendToTarget();
}
- public void providerChanged(int gadgetId, GadgetProviderInfo info) {
+ public void providerChanged(int appWidgetId, AppWidgetProviderInfo info) {
Message msg = mHandler.obtainMessage(HANDLE_PROVIDER_CHANGED);
- msg.arg1 = gadgetId;
+ msg.arg1 = appWidgetId;
msg.obj = info;
msg.sendToTarget();
}
@@ -71,11 +70,11 @@ public class GadgetHost {
public void handleMessage(Message msg) {
switch (msg.what) {
case HANDLE_UPDATE: {
- updateGadgetView(msg.arg1, (RemoteViews)msg.obj);
+ updateAppWidgetView(msg.arg1, (RemoteViews)msg.obj);
break;
}
case HANDLE_PROVIDER_CHANGED: {
- onProviderChanged(msg.arg1, (GadgetProviderInfo)msg.obj);
+ onProviderChanged(msg.arg1, (AppWidgetProviderInfo)msg.obj);
break;
}
}
@@ -86,22 +85,22 @@ public class GadgetHost {
int mHostId;
Callbacks mCallbacks = new Callbacks();
- HashMap mViews = new HashMap();
+ HashMap mViews = new HashMap();
- public GadgetHost(Context context, int hostId) {
+ public AppWidgetHost(Context context, int hostId) {
mContext = context;
mHostId = hostId;
mHandler = new UpdateHandler(context.getMainLooper());
synchronized (sServiceLock) {
if (sService == null) {
- IBinder b = ServiceManager.getService(Context.GADGET_SERVICE);
- sService = IGadgetService.Stub.asInterface(b);
+ IBinder b = ServiceManager.getService(Context.APPWIDGET_SERVICE);
+ sService = IAppWidgetService.Stub.asInterface(b);
}
}
}
/**
- * Start receiving onGadgetChanged calls for your gadgets. Call this when your activity
+ * Start receiving onAppWidgetChanged calls for your AppWidgets. Call this when your activity
* becomes visible, i.e. from onStart() in your Activity.
*/
public void startListening() {
@@ -120,12 +119,12 @@ public class GadgetHost {
final int N = updatedIds.length;
for (int i=0; i
*
Call this when initializing your database, as it might be because of a data wipe.
- *
Call this to have the gadget manager release all resources associated with your
+ *
Call this to have the AppWidget manager release all resources associated with your
* host. Any future calls about this host will cause the records to be re-allocated.
*
*/
@@ -190,7 +189,7 @@ public class GadgetHost {
* Remove all records about all hosts for your package.
*
*
Call this when initializing your database, as it might be because of a data wipe.
- *
Call this to have the gadget manager release all resources associated with your
+ *
Call this to have the AppWidget manager release all resources associated with your
* host. Any future calls about this host will cause the records to be re-allocated.
*
*/
@@ -203,45 +202,45 @@ public class GadgetHost {
}
}
- public final GadgetHostView createView(Context context, int gadgetId,
- GadgetProviderInfo gadget) {
- GadgetHostView view = onCreateView(context, gadgetId, gadget);
- view.setGadget(gadgetId, gadget);
+ public final AppWidgetHostView createView(Context context, int appWidgetId,
+ AppWidgetProviderInfo appWidget) {
+ AppWidgetHostView view = onCreateView(context, appWidgetId, appWidget);
+ view.setAppWidget(appWidgetId, appWidget);
synchronized (mViews) {
- mViews.put(gadgetId, view);
+ mViews.put(appWidgetId, view);
}
RemoteViews views = null;
try {
- views = sService.getGadgetViews(gadgetId);
+ views = sService.getAppWidgetViews(appWidgetId);
} catch (RemoteException e) {
throw new RuntimeException("system server dead?", e);
}
- view.updateGadget(views);
+ view.updateAppWidget(views);
return view;
}
/**
- * Called to create the GadgetHostView. Override to return a custom subclass if you
+ * Called to create the AppWidgetHostView. Override to return a custom subclass if you
* need it. {@more}
*/
- protected GadgetHostView onCreateView(Context context, int gadgetId,
- GadgetProviderInfo gadget) {
- return new GadgetHostView(context);
+ protected AppWidgetHostView onCreateView(Context context, int appWidgetId,
+ AppWidgetProviderInfo appWidget) {
+ return new AppWidgetHostView(context);
}
/**
- * Called when the gadget provider for a gadget has been upgraded to a new apk.
+ * Called when the AppWidget provider for a AppWidget has been upgraded to a new apk.
*/
- protected void onProviderChanged(int gadgetId, GadgetProviderInfo gadget) {
+ protected void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidget) {
}
- void updateGadgetView(int gadgetId, RemoteViews views) {
- GadgetHostView v;
+ void updateAppWidgetView(int appWidgetId, RemoteViews views) {
+ AppWidgetHostView v;
synchronized (mViews) {
- v = mViews.get(gadgetId);
+ v = mViews.get(appWidgetId);
}
if (v != null) {
- v.updateGadget(views);
+ v.updateAppWidget(views);
}
}
}
diff --git a/core/java/android/gadget/GadgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java
similarity index 88%
rename from core/java/android/gadget/GadgetHostView.java
rename to core/java/android/appwidget/AppWidgetHostView.java
index 5cbd98828ef65..be0f96e8ab6a6 100644
--- a/core/java/android/gadget/GadgetHostView.java
+++ b/core/java/android/appwidget/AppWidgetHostView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.gadget;
+package android.appwidget;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -37,12 +37,12 @@ import android.widget.RemoteViews;
import android.widget.TextView;
/**
- * Provides the glue to show gadget views. This class offers automatic animation
+ * Provides the glue to show AppWidget views. This class offers automatic animation
* between updates, and will try recycling old views for each incoming
* {@link RemoteViews}.
*/
-public class GadgetHostView extends FrameLayout {
- static final String TAG = "GadgetHostView";
+public class AppWidgetHostView extends FrameLayout {
+ static final String TAG = "AppWidgetHostView";
static final boolean LOGD = false;
static final boolean CROSSFADE = false;
@@ -53,7 +53,7 @@ public class GadgetHostView extends FrameLayout {
static final int FADE_DURATION = 1000;
- // When we're inflating the initialLayout for a gadget, we only allow
+ // When we're inflating the initialLayout for a AppWidget, we only allow
// views that are allowed in RemoteViews.
static final LayoutInflater.Filter sInflaterFilter = new LayoutInflater.Filter() {
public boolean onLoadClass(Class clazz) {
@@ -63,8 +63,8 @@ public class GadgetHostView extends FrameLayout {
Context mContext;
- int mGadgetId;
- GadgetProviderInfo mInfo;
+ int mAppWidgetId;
+ AppWidgetProviderInfo mInfo;
View mView;
int mViewMode = VIEW_MODE_NOINIT;
int mLayoutId = -1;
@@ -75,44 +75,44 @@ public class GadgetHostView extends FrameLayout {
/**
* Create a host view. Uses default fade animations.
*/
- public GadgetHostView(Context context) {
+ public AppWidgetHostView(Context context) {
this(context, android.R.anim.fade_in, android.R.anim.fade_out);
}
/**
* Create a host view. Uses specified animations when pushing
- * {@link #updateGadget(RemoteViews)}.
+ * {@link #updateAppWidget(RemoteViews)}.
*
* @param animationIn Resource ID of in animation to use
* @param animationOut Resource ID of out animation to use
*/
- public GadgetHostView(Context context, int animationIn, int animationOut) {
+ public AppWidgetHostView(Context context, int animationIn, int animationOut) {
super(context);
mContext = context;
}
/**
- * Set the gadget that will be displayed by this view.
+ * Set the AppWidget that will be displayed by this view.
*/
- public void setGadget(int gadgetId, GadgetProviderInfo info) {
- mGadgetId = gadgetId;
+ public void setAppWidget(int appWidgetId, AppWidgetProviderInfo info) {
+ mAppWidgetId = appWidgetId;
mInfo = info;
}
- public int getGadgetId() {
- return mGadgetId;
+ public int getAppWidgetId() {
+ return mAppWidgetId;
}
- public GadgetProviderInfo getGadgetInfo() {
+ public AppWidgetProviderInfo getAppWidgetInfo() {
return mInfo;
}
/**
* Process a set of {@link RemoteViews} coming in as an update from the
- * gadget provider. Will animate into these new views as needed.
+ * AppWidget provider. Will animate into these new views as needed.
*/
- public void updateGadget(RemoteViews remoteViews) {
- if (LOGD) Log.d(TAG, "updateGadget called mOld=" + mOld);
+ public void updateAppWidget(RemoteViews remoteViews) {
+ if (LOGD) Log.d(TAG, "updateAppWidget called mOld=" + mOld);
boolean recycled = false;
View content = null;
@@ -180,7 +180,7 @@ public class GadgetHostView extends FrameLayout {
// We've already done this -- nothing to do.
return ;
}
- Log.w(TAG, "updateGadget couldn't find any view, using error view", exception);
+ Log.w(TAG, "updateAppWidget couldn't find any view, using error view", exception);
content = getErrorView();
mViewMode = VIEW_MODE_ERROR;
}
@@ -263,7 +263,7 @@ public class GadgetHostView extends FrameLayout {
}
/**
- * Inflate and return the default layout requested by gadget provider.
+ * Inflate and return the default layout requested by AppWidget provider.
*/
protected View getDefaultView() {
View defaultView = null;
@@ -288,7 +288,7 @@ public class GadgetHostView extends FrameLayout {
}
if (exception != null && LOGD) {
- Log.w(TAG, "Error inflating gadget " + mInfo, exception);
+ Log.w(TAG, "Error inflating AppWidget " + mInfo, exception);
}
if (defaultView == null) {
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java
new file mode 100644
index 0000000000000..3b10ed282d1c7
--- /dev/null
+++ b/core/java/android/appwidget/AppWidgetManager.java
@@ -0,0 +1,320 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.appwidget;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Log;
+import android.widget.RemoteViews;
+
+import com.android.internal.appwidget.IAppWidgetService;
+
+import java.lang.ref.WeakReference;
+import java.util.List;
+import java.util.WeakHashMap;
+
+/**
+ * Updates AppWidget state; gets information about installed AppWidget providers and other
+ * AppWidget related state.
+ */
+public class AppWidgetManager {
+ static final String TAG = "AppWidgetManager";
+
+ /**
+ * Send this from your {@link AppWidgetHost} activity when you want to pick an AppWidget to display.
+ * The AppWidget picker activity will be launched.
+ *
+ * You must supply the following extras:
+ *
+ *
+ *
{@link #EXTRA_APPWIDGET_ID}
+ *
A newly allocated appWidgetId, which will be bound to the AppWidget provider
+ * once the user has selected one.
+ *
+ *
+ *
+ *
+ * The system will respond with an onActivityResult call with the following extras in
+ * the intent:
+ *
+ *
+ *
{@link #EXTRA_APPWIDGET_ID}
+ *
The appWidgetId that you supplied in the original intent.
+ *
+ *
+ *
+ * When you receive the result from the AppWidget pick activity, if the resultCode is
+ * {@link android.app.Activity#RESULT_OK}, an AppWidget has been selected. You should then
+ * check the AppWidgetProviderInfo for the returned AppWidget, and if it has one, launch its configuration
+ * activity. If {@link android.app.Activity#RESULT_CANCELED} is returned, you should delete
+ * the appWidgetId.
+ *
+ * @see #ACTION_APPWIDGET_CONFIGURE
+ */
+ public static final String ACTION_APPWIDGET_PICK = "android.appwidget.action.APPWIDGET_PICK";
+
+ /**
+ * Sent when it is time to configure your AppWidget while it is being added to a host.
+ * This action is not sent as a broadcast to the AppWidget provider, but as a startActivity
+ * to the activity specified in the {@link AppWidgetProviderInfo AppWidgetProviderInfo meta-data}.
+ *
+ *
+ * The intent will contain the following extras:
+ *
+ *
+ *
{@link #EXTRA_APPWIDGET_ID}
+ *
The appWidgetId to configure.
+ *
+ *
+ *
+ *
If you return {@link android.app.Activity#RESULT_OK} using
+ * {@link android.app.Activity#setResult Activity.setResult()}, the AppWidget will be added,
+ * and you will receive an {@link #ACTION_APPWIDGET_UPDATE} broadcast for this AppWidget.
+ * If you return {@link android.app.Activity#RESULT_CANCELED}, the host will cancel the add
+ * and not display this AppWidget, and you will receive a {@link #ACTION_APPWIDGET_DELETED} broadcast.
+ */
+ public static final String ACTION_APPWIDGET_CONFIGURE = "android.appwidget.action.APPWIDGET_CONFIGURE";
+
+ /**
+ * An intent extra that contains one appWidgetId.
+ *
+ * The value will be an int that can be retrieved like this:
+ * {@sample frameworks/base/tests/appwidgets/AppWidgetHostTest/src/com/android/tests/appwidgethost/AppWidgetHostActivity.java getExtra_EXTRA_APPWIDGET_ID}
+ */
+ public static final String EXTRA_APPWIDGET_ID = "appWidgetId";
+
+ /**
+ * An intent extra that contains multiple appWidgetIds.
+ *
+ * The value will be an int array that can be retrieved like this:
+ * {@sample frameworks/base/tests/appwidgets/AppWidgetHostTest/src/com/android/tests/appwidgethost/TestAppWidgetProvider.java getExtra_EXTRA_APPWIDGET_IDS}
+ */
+ public static final String EXTRA_APPWIDGET_IDS = "appWidgetIds";
+
+ /**
+ * A sentiel value that the AppWidget manager will never return as a appWidgetId.
+ */
+ public static final int INVALID_APPWIDGET_ID = 0;
+
+ /**
+ * Sent when it is time to update your AppWidget.
+ *
+ *
This may be sent in response to a new instance for this AppWidget provider having
+ * been instantiated, the requested {@link AppWidgetProviderInfo#updatePeriodMillis update interval}
+ * having lapsed, or the system booting.
+ *
+ *
+ * The intent will contain the following extras:
+ *
+ *
+ *
{@link #EXTRA_APPWIDGET_IDS}
+ *
The appWidgetIds to update. This may be all of the AppWidgets created for this
+ * provider, or just a subset. The system tries to send updates for as few AppWidget
+ * instances as possible.
+ *
+ *
+ *
+ * @see AppWidgetProvider#onUpdate AppWidgetProvider.onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
+ */
+ public static final String ACTION_APPWIDGET_UPDATE = "android.appwidget.action.APPWIDGET_UPDATE";
+
+ /**
+ * Sent when an instance of an AppWidget is deleted from its host.
+ *
+ * @see AppWidgetProvider#onDeleted AppWidgetProvider.onDeleted(Context context, int[] appWidgetIds)
+ */
+ public static final String ACTION_APPWIDGET_DELETED = "android.appwidget.action.APPWIDGET_DELETED";
+
+ /**
+ * Sent when an instance of an AppWidget is removed from the last host.
+ *
+ * @see AppWidgetProvider#onEnabled AppWidgetProvider.onEnabled(Context context)
+ */
+ public static final String ACTION_APPWIDGET_DISABLED = "android.appwidget.action.APPWIDGET_DISABLED";
+
+ /**
+ * Sent when an instance of an AppWidget is added to a host for the first time.
+ * This broadcast is sent at boot time if there is a AppWidgetHost installed with
+ * an instance for this provider.
+ *
+ * @see AppWidgetProvider#onEnabled AppWidgetProvider.onEnabled(Context context)
+ */
+ public static final String ACTION_APPWIDGET_ENABLED = "android.appwidget.action.APPWIDGET_ENABLED";
+
+ /**
+ * Field for the manifest meta-data tag.
+ *
+ * @see AppWidgetProviderInfo
+ */
+ public static final String META_DATA_APPWIDGET_PROVIDER = "android.appwidget.provider";
+
+ static WeakHashMap> sManagerCache = new WeakHashMap();
+ static IAppWidgetService sService;
+
+ Context mContext;
+
+ /**
+ * Get the AppWidgetManager instance to use for the supplied {@link android.content.Context
+ * Context} object.
+ */
+ public static AppWidgetManager getInstance(Context context) {
+ synchronized (sManagerCache) {
+ if (sService == null) {
+ IBinder b = ServiceManager.getService(Context.APPWIDGET_SERVICE);
+ sService = IAppWidgetService.Stub.asInterface(b);
+ }
+
+ WeakReference ref = sManagerCache.get(context);
+ AppWidgetManager result = null;
+ if (ref != null) {
+ result = ref.get();
+ }
+ if (result == null) {
+ result = new AppWidgetManager(context);
+ sManagerCache.put(context, new WeakReference(result));
+ }
+ return result;
+ }
+ }
+
+ private AppWidgetManager(Context context) {
+ mContext = context;
+ }
+
+ /**
+ * Set the RemoteViews to use for the specified appWidgetIds.
+ *
+ *
+ * It is okay to call this method both inside an {@link #ACTION_APPWIDGET_UPDATE} broadcast,
+ * and outside of the handler.
+ * This method will only work when called from the uid that owns the AppWidget provider.
+ *
+ * @param appWidgetIds The AppWidget instances for which to set the RemoteViews.
+ * @param views The RemoteViews object to show.
+ */
+ public void updateAppWidget(int[] appWidgetIds, RemoteViews views) {
+ try {
+ sService.updateAppWidgetIds(appWidgetIds, views);
+ }
+ catch (RemoteException e) {
+ throw new RuntimeException("system server dead?", e);
+ }
+ }
+
+ /**
+ * Set the RemoteViews to use for the specified appWidgetId.
+ *
+ *
+ * It is okay to call this method both inside an {@link #ACTION_APPWIDGET_UPDATE} broadcast,
+ * and outside of the handler.
+ * This method will only work when called from the uid that owns the AppWidget provider.
+ *
+ * @param appWidgetId The AppWidget instance for which to set the RemoteViews.
+ * @param views The RemoteViews object to show.
+ */
+ public void updateAppWidget(int appWidgetId, RemoteViews views) {
+ updateAppWidget(new int[] { appWidgetId }, views);
+ }
+
+ /**
+ * Set the RemoteViews to use for all AppWidget instances for the supplied AppWidget provider.
+ *
+ *
+ * It is okay to call this method both inside an {@link #ACTION_APPWIDGET_UPDATE} broadcast,
+ * and outside of the handler.
+ * This method will only work when called from the uid that owns the AppWidget provider.
+ *
+ * @param provider The {@link ComponentName} for the {@link
+ * android.content.BroadcastReceiver BroadcastReceiver} provider
+ * for your AppWidget.
+ * @param views The RemoteViews object to show.
+ */
+ public void updateAppWidget(ComponentName provider, RemoteViews views) {
+ try {
+ sService.updateAppWidgetProvider(provider, views);
+ }
+ catch (RemoteException e) {
+ throw new RuntimeException("system server dead?", e);
+ }
+ }
+
+ /**
+ * Return a list of the AppWidget providers that are currently installed.
+ */
+ public List getInstalledProviders() {
+ try {
+ return sService.getInstalledProviders();
+ }
+ catch (RemoteException e) {
+ throw new RuntimeException("system server dead?", e);
+ }
+ }
+
+ /**
+ * Get the available info about the AppWidget.
+ *
+ * @return A appWidgetId. If the appWidgetId has not been bound to a provider yet, or
+ * you don't have access to that appWidgetId, null is returned.
+ */
+ public AppWidgetProviderInfo getAppWidgetInfo(int appWidgetId) {
+ try {
+ return sService.getAppWidgetInfo(appWidgetId);
+ }
+ catch (RemoteException e) {
+ throw new RuntimeException("system server dead?", e);
+ }
+ }
+
+ /**
+ * Set the component for a given appWidgetId.
+ *
+ *
You need the APPWIDGET_LIST permission. This method is to be used by the
+ * AppWidget picker.
+ *
+ * @param appWidgetId The AppWidget instance for which to set the RemoteViews.
+ * @param provider The {@link android.content.BroadcastReceiver} that will be the AppWidget
+ * provider for this AppWidget.
+ */
+ public void bindAppWidgetId(int appWidgetId, ComponentName provider) {
+ try {
+ sService.bindAppWidgetId(appWidgetId, provider);
+ }
+ catch (RemoteException e) {
+ throw new RuntimeException("system server dead?", e);
+ }
+ }
+
+ /**
+ * Get the list of appWidgetIds that have been bound to the given AppWidget
+ * provider.
+ *
+ * @param provider The {@link android.content.BroadcastReceiver} that is the
+ * AppWidget provider to find appWidgetIds for.
+ */
+ public int[] getAppWidgetIds(ComponentName provider) {
+ try {
+ return sService.getAppWidgetIds(provider);
+ }
+ catch (RemoteException e) {
+ throw new RuntimeException("system server dead?", e);
+ }
+ }
+}
+
diff --git a/core/java/android/appwidget/AppWidgetProvider.java b/core/java/android/appwidget/AppWidgetProvider.java
new file mode 100755
index 0000000000000..f70de9cde67e0
--- /dev/null
+++ b/core/java/android/appwidget/AppWidgetProvider.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.appwidget;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+
+/**
+ * A conveience class to aid in implementing an AppWidget provider.
+ * Everything you can do with AppWidgetProvider, you can do with a regular {@link BroadcastReceiver}.
+ * AppWidgetProvider merely parses the relevant fields out of the Intent that is received in
+ * {@link #onReceive(Context,Intent) onReceive(Context,Intent)}, and calls hook methods
+ * with the received extras.
+ *
+ *
Extend this class and override one or more of the {@link #onUpdate}, {@link #onDeleted},
+ * {@link #onEnabled} or {@link #onDisabled} methods to implement your own AppWidget functionality.
+ *
+ *
Sample Code
+ * For an example of how to write a AppWidget provider, see the
+ * android.appwidget
+ * package overview.
+ */
+public class AppWidgetProvider extends BroadcastReceiver {
+ /**
+ * Constructor to initialize AppWidgetProvider.
+ */
+ public AppWidgetProvider() {
+ }
+
+ /**
+ * Implements {@link BroadcastReceiver#onReceive} to dispatch calls to the various
+ * other methods on AppWidgetProvider.
+ *
+ * @param context The Context in which the receiver is running.
+ * @param intent The Intent being received.
+ */
+ // BEGIN_INCLUDE(onReceive)
+ public void onReceive(Context context, Intent intent) {
+ // Protect against rogue update broadcasts (not really a security issue,
+ // just filter bad broacasts out so subclasses are less likely to crash).
+ String action = intent.getAction();
+ if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) {
+ Bundle extras = intent.getExtras();
+ if (extras != null) {
+ int[] appWidgetIds = extras.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);
+ if (appWidgetIds != null && appWidgetIds.length > 0) {
+ this.onUpdate(context, AppWidgetManager.getInstance(context), appWidgetIds);
+ }
+ }
+ }
+ else if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) {
+ Bundle extras = intent.getExtras();
+ if (extras != null) {
+ int[] appWidgetIds = extras.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);
+ if (appWidgetIds != null && appWidgetIds.length > 0) {
+ this.onDeleted(context, appWidgetIds);
+ }
+ }
+ }
+ else if (AppWidgetManager.ACTION_APPWIDGET_ENABLED.equals(action)) {
+ this.onEnabled(context);
+ }
+ else if (AppWidgetManager.ACTION_APPWIDGET_DISABLED.equals(action)) {
+ this.onDisabled(context);
+ }
+ }
+ // END_INCLUDE(onReceive)
+
+ /**
+ * Called in response to the {@link AppWidgetManager#ACTION_APPWIDGET_UPDATE} broadcast when
+ * this AppWidget provider is being asked to provide {@link android.widget.RemoteViews RemoteViews}
+ * for a set of AppWidgets. Override this method to implement your own AppWidget functionality.
+ *
+ * {@more}
+ *
+ * @param context The {@link android.content.Context Context} in which this receiver is
+ * running.
+ * @param appWidgetManager A {@link AppWidgetManager} object you can call {@link
+ * AppWidgetManager#updateAppWidget} on.
+ * @param appWidgetIds The appWidgetIds for which an update is needed. Note that this
+ * may be all of the AppWidget instances for this provider, or just
+ * a subset of them.
+ *
+ * @see AppWidgetManager#ACTION_APPWIDGET_UPDATE
+ */
+ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
+ }
+
+ /**
+ * Called in response to the {@link AppWidgetManager#ACTION_APPWIDGET_DELETED} broadcast when
+ * one or more AppWidget instances have been deleted. Override this method to implement
+ * your own AppWidget functionality.
+ *
+ * {@more}
+ *
+ * @param context The {@link android.content.Context Context} in which this receiver is
+ * running.
+ * @param appWidgetIds The appWidgetIds that have been deleted from their host.
+ *
+ * @see AppWidgetManager#ACTION_APPWIDGET_DELETED
+ */
+ public void onDeleted(Context context, int[] appWidgetIds) {
+ }
+
+ /**
+ * Called in response to the {@link AppWidgetManager#ACTION_APPWIDGET_ENABLED} broadcast when
+ * the a AppWidget for this provider is instantiated. Override this method to implement your
+ * own AppWidget functionality.
+ *
+ * {@more}
+ * When the last AppWidget for this provider is deleted,
+ * {@link AppWidgetManager#ACTION_APPWIDGET_DISABLED} is sent by the AppWidget manager, and
+ * {@link #onDisabled} is called. If after that, an AppWidget for this provider is created
+ * again, onEnabled() will be called again.
+ *
+ * @param context The {@link android.content.Context Context} in which this receiver is
+ * running.
+ *
+ * @see AppWidgetManager#ACTION_APPWIDGET_ENABLED
+ */
+ public void onEnabled(Context context) {
+ }
+
+ /**
+ * Called in response to the {@link AppWidgetManager#ACTION_APPWIDGET_DISABLED} broadcast, which
+ * is sent when the last AppWidget instance for this provider is deleted. Override this method
+ * to implement your own AppWidget functionality.
+ *
+ * {@more}
+ *
+ * @param context The {@link android.content.Context Context} in which this receiver is
+ * running.
+ *
+ * @see AppWidgetManager#ACTION_APPWIDGET_DISABLED
+ */
+ public void onDisabled(Context context) {
+ }
+}
diff --git a/core/java/android/gadget/GadgetProviderInfo.aidl b/core/java/android/appwidget/AppWidgetProviderInfo.aidl
similarity index 91%
rename from core/java/android/gadget/GadgetProviderInfo.aidl
rename to core/java/android/appwidget/AppWidgetProviderInfo.aidl
index 589f886776f4e..82b3adac9e775 100644
--- a/core/java/android/gadget/GadgetProviderInfo.aidl
+++ b/core/java/android/appwidget/AppWidgetProviderInfo.aidl
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-package android.gadget;
+package android.appwidget;
-parcelable GadgetProviderInfo;
+parcelable AppWidgetProviderInfo;
diff --git a/core/java/android/gadget/GadgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java
similarity index 63%
rename from core/java/android/gadget/GadgetProviderInfo.java
rename to core/java/android/appwidget/AppWidgetProviderInfo.java
index 95c043230ec30..8530c355b9351 100644
--- a/core/java/android/gadget/GadgetProviderInfo.java
+++ b/core/java/android/appwidget/AppWidgetProviderInfo.java
@@ -14,21 +14,21 @@
* limitations under the License.
*/
-package android.gadget;
+package android.appwidget;
import android.os.Parcel;
import android.os.Parcelable;
import android.content.ComponentName;
/**
- * Describes the meta data for an installed gadget provider. The fields in this class
- * correspond to the fields in the <gadget-provider> xml tag.
+ * Describes the meta data for an installed AppWidget provider. The fields in this class
+ * correspond to the fields in the <appwidget-provider> xml tag.
*/
-public class GadgetProviderInfo implements Parcelable {
+public class AppWidgetProviderInfo implements Parcelable {
/**
- * Identity of this gadget component. This component should be a {@link
- * android.content.BroadcastReceiver}, and it will be sent the Gadget intents
- * {@link android.gadget as described in the gadget package documentation}.
+ * Identity of this AppWidget component. This component should be a {@link
+ * android.content.BroadcastReceiver}, and it will be sent the AppWidget intents
+ * {@link android.appwidget as described in the AppWidget package documentation}.
*
*
This field corresponds to the android:name attribute in
* the <receiver> element in the AndroidManifest.xml file.
@@ -36,50 +36,50 @@ public class GadgetProviderInfo implements Parcelable {
public ComponentName provider;
/**
- * Minimum width of the gadget, in dp.
+ * Minimum width of the AppWidget, in dp.
*
*
This field corresponds to the android:minWidth attribute in
- * the gadget meta-data file.
+ * the AppWidget meta-data file.
*/
public int minWidth;
/**
- * Minimum height of the gadget, in dp.
+ * Minimum height of the AppWidget, in dp.
*
*
This field corresponds to the android:minHeight attribute in
- * the gadget meta-data file.
+ * the AppWidget meta-data file.
*/
public int minHeight;
/**
- * How often, in milliseconds, that this gadget wants to be updated.
- * The gadget manager may place a limit on how often a gadget is updated.
+ * How often, in milliseconds, that this AppWidget wants to be updated.
+ * The AppWidget manager may place a limit on how often a AppWidget is updated.
*
*
This field corresponds to the android:updatePeriodMillis attribute in
- * the gadget meta-data file.
+ * the AppWidget meta-data file.
*/
public int updatePeriodMillis;
/**
- * The resource id of the initial layout for this gadget. This should be
- * displayed until the RemoteViews for the gadget is available.
+ * The resource id of the initial layout for this AppWidget. This should be
+ * displayed until the RemoteViews for the AppWidget is available.
*
*
This field corresponds to the android:initialLayout attribute in
- * the gadget meta-data file.
+ * the AppWidget meta-data file.
*/
public int initialLayout;
/**
- * The activity to launch that will configure the gadget.
+ * The activity to launch that will configure the AppWidget.
*
*
This class name of field corresponds to the android:configure attribute in
- * the gadget meta-data file. The package name always corresponds to the package containing
- * the gadget provider.
+ * the AppWidget meta-data file. The package name always corresponds to the package containing
+ * the AppWidget provider.
*/
public ComponentName configure;
/**
- * The label to display to the user in the gadget picker. If not supplied in the
+ * The label to display to the user in the AppWidget picker. If not supplied in the
* xml, the application label will be used.
*
*
This field corresponds to the android:label attribute in
@@ -88,7 +88,7 @@ public class GadgetProviderInfo implements Parcelable {
public String label;
/**
- * The icon to display for this gadget in the gadget picker. If not supplied in the
+ * The icon to display for this AppWidget in the AppWidget picker. If not supplied in the
* xml, the application icon will be used.
*
*
This field corresponds to the android:icon attribute in
@@ -96,13 +96,13 @@ public class GadgetProviderInfo implements Parcelable {
*/
public int icon;
- public GadgetProviderInfo() {
+ public AppWidgetProviderInfo() {
}
/**
- * Unflatten the GadgetProviderInfo from a parcel.
+ * Unflatten the AppWidgetProviderInfo from a parcel.
*/
- public GadgetProviderInfo(Parcel in) {
+ public AppWidgetProviderInfo(Parcel in) {
if (0 != in.readInt()) {
this.provider = new ComponentName(in);
}
@@ -144,24 +144,24 @@ public class GadgetProviderInfo implements Parcelable {
}
/**
- * Parcelable.Creator that instantiates GadgetProviderInfo objects
+ * Parcelable.Creator that instantiates AppWidgetProviderInfo objects
*/
- public static final Parcelable.Creator CREATOR
- = new Parcelable.Creator()
+ public static final Parcelable.Creator CREATOR
+ = new Parcelable.Creator()
{
- public GadgetProviderInfo createFromParcel(Parcel parcel)
+ public AppWidgetProviderInfo createFromParcel(Parcel parcel)
{
- return new GadgetProviderInfo(parcel);
+ return new AppWidgetProviderInfo(parcel);
}
- public GadgetProviderInfo[] newArray(int size)
+ public AppWidgetProviderInfo[] newArray(int size)
{
- return new GadgetProviderInfo[size];
+ return new AppWidgetProviderInfo[size];
}
};
public String toString() {
- return "GadgetProviderInfo(provider=" + this.provider + ")";
+ return "AppWidgetProviderInfo(provider=" + this.provider + ")";
}
}
diff --git a/core/java/android/appwidget/package.html b/core/java/android/appwidget/package.html
new file mode 100644
index 0000000000000..b6cd9c74d02ef
--- /dev/null
+++ b/core/java/android/appwidget/package.html
@@ -0,0 +1,136 @@
+
+
Android allows applications to publish views to be embedded in other applications. These
+views are called widgets, and are published by "AppWidget providers." The component that can
+contain widgets is called a "AppWidget host."
+
+Any application can publish widgets. All an application needs to do to publish a widget is
+to have a {@link android.content.BroadcastReceiver} that receives the {@link
+android.appwidget.AppWidgetManager#ACTION_APPWIDGET_UPDATE AppWidgetManager.ACTION_APPWIDGET_UPDATE} intent,
+and provide some meta-data about the widget. Android provides the
+{@link android.appwidget.AppWidgetProvider} class, which extends BroadcastReceiver, as a convenience
+class to aid in handling the broadcasts.
+
+
Declaring a widget in the AndroidManifest
+
+
+First, declare the {@link android.content.BroadcastReceiver} in your application's
+AndroidManifest.xml file.
+
+{@sample frameworks/base/tests/appwidgets/AppWidgetHostTest/AndroidManifest.xml AppWidgetProvider}
+
+
+The <receiver> element has the following attributes:
+
+
android:name - which specifies the
+ {@link android.content.BroadcastReceiver} or {@link android.appwidget.AppWidgetProvider}
+ class.
+
android:label - which specifies the string resource that
+ will be shown by the widget picker as the label.
+
android:icon - which specifies the drawable resource that
+ will be shown by the widget picker as the icon.
+
+
+
+The <intent-filter> element tells the {@link android.content.pm.PackageManager}
+that this {@link android.content.BroadcastReceiver} receives the {@link
+android.appwidget.AppWidgetManager#ACTION_APPWIDGET_UPDATE AppWidgetManager.ACTION_APPWIDGET_UPDATE} broadcast.
+The widget manager will send other broadcasts directly to your widget provider as required.
+It is only necessary to explicitly declare that you accept the {@link
+android.appwidget.AppWidgetManager#ACTION_APPWIDGET_UPDATE AppWidgetManager.ACTION_APPWIDGET_UPDATE} broadcast.
+
+
+The <meta-data> element tells the widget manager which xml resource to
+read to find the {@link android.appwidget.AppWidgetProviderInfo} for your widget provider. It has the following
+attributes:
+
+
android:name="android.appwidget.provider" - identifies this meta-data
+ as the {@link android.appwidget.AppWidgetProviderInfo} descriptor.
+
android:resource - is the xml resource to use as that descriptor.
+
+
+
+
Adding the {@link android.appwidget.AppWidgetProviderInfo AppWidgetProviderInfo} meta-data
+
+
+For a widget, the values in the {@link android.appwidget.AppWidgetProviderInfo} structure are supplied
+in an XML resource. In the example above, the xml resource is referenced with
+android:resource="@xml/appwidget_info". That XML file would go in your application's
+directory at res/xml/appwidget_info.xml. Here is a simple example.
+
+{@sample frameworks/base/tests/appwidgets/AppWidgetHostTest/res/xml/appwidget_info.xml AppWidgetProviderInfo}
+
+
+The attributes are as documented in the {@link android.appwidget.AppWidgetProviderInfo GagetInfo} class. (86400000 milliseconds means once per day)
+
+
+
Using the {@link android.appwidget.AppWidgetProvider AppWidgetProvider} class
+
+
The AppWidgetProvider class is the easiest way to handle the widget provider intent broadcasts.
+See the src/com/example/android/apis/appwidget/ExampleAppWidgetProvider.java
+sample class in ApiDemos for an example.
+
+
Keep in mind that since the the AppWidgetProvider is a BroadcastReceiver,
+your process is not guaranteed to keep running after the callback methods return. See
+Application Fundamentals >
+Broadcast Receiver Lifecycle for more information.
+
+
+
+
AppWidget Configuration UI
+
+
+Widget hosts have the ability to start a configuration activity when a widget is instantiated.
+The activity should be declared as normal in AndroidManifest.xml, and it should be listed in
+the AppWidgetProviderInfo XML file in the android:configure attribute.
+
+
The activity you specified will be launched with the {@link
+android.appwidget.AppWidgetManager#ACTION_APPWIDGET_CONFIGURE} action. See the documentation for that
+action for more info.
+
+
See the src/com/example/android/apis/appwidget/ExampleAppWidgetConfigure.java
+sample class in ApiDemos for an example.
+
+
+
+
AppWidget Broadcast Intents
+
+
{@link android.appwidget.AppWidgetProvider} is just a convenience class. If you would like
+to receive the widget broadcasts directly, you can. The four intents you need to care about are:
+
Widget hosts are the containers in which widgets can be placed. Most of the look and feel
+details are left up to the widget hosts. For example, the home screen has one way of viewing
+widgets, but the lock screen could also contain widgets, and it would have a different way of
+adding, removing and otherwise managing widgets.
+
For more information on implementing your own widget host, see the
+{@link android.appwidget.AppWidgetHost AppWidgetHost} class.
+
+
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index e0fe533a93813..9a0dc9f189bb1 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -1250,12 +1250,12 @@ public abstract class Context {
/**
* Use with {@link #getSystemService} to retrieve a
- * {@blink android.gadget.GadgetManager} for accessing wallpapers.
+ * {@blink android.appwidget.AppWidgetManager} for accessing AppWidgets.
*
* @hide
* @see #getSystemService
*/
- public static final String GADGET_SERVICE = "gadget";
+ public static final String APPWIDGET_SERVICE = "appwidget";
/**
* Determine whether the given permission is allowed for a particular
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 824fd9b1f7523..bb80e10d49d22 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -525,7 +525,6 @@ import java.util.Set;
*
{@link #CATEGORY_INFO}
*
{@link #CATEGORY_HOME}
*
{@link #CATEGORY_PREFERENCE}
- *
{@link #CATEGORY_GADGET}
*
{@link #CATEGORY_TEST}
*
*
@@ -1543,12 +1542,6 @@ public class Intent implements Parcelable {
*/
@SdkConstant(SdkConstantType.INTENT_CATEGORY)
public static final String CATEGORY_TAB = "android.intent.category.TAB";
- /**
- * This activity can be embedded inside of another activity that is hosting
- * gadgets.
- */
- @SdkConstant(SdkConstantType.INTENT_CATEGORY)
- public static final String CATEGORY_GADGET = "android.intent.category.GADGET";
/**
* Should be displayed in the top-level launcher.
*/
@@ -1579,9 +1572,6 @@ public class Intent implements Parcelable {
public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
/**
* Capable of running inside a parent activity container.
- *
- *
Note: being removed in favor of more explicit categories such as
- * CATEGORY_GADGET
*/
@SdkConstant(SdkConstantType.INTENT_CATEGORY)
public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
diff --git a/core/java/android/content/res/ColorStateList.java b/core/java/android/content/res/ColorStateList.java
index 0f3f2708c6017..453a83d30412d 100644
--- a/core/java/android/content/res/ColorStateList.java
+++ b/core/java/android/content/res/ColorStateList.java
@@ -304,7 +304,6 @@ public class ColorStateList implements Parcelable {
for (int i=0; i
- * You must supply the following extras:
- *
- *
- *
{@link #EXTRA_GADGET_ID}
- *
A newly allocated gadgetId, which will be bound to the gadget provider
- * once the user has selected one.
- *
- *
- *
- *
- * The system will respond with an onActivityResult call with the following extras in
- * the intent:
- *
- *
- *
{@link #EXTRA_GADGET_ID}
- *
The gadgetId that you supplied in the original intent.
- *
- *
- *
- * When you receive the result from the gadget pick activity, if the resultCode is
- * {@link android.app.Activity#RESULT_OK}, a gadget has been selected. You should then
- * check the GadgetProviderInfo for the returned gadget, and if it has one, launch its configuration
- * activity. If {@link android.app.Activity#RESULT_CANCELED} is returned, you should delete
- * the gadgetId.
- *
- * @see #ACTION_GADGET_CONFIGURE
- */
- public static final String ACTION_GADGET_PICK = "android.gadget.action.GADGET_PICK";
-
- /**
- * Sent when it is time to configure your gadget while it is being added to a host.
- * This action is not sent as a broadcast to the gadget provider, but as a startActivity
- * to the activity specified in the {@link GadgetProviderInfo GadgetProviderInfo meta-data}.
- *
- *
- * The intent will contain the following extras:
- *
- *
- *
{@link #EXTRA_GADGET_ID}
- *
The gadgetId to configure.
- *
- *
- *
- *
If you return {@link android.app.Activity#RESULT_OK} using
- * {@link android.app.Activity#setResult Activity.setResult()}, the gadget will be added,
- * and you will receive an {@link #ACTION_GADGET_UPDATE} broadcast for this gadget.
- * If you return {@link android.app.Activity#RESULT_CANCELED}, the host will cancel the add
- * and not display this gadget, and you will receive a {@link #ACTION_GADGET_DELETED} broadcast.
- */
- public static final String ACTION_GADGET_CONFIGURE = "android.gadget.action.GADGET_CONFIGURE";
-
- /**
- * An intent extra that contains one gadgetId.
- *
- * The value will be an int that can be retrieved like this:
- * {@sample frameworks/base/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/GadgetHostActivity.java getExtra_EXTRA_GADGET_ID}
- */
- public static final String EXTRA_GADGET_ID = "gadgetId";
-
- /**
- * An intent extra that contains multiple gadgetIds.
- *
- * The value will be an int array that can be retrieved like this:
- * {@sample frameworks/base/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/TestGadgetProvider.java getExtra_EXTRA_GADGET_IDS}
- */
- public static final String EXTRA_GADGET_IDS = "gadgetIds";
-
- /**
- * A sentiel value that the gadget manager will never return as a gadgetId.
- */
- public static final int INVALID_GADGET_ID = 0;
-
- /**
- * Sent when it is time to update your gadget.
- *
- *
This may be sent in response to a new instance for this gadget provider having
- * been instantiated, the requested {@link GadgetProviderInfo#updatePeriodMillis update interval}
- * having lapsed, or the system booting.
- *
- *
- * The intent will contain the following extras:
- *
- *
- *
{@link #EXTRA_GADGET_IDS}
- *
The gadgetIds to update. This may be all of the gadgets created for this
- * provider, or just a subset. The system tries to send updates for as few gadget
- * instances as possible.
- *
- *
- *
- * @see GadgetProvider#onUpdate GadgetProvider.onUpdate(Context context, GadgetManager gadgetManager, int[] gadgetIds)
- */
- public static final String ACTION_GADGET_UPDATE = "android.gadget.action.GADGET_UPDATE";
-
- /**
- * Sent when an instance of a gadget is deleted from its host.
- *
- * @see GadgetProvider#onDeleted GadgetProvider.onDeleted(Context context, int[] gadgetIds)
- */
- public static final String ACTION_GADGET_DELETED = "android.gadget.action.GADGET_DELETED";
-
- /**
- * Sent when an instance of a gadget is removed from the last host.
- *
- * @see GadgetProvider#onEnabled GadgetProvider.onEnabled(Context context)
- */
- public static final String ACTION_GADGET_DISABLED = "android.gadget.action.GADGET_DISABLED";
-
- /**
- * Sent when an instance of a gadget is added to a host for the first time.
- * This broadcast is sent at boot time if there is a gadget host installed with
- * an instance for this provider.
- *
- * @see GadgetProvider#onEnabled GadgetProvider.onEnabled(Context context)
- */
- public static final String ACTION_GADGET_ENABLED = "android.gadget.action.GADGET_ENABLED";
-
- /**
- * Field for the manifest meta-data tag.
- *
- * @see GadgetProviderInfo
- */
- public static final String META_DATA_GADGET_PROVIDER = "android.gadget.provider";
-
- static WeakHashMap> sManagerCache = new WeakHashMap();
- static IGadgetService sService;
-
- Context mContext;
-
- /**
- * Get the GadgetManager instance to use for the supplied {@link android.content.Context
- * Context} object.
- */
- public static GadgetManager getInstance(Context context) {
- synchronized (sManagerCache) {
- if (sService == null) {
- IBinder b = ServiceManager.getService(Context.GADGET_SERVICE);
- sService = IGadgetService.Stub.asInterface(b);
- }
-
- WeakReference ref = sManagerCache.get(context);
- GadgetManager result = null;
- if (ref != null) {
- result = ref.get();
- }
- if (result == null) {
- result = new GadgetManager(context);
- sManagerCache.put(context, new WeakReference(result));
- }
- return result;
- }
- }
-
- private GadgetManager(Context context) {
- mContext = context;
- }
-
- /**
- * Set the RemoteViews to use for the specified gadgetIds.
- *
- *
- * It is okay to call this method both inside an {@link #ACTION_GADGET_UPDATE} broadcast,
- * and outside of the handler.
- * This method will only work when called from the uid that owns the gadget provider.
- *
- * @param gadgetIds The gadget instances for which to set the RemoteViews.
- * @param views The RemoteViews object to show.
- */
- public void updateGadget(int[] gadgetIds, RemoteViews views) {
- try {
- sService.updateGadgetIds(gadgetIds, views);
- }
- catch (RemoteException e) {
- throw new RuntimeException("system server dead?", e);
- }
- }
-
- /**
- * Set the RemoteViews to use for the specified gadgetId.
- *
- *
- * It is okay to call this method both inside an {@link #ACTION_GADGET_UPDATE} broadcast,
- * and outside of the handler.
- * This method will only work when called from the uid that owns the gadget provider.
- *
- * @param gadgetId The gadget instance for which to set the RemoteViews.
- * @param views The RemoteViews object to show.
- */
- public void updateGadget(int gadgetId, RemoteViews views) {
- updateGadget(new int[] { gadgetId }, views);
- }
-
- /**
- * Set the RemoteViews to use for all gadget instances for the supplied gadget provider.
- *
- *
- * It is okay to call this method both inside an {@link #ACTION_GADGET_UPDATE} broadcast,
- * and outside of the handler.
- * This method will only work when called from the uid that owns the gadget provider.
- *
- * @param provider The {@link ComponentName} for the {@link
- * android.content.BroadcastReceiver BroadcastReceiver} provider
- * for your gadget.
- * @param views The RemoteViews object to show.
- */
- public void updateGadget(ComponentName provider, RemoteViews views) {
- try {
- sService.updateGadgetProvider(provider, views);
- }
- catch (RemoteException e) {
- throw new RuntimeException("system server dead?", e);
- }
- }
-
- /**
- * Return a list of the gadget providers that are currently installed.
- */
- public List getInstalledProviders() {
- try {
- return sService.getInstalledProviders();
- }
- catch (RemoteException e) {
- throw new RuntimeException("system server dead?", e);
- }
- }
-
- /**
- * Get the available info about the gadget.
- *
- * @return A gadgetId. If the gadgetId has not been bound to a provider yet, or
- * you don't have access to that gadgetId, null is returned.
- */
- public GadgetProviderInfo getGadgetInfo(int gadgetId) {
- try {
- return sService.getGadgetInfo(gadgetId);
- }
- catch (RemoteException e) {
- throw new RuntimeException("system server dead?", e);
- }
- }
-
- /**
- * Set the component for a given gadgetId.
- *
- *
You need the GADGET_LIST permission. This method is to be used by the
- * gadget picker.
- *
- * @param gadgetId The gadget instance for which to set the RemoteViews.
- * @param provider The {@link android.content.BroadcastReceiver} that will be the gadget
- * provider for this gadget.
- */
- public void bindGadgetId(int gadgetId, ComponentName provider) {
- try {
- sService.bindGadgetId(gadgetId, provider);
- }
- catch (RemoteException e) {
- throw new RuntimeException("system server dead?", e);
- }
- }
-
- /**
- * Get the list of gadgetIds that have been bound to the given gadget
- * provider.
- *
- * @param provider The {@link android.content.BroadcastReceiver} that is the
- * gadget provider to find gadgetIds for.
- */
- public int[] getGadgetIds(ComponentName provider) {
- try {
- return sService.getGadgetIds(provider);
- }
- catch (RemoteException e) {
- throw new RuntimeException("system server dead?", e);
- }
- }
-}
-
diff --git a/core/java/android/gadget/GadgetProvider.java b/core/java/android/gadget/GadgetProvider.java
deleted file mode 100755
index 7e10e7817a2b6..0000000000000
--- a/core/java/android/gadget/GadgetProvider.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.gadget;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-
-/**
- * A conveience class to aid in implementing a gadget provider.
- * Everything you can do with GadgetProvider, you can do with a regular {@link BroadcastReceiver}.
- * GadgetProvider merely parses the relevant fields out of the Intent that is received in
- * {@link #onReceive(Context,Intent) onReceive(Context,Intent)}, and calls hook methods
- * with the received extras.
- *
- *
Extend this class and override one or more of the {@link #onUpdate}, {@link #onDeleted},
- * {@link #onEnabled} or {@link #onDisabled} methods to implement your own gadget functionality.
- *
- *
Sample Code
- * For an example of how to write a gadget provider, see the
- * android.gadget
- * package overview.
- */
-public class GadgetProvider extends BroadcastReceiver {
- /**
- * Constructor to initialize GadgetProvider.
- */
- public GadgetProvider() {
- }
-
- /**
- * Implements {@link BroadcastReceiver#onReceive} to dispatch calls to the various
- * other methods on GadgetProvider.
- *
- * @param context The Context in which the receiver is running.
- * @param intent The Intent being received.
- */
- // BEGIN_INCLUDE(onReceive)
- public void onReceive(Context context, Intent intent) {
- // Protect against rogue update broadcasts (not really a security issue,
- // just filter bad broacasts out so subclasses are less likely to crash).
- String action = intent.getAction();
- if (GadgetManager.ACTION_GADGET_UPDATE.equals(action)) {
- Bundle extras = intent.getExtras();
- if (extras != null) {
- int[] gadgetIds = extras.getIntArray(GadgetManager.EXTRA_GADGET_IDS);
- if (gadgetIds != null && gadgetIds.length > 0) {
- this.onUpdate(context, GadgetManager.getInstance(context), gadgetIds);
- }
- }
- }
- else if (GadgetManager.ACTION_GADGET_DELETED.equals(action)) {
- Bundle extras = intent.getExtras();
- if (extras != null) {
- int[] gadgetIds = extras.getIntArray(GadgetManager.EXTRA_GADGET_IDS);
- if (gadgetIds != null && gadgetIds.length > 0) {
- this.onDeleted(context, gadgetIds);
- }
- }
- }
- else if (GadgetManager.ACTION_GADGET_ENABLED.equals(action)) {
- this.onEnabled(context);
- }
- else if (GadgetManager.ACTION_GADGET_DISABLED.equals(action)) {
- this.onDisabled(context);
- }
- }
- // END_INCLUDE(onReceive)
-
- /**
- * Called in response to the {@link GadgetManager#ACTION_GADGET_UPDATE} broadcast when
- * this gadget provider is being asked to provide {@link android.widget.RemoteViews RemoteViews}
- * for a set of gadgets. Override this method to implement your own gadget functionality.
- *
- * {@more}
- *
- * @param context The {@link android.content.Context Context} in which this receiver is
- * running.
- * @param gadgetManager A {@link GadgetManager} object you can call {@link
- * GadgetManager#updateGadget} on.
- * @param gadgetIds The gadgetsIds for which an update is needed. Note that this
- * may be all of the gadget instances for this provider, or just
- * a subset of them.
- *
- * @see GadgetManager#ACTION_GADGET_UPDATE
- */
- public void onUpdate(Context context, GadgetManager gadgetManager, int[] gadgetIds) {
- }
-
- /**
- * Called in response to the {@link GadgetManager#ACTION_GADGET_DELETED} broadcast when
- * one or more gadget instances have been deleted. Override this method to implement
- * your own gadget functionality.
- *
- * {@more}
- *
- * @param context The {@link android.content.Context Context} in which this receiver is
- * running.
- * @param gadgetIds The gadgetsIds that have been deleted from their host.
- *
- * @see GadgetManager#ACTION_GADGET_DELETED
- */
- public void onDeleted(Context context, int[] gadgetIds) {
- }
-
- /**
- * Called in response to the {@link GadgetManager#ACTION_GADGET_ENABLED} broadcast when
- * the a gadget for this provider is instantiated. Override this method to implement your
- * own gadget functionality.
- *
- * {@more}
- * When the last gadget for this provider is deleted,
- * {@link GadgetManager#ACTION_GADGET_DISABLED} is sent by the gadget manager, and
- * {@link #onDisabled} is called. If after that, a gadget for this provider is created
- * again, onEnabled() will be called again.
- *
- * @param context The {@link android.content.Context Context} in which this receiver is
- * running.
- *
- * @see GadgetManager#ACTION_GADGET_ENABLED
- */
- public void onEnabled(Context context) {
- }
-
- /**
- * Called in response to the {@link GadgetManager#ACTION_GADGET_DISABLED} broadcast, which
- * is sent when the last gadget instance for this provider is deleted. Override this method
- * to implement your own gadget functionality.
- *
- * {@more}
- *
- * @param context The {@link android.content.Context Context} in which this receiver is
- * running.
- *
- * @see GadgetManager#ACTION_GADGET_DISABLED
- */
- public void onDisabled(Context context) {
- }
-}
diff --git a/core/java/android/gadget/package.html b/core/java/android/gadget/package.html
deleted file mode 100644
index 4c04396e8b7e6..0000000000000
--- a/core/java/android/gadget/package.html
+++ /dev/null
@@ -1,136 +0,0 @@
-
-
Android allows applications to publish views to be embedded in other applications. These
-views are called gadgets, and are published by "gadget providers." The component that can
-contain gadgets is called a "gadget host."
-
-Any application can publish gadgets. All an application needs to do to publish a gadget is
-to have a {@link android.content.BroadcastReceiver} that receives the {@link
-android.gadget.GadgetManager#ACTION_GADGET_UPDATE GadgetManager.ACTION_GADGET_UPDATE} intent,
-and provide some meta-data about the gadget. Android provides the
-{@link android.gadget.GadgetProvider} class, which extends BroadcastReceiver, as a convenience
-class to aid in handling the broadcasts.
-
-
Declaring a gadget in the AndroidManifest
-
-
-First, declare the {@link android.content.BroadcastReceiver} in your application's
-AndroidManifest.xml file.
-
-{@sample frameworks/base/tests/gadgets/GadgetHostTest/AndroidManifest.xml GadgetProvider}
-
-
-The <receiver> element has the following attributes:
-
-
android:name - which specifies the
- {@link android.content.BroadcastReceiver} or {@link android.gadget.GadgetProvider}
- class.
-
android:label - which specifies the string resource that
- will be shown by the gadget picker as the label.
-
android:icon - which specifies the drawable resource that
- will be shown by the gadget picker as the icon.
-
-
-
-The <intent-filter> element tells the {@link android.content.pm.PackageManager}
-that this {@link android.content.BroadcastReceiver} receives the {@link
-android.gadget.GadgetManager#ACTION_GADGET_UPDATE GadgetManager.ACTION_GADGET_UPDATE} broadcast.
-The gadget manager will send other broadcasts directly to your gadget provider as required.
-It is only necessary to explicitly declare that you accept the {@link
-android.gadget.GadgetManager#ACTION_GADGET_UPDATE GadgetManager.ACTION_GADGET_UPDATE} broadcast.
-
-
-The <meta-data> element tells the gadget manager which xml resource to
-read to find the {@link android.gadget.GadgetProviderInfo} for your gadget provider. It has the following
-attributes:
-
-
android:name="android.gadget.provider" - identifies this meta-data
- as the {@link android.gadget.GadgetProviderInfo} descriptor.
-
android:resource - is the xml resource to use as that descriptor.
-
-
-
-
Adding the {@link android.gadget.GadgetProviderInfo GadgetProviderInfo} meta-data
-
-
-For a gadget, the values in the {@link android.gadget.GadgetProviderInfo} structure are supplied
-in an XML resource. In the example above, the xml resource is referenced with
-android:resource="@xml/gadget_info". That XML file would go in your application's
-directory at res/xml/gadget_info.xml. Here is a simple example.
-
-{@sample frameworks/base/tests/gadgets/GadgetHostTest/res/xml/gadget_info.xml GadgetProviderInfo}
-
-
-The attributes are as documented in the {@link android.gadget.GadgetProviderInfo GagetInfo} class. (86400000 milliseconds means once per day)
-
-
-
Using the {@link android.gadget.GadgetProvider GadgetProvider} class
-
-
The GadgetProvider class is the easiest way to handle the gadget provider intent broadcasts.
-See the src/com/example/android/apis/gadget/ExampleGadgetProvider.java
-sample class in ApiDemos for an example.
-
-
Keep in mind that since the the GadgetProvider is a BroadcastReceiver,
-your process is not guaranteed to keep running after the callback methods return. See
-Application Fundamentals >
-Broadcast Receiver Lifecycle for more information.
-
-
-
-
Gadget Configuration UI
-
-
-Gadget hosts have the ability to start a configuration activity when a gadget is instantiated.
-The activity should be declared as normal in AndroidManifest.xml, and it should be listed in
-the GadgetProviderInfo XML file in the android:configure attribute.
-
-
The activity you specified will be launched with the {@link
-android.gadget.GadgetManager#ACTION_GADGET_CONFIGURE} action. See the documentation for that
-action for more info.
-
-
See the src/com/example/android/apis/gadget/ExampleGadgetConfigure.java
-sample class in ApiDemos for an example.
-
-
-
-
Gadget Broadcast Intents
-
-
{@link android.gadget.GadgetProvider} is just a convenience class. If you would like
-to receive the gadget broadcasts directly, you can. The four intents you need to care about are:
-
Gadget hosts are the containers in which gadgets can be placed. Most of the look and feel
-details are left up to the gadget hosts. For example, the home screen has one way of viewing
-gadgets, but the lock screen could also contain gadgets, and it would have a different way of
-adding, removing and otherwise managing gadgets.
-
For more information on implementing your own gadget host, see the
-{@link android.gadget.GadgetHost GadgetHost} class.
-
-
diff --git a/core/java/android/inputmethodservice/ExtractButton.java b/core/java/android/inputmethodservice/ExtractButton.java
new file mode 100644
index 0000000000000..d6fe38d3ea4a4
--- /dev/null
+++ b/core/java/android/inputmethodservice/ExtractButton.java
@@ -0,0 +1,30 @@
+package android.inputmethodservice;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.Button;
+
+/***
+ * Specialization of {@link Button} that ignores the window not being focused.
+ */
+class ExtractButton extends Button {
+ public ExtractButton(Context context) {
+ super(context, null);
+ }
+
+ public ExtractButton(Context context, AttributeSet attrs) {
+ super(context, attrs, com.android.internal.R.attr.buttonStyle);
+ }
+
+ public ExtractButton(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ /**
+ * Pretend like the window this view is in always has focus, so it will
+ * highlight when selected.
+ */
+ @Override public boolean hasWindowFocus() {
+ return this.isEnabled() ? true : false;
+ }
+}
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 34d569592fd3d..32270c46d039a 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -1398,10 +1398,17 @@ public class InputMethodService extends AbstractInputMethodService {
int newSelStart, int newSelEnd,
int candidatesStart, int candidatesEnd) {
final ExtractEditText eet = mExtractEditText;
- if (eet != null && mExtractedText != null) {
+ if (eet != null && isFullscreenMode() && mExtractedText != null) {
final int off = mExtractedText.startOffset;
eet.startInternalChanges();
- eet.setSelection(newSelStart-off, newSelEnd-off);
+ newSelStart -= off;
+ newSelEnd -= off;
+ final int len = eet.getText().length();
+ if (newSelStart < 0) newSelStart = 0;
+ else if (newSelStart > len) newSelStart = len;
+ if (newSelEnd < 0) newSelEnd = 0;
+ else if (newSelEnd > len) newSelEnd = len;
+ eet.setSelection(newSelStart, newSelEnd);
eet.finishInternalChanges();
}
}
diff --git a/core/java/android/provider/Contacts.java b/core/java/android/provider/Contacts.java
index 3bffaec52989f..d0bd2a56e4d1c 100644
--- a/core/java/android/provider/Contacts.java
+++ b/core/java/android/provider/Contacts.java
@@ -1423,7 +1423,42 @@ public class Contacts {
*/
public static final String ATTACH_IMAGE =
"com.android.contacts.action.ATTACH_IMAGE";
-
+
+ /**
+ * Takes as input a data URI with a mailto: or tel: scheme. If a single
+ * contact exists with the given data it will be shown. If no contact
+ * exists, a dialog will ask the user if they want to create a new
+ * contact with the provided details filled in. If multiple contacts
+ * share the data the user will be prompted to pick which contact they
+ * want to view.
+ *
+ * For mailto: URIs, the scheme specific portion must be a
+ * raw email address, such as one built using
+ * {@link Uri#fromParts(String, String, String)}.
+ *
+ * For tel: URIs, the scheme specific portion is compared
+ * to existing numbers using the standard caller ID lookup algorithm.
+ * The number must be properly encoded, for example using
+ * {@link Uri#fromParts(String, String, String)}.
+ *
+ * Any extras from the {@link Insert} class will be passed along to the
+ * create activity if there are no contacts to show.
+ *
+ * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
+ * prompting the user when the contact doesn't exist.
+ */
+ public static final String SHOW_OR_CREATE_CONTACT =
+ "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
+
+ /**
+ * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new contact if no matching
+ * contact found. Otherwise, default behavior is to prompt user with dialog before creating.
+ *
+ *
Type: BOOLEAN
+ */
+ public static final String EXTRA_FORCE_CREATE =
+ "com.android.contacts.action.FORCE_CREATE";
+
/**
* Intents related to the Contacts app UI.
*/
diff --git a/core/java/android/provider/Gmail.java b/core/java/android/provider/Gmail.java
index 5b3c2234ded1c..cc039686249dc 100644
--- a/core/java/android/provider/Gmail.java
+++ b/core/java/android/provider/Gmail.java
@@ -1540,7 +1540,15 @@ public final class Gmail {
/** Returns the number of unread conversation with a given label. */
public int getNumUnreadConversations(long labelId) {
- return getLabelIdValues(labelId).getAsInteger(LabelColumns.NUM_UNREAD_CONVERSATIONS);
+ Integer unreadConversations =
+ getLabelIdValues(labelId).getAsInteger(LabelColumns.NUM_UNREAD_CONVERSATIONS);
+ // There seems to be a race condition here that can get the label maps into a bad
+ // state and lose state on a particular label.
+ if (unreadConversations == null) {
+ return 0;
+ } else {
+ return unreadConversations;
+ }
}
/**
diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java
index f8bc765e0a047..3aa407858100c 100644
--- a/core/java/android/server/BluetoothA2dpService.java
+++ b/core/java/android/server/BluetoothA2dpService.java
@@ -208,6 +208,15 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
if (mAudioDevices == null) {
return BluetoothError.ERROR;
}
+ // ignore if there are any active sinks
+ if (lookupSinksMatchingStates(new int[] {
+ BluetoothA2dp.STATE_CONNECTING,
+ BluetoothA2dp.STATE_CONNECTED,
+ BluetoothA2dp.STATE_PLAYING,
+ BluetoothA2dp.STATE_DISCONNECTING}).size() != 0) {
+ return BluetoothError.ERROR;
+ }
+
String path = lookupPath(address);
if (path == null) {
path = createHeadsetNative(address);
diff --git a/core/java/android/server/BluetoothDeviceService.java b/core/java/android/server/BluetoothDeviceService.java
index 6f5513a369ae9..e271909934934 100644
--- a/core/java/android/server/BluetoothDeviceService.java
+++ b/core/java/android/server/BluetoothDeviceService.java
@@ -287,6 +287,7 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
} else {
intent = new Intent(BluetoothIntent.DISABLED_ACTION);
}
+ intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
mEnableThread = null;
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index e4ebcca4d0805..8e77eed9c067c 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -52,6 +52,7 @@ class BluetoothEventLoop {
private Context mContext;
private static final int EVENT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY = 1;
+ private static final int EVENT_RESTART_BLUETOOTH = 2;
// The time (in millisecs) to delay the pairing attempt after the first
// auto pairing attempt fails. We use an exponential delay with
@@ -74,6 +75,10 @@ class BluetoothEventLoop {
return;
}
break;
+ case EVENT_RESTART_BLUETOOTH:
+ mBluetoothService.disable();
+ mBluetoothService.enable(null);
+ break;
}
}
};
@@ -372,6 +377,13 @@ class BluetoothEventLoop {
}
}
+ private void onRestartRequired() {
+ if (mBluetoothService.isEnabled()) {
+ Log.e(TAG, "*** A serious error occured (did hcid crash?) - restarting Bluetooth ***");
+ mHandler.sendEmptyMessage(EVENT_RESTART_BLUETOOTH);
+ }
+ }
+
private static void log(String msg) {
Log.d(TAG, msg);
}
diff --git a/core/java/android/text/method/QwertyKeyListener.java b/core/java/android/text/method/QwertyKeyListener.java
index 3f8288c83e69c..21bc2a6311b64 100644
--- a/core/java/android/text/method/QwertyKeyListener.java
+++ b/core/java/android/text/method/QwertyKeyListener.java
@@ -298,8 +298,10 @@ public class QwertyKeyListener extends BaseKeyListener {
content.removeSpan(repl[0]);
// only cancel the autocomplete if the cursor is at the end of
- // the replaced span
- if (selStart == en) {
+ // the replaced span (or after it, because the user is
+ // backspacing over the space after the word, not the word
+ // itself).
+ if (selStart >= en) {
content.setSpan(TextKeyListener.INHIBIT_REPLACEMENT,
en, en, Spannable.SPAN_POINT_POINT);
content.replace(st, en, old);
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index d78320a01b87e..c3e00c40d941c 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -1511,8 +1511,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback {
@ViewDebug.ExportedProperty
int mUserPaddingBottom;
- private int mOldWidthMeasureSpec = Integer.MIN_VALUE;
- private int mOldHeightMeasureSpec = Integer.MIN_VALUE;
+ /**
+ * @hide
+ */
+ int mOldWidthMeasureSpec = Integer.MIN_VALUE;
+ /**
+ * @hide
+ */
+ int mOldHeightMeasureSpec = Integer.MIN_VALUE;
private Resources mResources = null;
@@ -2661,9 +2667,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback {
* @attr ref android.R.styleable#View_visibility
*/
@ViewDebug.ExportedProperty(mapping = {
- @ViewDebug.IntToString(from = 0, to = "VISIBLE"),
- @ViewDebug.IntToString(from = 4, to = "INVISIBLE"),
- @ViewDebug.IntToString(from = 8, to = "GONE")
+ @ViewDebug.IntToString(from = VISIBLE, to = "VISIBLE"),
+ @ViewDebug.IntToString(from = INVISIBLE, to = "INVISIBLE"),
+ @ViewDebug.IntToString(from = GONE, to = "GONE")
})
public int getVisibility() {
return mViewFlags & VISIBILITY_MASK;
@@ -3291,8 +3297,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback {
* when ViewDebug.SYSTEM_PROPERTY_CAPTURE_VIEW) is set
*/
private static void captureViewInfo(String subTag, View v) {
- if (v == null ||
- SystemProperties.getInt(ViewDebug.SYSTEM_PROPERTY_CAPTURE_VIEW, 0) == 0) {
+ if (v == null || SystemProperties.getInt(ViewDebug.SYSTEM_PROPERTY_CAPTURE_VIEW, 0) == 0) {
return;
}
ViewDebug.dumpCapturedView(subTag, v);
diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java
index 883c7bd2e5d26..0a043bd13ea01 100644
--- a/core/java/android/view/ViewDebug.java
+++ b/core/java/android/view/ViewDebug.java
@@ -17,9 +17,12 @@
package android.view;
import android.util.Log;
+import android.util.DisplayMetrics;
import android.content.res.Resources;
import android.graphics.Bitmap;
+import android.graphics.Canvas;
import android.os.Environment;
+import android.os.Debug;
import java.io.File;
import java.io.BufferedWriter;
@@ -43,6 +46,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.AccessibleObject;
/**
* Various debugging/tracing tools related to {@link View} and the view hierarchy.
@@ -73,7 +77,7 @@ public class ViewDebug {
* when it is set, we log key events, touch/motion and trackball events
*/
static final String SYSTEM_PROPERTY_CAPTURE_EVENT = "debug.captureevent";
-
+
/**
* This annotation can be used to mark fields and methods to be dumped by
* the view server. Only non-void methods with no arguments can be annotated
@@ -112,6 +116,27 @@ public class ViewDebug {
*/
IntToString[] mapping() default { };
+ /**
+ * A mapping can be defined to map array indices to specific strings.
+ * A mapping can be used to see human readable values for the indices
+ * of an array:
+ *
+ *