summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/java/android/appwidget/AppWidgetHost.java31
-rw-r--r--core/java/android/appwidget/AppWidgetManager.java37
-rw-r--r--core/java/android/appwidget/AppWidgetProviderInfo.java5
-rw-r--r--core/java/com/android/internal/appwidget/IAppWidgetService.aidl7
4 files changed, 39 insertions, 41 deletions
diff --git a/core/java/android/appwidget/AppWidgetHost.java b/core/java/android/appwidget/AppWidgetHost.java
index 66a6eb6..69716e5 100644
--- a/core/java/android/appwidget/AppWidgetHost.java
+++ b/core/java/android/appwidget/AppWidgetHost.java
@@ -19,12 +19,15 @@ package android.appwidget;
import java.util.ArrayList;
import java.util.HashMap;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Binder;
+import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
@@ -199,32 +202,30 @@ public class AppWidgetHost {
/**
* Starts an app widget provider configure activity for result on behalf of the caller.
* Use this method if the provider is in another profile as you are not allowed to start
- * an activity in another profile. The provided intent must have action {@link
- * AppWidgetManager#ACTION_APPWIDGET_CONFIGURE}. The widget id must be specified by
- * the {@link AppWidgetManager#EXTRA_APPWIDGET_ID} extra. The provider configure
- * activity must be specified as the component name of the intent via {@link
- * Intent#setComponent(android.content.ComponentName)}. The user profile under which
- * the provider operates is specified via the {@link
- * AppWidgetManager#EXTRA_APPWIDGET_PROVIDER_PROFILE} extra. If a user profile is
- * not provided, the current user is used. Finally, you can optionally provide a
- * request code that is returned in {@link Activity#onActivityResult(int, int,
- * android.content.Intent)}.
+ * an activity in another profile. You can optionally provide a request code that is
+ * returned in {@link Activity#onActivityResult(int, int, android.content.Intent)} and
+ * an options bundle to be passed to the started activity.
+ * <p>
+ * Note that the provided app widget has to be bound for this method to work.
+ * </p>
*
* @param activity The activity from which to start the configure one.
- * @param intent Properly populated intent for launching the configuration activity.
+ * @param appWidgetId The bound app widget whose provider's config activity to start.
* @param requestCode Optional request code retuned with the result.
+ * @param intentFlags Optional intent flags.
*
* @throws android.content.ActivityNotFoundException If the activity is not found.
*
* @see AppWidgetProviderInfo#getProfile()
*/
- public final void startAppWidgetConfigureActivityForResult(Activity activity, Intent intent,
- int requestCode) {
+ public final void startAppWidgetConfigureActivityForResult(@NonNull Activity activity,
+ int appWidgetId, int intentFlags, int requestCode, @Nullable Bundle options) {
try {
IntentSender intentSender = sService.createAppWidgetConfigIntentSender(
- mContext.getPackageName(), intent);
+ mContext.getPackageName(), appWidgetId, intentFlags);
if (intentSender != null) {
- activity.startIntentSenderForResult(intentSender, requestCode, null, 0, 0, 0);
+ activity.startIntentSenderForResult(intentSender, requestCode, null, 0, 0, 0,
+ options);
} else {
throw new ActivityNotFoundException();
}
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java
index e5d1d95..086eb7d 100644
--- a/core/java/android/appwidget/AppWidgetManager.java
+++ b/core/java/android/appwidget/AppWidgetManager.java
@@ -16,6 +16,7 @@
package android.appwidget;
+import android.annotation.Nullable;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -673,24 +674,24 @@ public class AppWidgetManager {
}
/**
- * Gets the AppWidget providers for the given user profiles. User profiles can only
+ * Gets the AppWidget providers for the given user profile. User profile can only
* be the current user or a profile of the current user. For example, the current
* user may have a corporate profile. In this case the parent user profile has a
* child profile, the corporate one.
*
- * @param profiles The profiles for which to get providers. Passing null is equivaled
+ * @param profile The profile for which to get providers. Passing null is equivaled
* to passing only the current user handle.
* @return The intalled providers.
*
* @see android.os.Process#myUserHandle()
* @see android.os.UserManager#getUserProfiles()
*/
- public List<AppWidgetProviderInfo> getInstalledProvidersForProfiles(UserHandle[] profiles) {
+ public List<AppWidgetProviderInfo> getInstalledProvidersForProfile(@Nullable UserHandle profile) {
if (mService == null) {
return Collections.emptyList();
}
- return getInstalledProvidersForProfiles(AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN,
- profiles);
+ return getInstalledProvidersForProfile(AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN,
+ profile);
}
/**
@@ -700,7 +701,7 @@ public class AppWidgetManager {
if (mService == null) {
return Collections.emptyList();
}
- return getInstalledProvidersForProfiles(AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN,
+ return getInstalledProvidersForProfile(AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN,
null);
}
@@ -720,18 +721,18 @@ public class AppWidgetManager {
if (mService == null) {
return Collections.emptyList();
}
- return getInstalledProvidersForProfiles(categoryFilter, null);
+ return getInstalledProvidersForProfile(categoryFilter, null);
}
/**
- * Gets the AppWidget providers for the given user profiles. User profiles can only
+ * Gets the AppWidget providers for the given user profile. User profile can only
* be the current user or a profile of the current user. For example, the current
* user may have a corporate profile. In this case the parent user profile has a
* child profile, the corporate one.
*
* @param categoryFilter Will only return providers which register as any of the specified
* specified categories. See {@link AppWidgetProviderInfo#widgetCategory}.
- * @param profiles Child profiles of the current user which to be queried. The user
+ * @param profile A profile of the current user which to be queried. The user
* is itself also a profile. If null, the providers only for the current user
* are returned.
* @return The intalled providers.
@@ -741,25 +742,19 @@ public class AppWidgetManager {
*
* @hide
*/
- public List<AppWidgetProviderInfo> getInstalledProvidersForProfiles(int categoryFilter,
- UserHandle[] profiles) {
+ public List<AppWidgetProviderInfo> getInstalledProvidersForProfile(int categoryFilter,
+ UserHandle profile) {
if (mService == null) {
return Collections.emptyList();
}
- int[] profileIds = null;
-
- if (profiles != null) {
- final int profileCount = profiles.length;
- profileIds = new int[profileCount];
- for (int i = 0; i < profileCount; i++) {
- profileIds[i] = profiles[i].getIdentifier();
- }
+ if (profile == null) {
+ profile = Process.myUserHandle();
}
try {
- List<AppWidgetProviderInfo> providers = mService.getInstalledProviders(categoryFilter,
- profileIds);
+ List<AppWidgetProviderInfo> providers = mService.getInstalledProvidersForProfile(
+ categoryFilter, profile.getIdentifier());
if (providers == null) {
return Collections.emptyList();
}
diff --git a/core/java/android/appwidget/AppWidgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java
index 6835368..a767246 100644
--- a/core/java/android/appwidget/AppWidgetProviderInfo.java
+++ b/core/java/android/appwidget/AppWidgetProviderInfo.java
@@ -16,6 +16,7 @@
package android.appwidget;
+import android.annotation.NonNull;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
@@ -269,7 +270,7 @@ public class AppWidgetProviderInfo implements Parcelable {
* {@link android.util.DisplayMetrics#densityDpi}.
* @return The provider icon.
*/
- public final Drawable loadIcon(Context context, int density) {
+ public final Drawable loadIcon(@NonNull Context context, int density) {
return loadDrawable(context, density, providerInfo.getIconResource());
}
@@ -289,7 +290,7 @@ public class AppWidgetProviderInfo implements Parcelable {
* {@link android.util.DisplayMetrics#densityDpi}.
* @return The widget preview image.
*/
- public final Drawable loadPreviewImage(Context context, int density) {
+ public final Drawable loadPreviewImage(@NonNull Context context, int density) {
return loadDrawable(context, density, previewImage);
}
diff --git a/core/java/com/android/internal/appwidget/IAppWidgetService.aidl b/core/java/com/android/internal/appwidget/IAppWidgetService.aidl
index 9da1c9d..008d38b 100644
--- a/core/java/com/android/internal/appwidget/IAppWidgetService.aidl
+++ b/core/java/com/android/internal/appwidget/IAppWidgetService.aidl
@@ -41,7 +41,8 @@ interface IAppWidgetService {
void deleteAllHosts();
RemoteViews getAppWidgetViews(String callingPackage, int appWidgetId);
int[] getAppWidgetIdsForHost(String callingPackage, int hostId);
- IntentSender createAppWidgetConfigIntentSender(String callingPackage, in Intent intent);
+ IntentSender createAppWidgetConfigIntentSender(String callingPackage, int appWidgetId,
+ int intentFlags);
//
// for AppWidgetManager
@@ -53,8 +54,8 @@ interface IAppWidgetService {
in RemoteViews views);
void updateAppWidgetProvider(in ComponentName provider, in RemoteViews views);
void notifyAppWidgetViewDataChanged(String packageName, in int[] appWidgetIds, int viewId);
- List<AppWidgetProviderInfo> getInstalledProviders(int categoryFilter,
- in int[] profileIds);
+ List<AppWidgetProviderInfo> getInstalledProvidersForProfile(int categoryFilter,
+ int profileId);
AppWidgetProviderInfo getAppWidgetInfo(String callingPackage, int appWidgetId);
boolean hasBindAppWidgetPermission(in String packageName, int userId);
void setBindAppWidgetPermission(in String packageName, int userId, in boolean permission);