summaryrefslogtreecommitdiffstats
path: root/services/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com')
-rw-r--r--services/java/com/android/server/AppWidgetService.java (renamed from services/java/com/android/server/GadgetService.java)320
-rw-r--r--services/java/com/android/server/SystemServer.java14
-rw-r--r--services/java/com/android/server/WindowManagerService.java39
3 files changed, 192 insertions, 181 deletions
diff --git a/services/java/com/android/server/GadgetService.java b/services/java/com/android/server/AppWidgetService.java
index 0943778..de5d0ac 100644
--- a/services/java/com/android/server/GadgetService.java
+++ b/services/java/com/android/server/AppWidgetService.java
@@ -18,6 +18,8 @@ package com.android.server;
import android.app.AlarmManager;
import android.app.PendingIntent;
+import android.appwidget.AppWidgetManager;
+import android.appwidget.AppWidgetProviderInfo;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -30,8 +32,6 @@ import android.content.pm.ResolveInfo;
import android.content.pm.PackageItemInfo;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
-import android.gadget.GadgetManager;
-import android.gadget.GadgetProviderInfo;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
@@ -53,8 +53,8 @@ import java.util.List;
import java.util.HashMap;
import java.util.HashSet;
-import com.android.internal.gadget.IGadgetService;
-import com.android.internal.gadget.IGadgetHost;
+import com.android.internal.appwidget.IAppWidgetService;
+import com.android.internal.appwidget.IAppWidgetHost;
import com.android.internal.util.XmlUtils;
import com.android.internal.util.FastXmlSerializer;
@@ -62,11 +62,11 @@ import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
-class GadgetService extends IGadgetService.Stub
+class AppWidgetService extends IAppWidgetService.Stub
{
- private static final String TAG = "GadgetService";
+ private static final String TAG = "AppWidgetService";
- private static final String SETTINGS_FILENAME = "gadgets.xml";
+ private static final String SETTINGS_FILENAME = "appwidgets.xml";
private static final String SETTINGS_TMP_FILENAME = SETTINGS_FILENAME + ".tmp";
/*
@@ -77,8 +77,8 @@ class GadgetService extends IGadgetService.Stub
static class Provider {
int uid;
- GadgetProviderInfo info;
- ArrayList<GadgetId> instances = new ArrayList();
+ AppWidgetProviderInfo info;
+ ArrayList<AppWidgetId> instances = new ArrayList();
PendingIntent broadcast;
boolean zombie; // if we're in safe mode, don't prune this just because nobody references it
@@ -89,15 +89,15 @@ class GadgetService extends IGadgetService.Stub
int uid;
int hostId;
String packageName;
- ArrayList<GadgetId> instances = new ArrayList();
- IGadgetHost callbacks;
+ ArrayList<AppWidgetId> instances = new ArrayList();
+ IAppWidgetHost callbacks;
boolean zombie; // if we're in safe mode, don't prune this just because nobody references it
int tag; // for use while saving state (the index)
}
- static class GadgetId {
- int gadgetId;
+ static class AppWidgetId {
+ int appWidgetId;
Provider provider;
RemoteViews views;
Host host;
@@ -107,12 +107,12 @@ class GadgetService extends IGadgetService.Stub
PackageManager mPackageManager;
AlarmManager mAlarmManager;
ArrayList<Provider> mInstalledProviders = new ArrayList();
- int mNextGadgetId = GadgetManager.INVALID_GADGET_ID + 1;
- ArrayList<GadgetId> mGadgetIds = new ArrayList();
+ int mNextAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID + 1;
+ ArrayList<AppWidgetId> mAppWidgetIds = new ArrayList();
ArrayList<Host> mHosts = new ArrayList();
boolean mSafeMode;
- GadgetService(Context context) {
+ AppWidgetService(Context context) {
mContext = context;
mPackageManager = context.getPackageManager();
mAlarmManager = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
@@ -121,7 +121,7 @@ class GadgetService extends IGadgetService.Stub
public void systemReady(boolean safeMode) {
mSafeMode = safeMode;
- loadGadgetList();
+ loadAppWidgetList();
loadStateLocked();
// Register for the boot completed broadcast, so we can send the
@@ -149,23 +149,23 @@ class GadgetService extends IGadgetService.Stub
return;
}
- synchronized (mGadgetIds) {
+ synchronized (mAppWidgetIds) {
int N = mInstalledProviders.size();
pw.println("Providers: (size=" + N + ")");
for (int i=0; i<N; i++) {
Provider p = mInstalledProviders.get(i);
- GadgetProviderInfo info = p.info;
+ AppWidgetProviderInfo info = p.info;
pw.println(" [" + i + "] provder=" + info.provider
+ " min=(" + info.minWidth + "x" + info.minHeight + ")"
+ " updatePeriodMillis=" + info.updatePeriodMillis
+ " initialLayout=" + info.initialLayout + " zombie=" + p.zombie);
}
- N = mGadgetIds.size();
- pw.println("GadgetIds: (size=" + N + ")");
+ N = mAppWidgetIds.size();
+ pw.println("AppWidgetIds: (size=" + N + ")");
for (int i=0; i<N; i++) {
- GadgetId id = mGadgetIds.get(i);
- pw.println(" [" + i + "] gadgetId=" + id.gadgetId
+ AppWidgetId id = mAppWidgetIds.get(i);
+ pw.println(" [" + i + "] appWidgetId=" + id.appWidgetId
+ " host=" + id.host.hostId + "/" + id.host.packageName + " provider="
+ (id.provider == null ? "null" : id.provider.info.provider)
+ " host.callbacks=" + (id.host != null ? id.host.callbacks : "(no host)")
@@ -183,38 +183,38 @@ class GadgetService extends IGadgetService.Stub
}
}
- public int allocateGadgetId(String packageName, int hostId) {
+ public int allocateAppWidgetId(String packageName, int hostId) {
int callingUid = enforceCallingUid(packageName);
- synchronized (mGadgetIds) {
- int gadgetId = mNextGadgetId++;
+ synchronized (mAppWidgetIds) {
+ int appWidgetId = mNextAppWidgetId++;
Host host = lookupOrAddHostLocked(callingUid, packageName, hostId);
- GadgetId id = new GadgetId();
- id.gadgetId = gadgetId;
+ AppWidgetId id = new AppWidgetId();
+ id.appWidgetId = appWidgetId;
id.host = host;
host.instances.add(id);
- mGadgetIds.add(id);
+ mAppWidgetIds.add(id);
saveStateLocked();
- return gadgetId;
+ return appWidgetId;
}
}
- public void deleteGadgetId(int gadgetId) {
- synchronized (mGadgetIds) {
- GadgetId id = lookupGadgetIdLocked(gadgetId);
+ public void deleteAppWidgetId(int appWidgetId) {
+ synchronized (mAppWidgetIds) {
+ AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
if (id != null) {
- deleteGadgetLocked(id);
+ deleteAppWidgetLocked(id);
saveStateLocked();
}
}
}
public void deleteHost(int hostId) {
- synchronized (mGadgetIds) {
+ synchronized (mAppWidgetIds) {
int callingUid = getCallingUid();
Host host = lookupHostLocked(callingUid, hostId);
if (host != null) {
@@ -225,7 +225,7 @@ class GadgetService extends IGadgetService.Stub
}
public void deleteAllHosts() {
- synchronized (mGadgetIds) {
+ synchronized (mAppWidgetIds) {
int callingUid = getCallingUid();
final int N = mHosts.size();
boolean changed = false;
@@ -245,8 +245,8 @@ class GadgetService extends IGadgetService.Stub
void deleteHostLocked(Host host) {
final int N = host.instances.size();
for (int i=N-1; i>=0; i--) {
- GadgetId id = host.instances.get(i);
- deleteGadgetLocked(id);
+ AppWidgetId id = host.instances.get(i);
+ deleteAppWidgetLocked(id);
}
host.instances.clear();
mHosts.remove(host);
@@ -254,28 +254,28 @@ class GadgetService extends IGadgetService.Stub
host.callbacks = null;
}
- void deleteGadgetLocked(GadgetId id) {
+ void deleteAppWidgetLocked(AppWidgetId id) {
Host host = id.host;
host.instances.remove(id);
pruneHostLocked(host);
- mGadgetIds.remove(id);
+ mAppWidgetIds.remove(id);
Provider p = id.provider;
if (p != null) {
p.instances.remove(id);
if (!p.zombie) {
- // send the broacast saying that this gadgetId has been deleted
- Intent intent = new Intent(GadgetManager.ACTION_GADGET_DELETED);
+ // send the broacast saying that this appWidgetId has been deleted
+ Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_DELETED);
intent.setComponent(p.info.provider);
- intent.putExtra(GadgetManager.EXTRA_GADGET_ID, id.gadgetId);
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id.appWidgetId);
mContext.sendBroadcast(intent);
if (p.instances.size() == 0) {
// cancel the future updates
cancelBroadcasts(p);
// send the broacast saying that the provider is not in use any more
- intent = new Intent(GadgetManager.ACTION_GADGET_DISABLED);
+ intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_DISABLED);
intent.setComponent(p.info.provider);
mContext.sendBroadcast(intent);
}
@@ -296,21 +296,21 @@ class GadgetService extends IGadgetService.Stub
}
}
- public void bindGadgetId(int gadgetId, ComponentName provider) {
- mContext.enforceCallingPermission(android.Manifest.permission.BIND_GADGET,
- "bindGagetId gadgetId=" + gadgetId + " provider=" + provider);
- synchronized (mGadgetIds) {
- GadgetId id = lookupGadgetIdLocked(gadgetId);
+ public void bindAppWidgetId(int appWidgetId, ComponentName provider) {
+ mContext.enforceCallingPermission(android.Manifest.permission.BIND_APPWIDGET,
+ "bindGagetId appWidgetId=" + appWidgetId + " provider=" + provider);
+ synchronized (mAppWidgetIds) {
+ AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
if (id == null) {
- throw new IllegalArgumentException("bad gadgetId");
+ throw new IllegalArgumentException("bad appWidgetId");
}
if (id.provider != null) {
- throw new IllegalArgumentException("gadgetId " + gadgetId + " already bound to "
+ throw new IllegalArgumentException("appWidgetId " + appWidgetId + " already bound to "
+ id.provider.info.provider);
}
Provider p = lookupProviderLocked(provider);
if (p == null) {
- throw new IllegalArgumentException("not a gadget provider: " + provider);
+ throw new IllegalArgumentException("not a appwidget provider: " + provider);
}
if (p.zombie) {
throw new IllegalArgumentException("can't bind to a 3rd party provider in"
@@ -325,21 +325,21 @@ class GadgetService extends IGadgetService.Stub
sendEnableIntentLocked(p);
}
- // send an update now -- We need this update now, and just for this gadgetId.
+ // send an update now -- We need this update now, and just for this appWidgetId.
// It's less critical when the next one happens, so when we schdule the next one,
// we add updatePeriodMillis to its start time. That time will have some slop,
// but that's okay.
- sendUpdateIntentLocked(p, new int[] { gadgetId });
+ sendUpdateIntentLocked(p, new int[] { appWidgetId });
// schedule the future updates
- registerForBroadcastsLocked(p, getGadgetIds(p));
+ registerForBroadcastsLocked(p, getAppWidgetIds(p));
saveStateLocked();
}
}
- public GadgetProviderInfo getGadgetInfo(int gadgetId) {
- synchronized (mGadgetIds) {
- GadgetId id = lookupGadgetIdLocked(gadgetId);
+ public AppWidgetProviderInfo getAppWidgetInfo(int appWidgetId) {
+ synchronized (mAppWidgetIds) {
+ AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
if (id != null && id.provider != null && !id.provider.zombie) {
return id.provider.info;
}
@@ -347,9 +347,9 @@ class GadgetService extends IGadgetService.Stub
}
}
- public RemoteViews getGadgetViews(int gadgetId) {
- synchronized (mGadgetIds) {
- GadgetId id = lookupGadgetIdLocked(gadgetId);
+ public RemoteViews getAppWidgetViews(int appWidgetId) {
+ synchronized (mAppWidgetIds) {
+ AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
if (id != null) {
return id.views;
}
@@ -357,10 +357,10 @@ class GadgetService extends IGadgetService.Stub
}
}
- public List<GadgetProviderInfo> getInstalledProviders() {
- synchronized (mGadgetIds) {
+ public List<AppWidgetProviderInfo> getInstalledProviders() {
+ synchronized (mAppWidgetIds) {
final int N = mInstalledProviders.size();
- ArrayList<GadgetProviderInfo> result = new ArrayList(N);
+ ArrayList<AppWidgetProviderInfo> result = new ArrayList(N);
for (int i=0; i<N; i++) {
Provider p = mInstalledProviders.get(i);
if (!p.zombie) {
@@ -371,43 +371,43 @@ class GadgetService extends IGadgetService.Stub
}
}
- public void updateGadgetIds(int[] gadgetIds, RemoteViews views) {
- if (gadgetIds == null) {
+ public void updateAppWidgetIds(int[] appWidgetIds, RemoteViews views) {
+ if (appWidgetIds == null) {
return;
}
- if (gadgetIds.length == 0) {
+ if (appWidgetIds.length == 0) {
return;
}
- final int N = gadgetIds.length;
+ final int N = appWidgetIds.length;
- synchronized (mGadgetIds) {
+ synchronized (mAppWidgetIds) {
for (int i=0; i<N; i++) {
- GadgetId id = lookupGadgetIdLocked(gadgetIds[i]);
- updateGadgetInstanceLocked(id, views);
+ AppWidgetId id = lookupAppWidgetIdLocked(appWidgetIds[i]);
+ updateAppWidgetInstanceLocked(id, views);
}
}
}
- public void updateGadgetProvider(ComponentName provider, RemoteViews views) {
- synchronized (mGadgetIds) {
+ public void updateAppWidgetProvider(ComponentName provider, RemoteViews views) {
+ synchronized (mAppWidgetIds) {
Provider p = lookupProviderLocked(provider);
if (p == null) {
- Log.w(TAG, "updateGadget: provider doesn't exist: " + provider);
+ Log.w(TAG, "updateAppWidgetProvider: provider doesn't exist: " + provider);
return;
}
- ArrayList<GadgetId> instances = p.instances;
+ ArrayList<AppWidgetId> instances = p.instances;
final int N = instances.size();
for (int i=0; i<N; i++) {
- GadgetId id = instances.get(i);
- updateGadgetInstanceLocked(id, views);
+ AppWidgetId id = instances.get(i);
+ updateAppWidgetInstanceLocked(id, views);
}
}
}
- void updateGadgetInstanceLocked(GadgetId id, RemoteViews views) {
- // allow for stale gadgetIds and other badness
- // lookup also checks that the calling process can access the gadget id
- // drop unbound gadget ids (shouldn't be possible under normal circumstances)
+ void updateAppWidgetInstanceLocked(AppWidgetId id, RemoteViews views) {
+ // allow for stale appWidgetIds and other badness
+ // lookup also checks that the calling process can access the appWidgetId
+ // drop unbound appWidgetIds (shouldn't be possible under normal circumstances)
if (id != null && id.provider != null && !id.provider.zombie && !id.host.zombie) {
id.views = views;
@@ -415,7 +415,7 @@ class GadgetService extends IGadgetService.Stub
if (id.host.callbacks != null) {
try {
// the lock is held, but this is a oneway call
- id.host.callbacks.updateGadget(id.gadgetId, views);
+ id.host.callbacks.updateAppWidget(id.appWidgetId, views);
} catch (RemoteException e) {
// It failed; remove the callback. No need to prune because
// we know that this host is still referenced by this instance.
@@ -425,21 +425,21 @@ class GadgetService extends IGadgetService.Stub
}
}
- public int[] startListening(IGadgetHost callbacks, String packageName, int hostId,
+ public int[] startListening(IAppWidgetHost callbacks, String packageName, int hostId,
List<RemoteViews> updatedViews) {
int callingUid = enforceCallingUid(packageName);
- synchronized (mGadgetIds) {
+ synchronized (mAppWidgetIds) {
Host host = lookupOrAddHostLocked(callingUid, packageName, hostId);
host.callbacks = callbacks;
updatedViews.clear();
- ArrayList<GadgetId> instances = host.instances;
+ ArrayList<AppWidgetId> instances = host.instances;
int N = instances.size();
int[] updatedIds = new int[N];
for (int i=0; i<N; i++) {
- GadgetId id = instances.get(i);
- updatedIds[i] = id.gadgetId;
+ AppWidgetId id = instances.get(i);
+ updatedIds[i] = id.appWidgetId;
updatedViews.add(id.views);
}
return updatedIds;
@@ -447,37 +447,37 @@ class GadgetService extends IGadgetService.Stub
}
public void stopListening(int hostId) {
- synchronized (mGadgetIds) {
+ synchronized (mAppWidgetIds) {
Host host = lookupHostLocked(getCallingUid(), hostId);
host.callbacks = null;
pruneHostLocked(host);
}
}
- boolean canAccessGadgetId(GadgetId id, int callingUid) {
+ boolean canAccessAppWidgetId(AppWidgetId id, int callingUid) {
if (id.host.uid == callingUid) {
- // Apps hosting the gadget have access to it.
+ // Apps hosting the AppWidget have access to it.
return true;
}
if (id.provider != null && id.provider.uid == callingUid) {
- // Apps providing the gadget have access to it (if the gadgetId has been bound)
+ // Apps providing the AppWidget have access to it (if the appWidgetId has been bound)
return true;
}
- if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.BIND_GADGET)
+ if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.BIND_APPWIDGET)
== PackageManager.PERMISSION_GRANTED) {
- // Apps that can bind have access to all gadgetIds.
+ // Apps that can bind have access to all appWidgetIds.
return true;
}
// Nobody else can access it.
return false;
}
- GadgetId lookupGadgetIdLocked(int gadgetId) {
+ AppWidgetId lookupAppWidgetIdLocked(int appWidgetId) {
int callingUid = getCallingUid();
- final int N = mGadgetIds.size();
+ final int N = mAppWidgetIds.size();
for (int i=0; i<N; i++) {
- GadgetId id = mGadgetIds.get(i);
- if (id.gadgetId == gadgetId && canAccessGadgetId(id, callingUid)) {
+ AppWidgetId id = mAppWidgetIds.get(i);
+ if (id.appWidgetId == appWidgetId && canAccessAppWidgetId(id, callingUid)) {
return id;
}
}
@@ -528,10 +528,10 @@ class GadgetService extends IGadgetService.Stub
}
}
- void loadGadgetList() {
+ void loadAppWidgetList() {
PackageManager pm = mPackageManager;
- Intent intent = new Intent(GadgetManager.ACTION_GADGET_UPDATE);
+ Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
List<ResolveInfo> broadcastReceivers = pm.queryBroadcastReceivers(intent,
PackageManager.GET_META_DATA);
@@ -556,14 +556,14 @@ class GadgetService extends IGadgetService.Stub
void removeProviderLocked(int index, Provider p) {
int N = p.instances.size();
for (int i=0; i<N; i++) {
- GadgetId id = p.instances.get(i);
+ AppWidgetId id = p.instances.get(i);
// Call back with empty RemoteViews
- updateGadgetInstanceLocked(id, null);
+ updateAppWidgetInstanceLocked(id, null);
// Stop telling the host about updates for this from now on
cancelBroadcasts(p);
- // clear out references to this gadgetID
+ // clear out references to this appWidgetId
id.host.instances.remove(id);
- mGadgetIds.remove(id);
+ mAppWidgetIds.remove(id);
id.provider = null;
pruneHostLocked(id.host);
id.host = null;
@@ -575,29 +575,29 @@ class GadgetService extends IGadgetService.Stub
}
void sendEnableIntentLocked(Provider p) {
- Intent intent = new Intent(GadgetManager.ACTION_GADGET_ENABLED);
+ Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_ENABLED);
intent.setComponent(p.info.provider);
mContext.sendBroadcast(intent);
}
- void sendUpdateIntentLocked(Provider p, int[] gadgetIds) {
- if (gadgetIds != null && gadgetIds.length > 0) {
- Intent intent = new Intent(GadgetManager.ACTION_GADGET_UPDATE);
- intent.putExtra(GadgetManager.EXTRA_GADGET_IDS, gadgetIds);
+ void sendUpdateIntentLocked(Provider p, int[] appWidgetIds) {
+ if (appWidgetIds != null && appWidgetIds.length > 0) {
+ Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
intent.setComponent(p.info.provider);
mContext.sendBroadcast(intent);
}
}
- void registerForBroadcastsLocked(Provider p, int[] gadgetIds) {
+ void registerForBroadcastsLocked(Provider p, int[] appWidgetIds) {
if (p.info.updatePeriodMillis > 0) {
// if this is the first instance, set the alarm. otherwise,
// rely on the fact that we've already set it and that
// PendingIntent.getBroadcast will update the extras.
boolean alreadyRegistered = p.broadcast != null;
int instancesSize = p.instances.size();
- Intent intent = new Intent(GadgetManager.ACTION_GADGET_UPDATE);
- intent.putExtra(GadgetManager.EXTRA_GADGET_IDS, gadgetIds);
+ Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
intent.setComponent(p.info.provider);
long token = Binder.clearCallingIdentity();
try {
@@ -614,20 +614,20 @@ class GadgetService extends IGadgetService.Stub
}
}
- static int[] getGadgetIds(Provider p) {
+ static int[] getAppWidgetIds(Provider p) {
int instancesSize = p.instances.size();
- int gadgetIds[] = new int[instancesSize];
+ int appWidgetIds[] = new int[instancesSize];
for (int i=0; i<instancesSize; i++) {
- gadgetIds[i] = p.instances.get(i).gadgetId;
+ appWidgetIds[i] = p.instances.get(i).appWidgetId;
}
- return gadgetIds;
+ return appWidgetIds;
}
- public int[] getGadgetIds(ComponentName provider) {
- synchronized (mGadgetIds) {
+ public int[] getAppWidgetIds(ComponentName provider) {
+ synchronized (mAppWidgetIds) {
Provider p = lookupProviderLocked(provider);
if (p != null && getCallingUid() == p.uid) {
- return getGadgetIds(p);
+ return getAppWidgetIds(p);
} else {
return new int[0];
}
@@ -641,10 +641,10 @@ class GadgetService extends IGadgetService.Stub
XmlResourceParser parser = null;
try {
parser = activityInfo.loadXmlMetaData(mPackageManager,
- GadgetManager.META_DATA_GADGET_PROVIDER);
+ AppWidgetManager.META_DATA_APPWIDGET_PROVIDER);
if (parser == null) {
- Log.w(TAG, "No " + GadgetManager.META_DATA_GADGET_PROVIDER + " meta-data for "
- + "gadget provider '" + component + '\'');
+ Log.w(TAG, "No " + AppWidgetManager.META_DATA_APPWIDGET_PROVIDER + " meta-data for "
+ + "AppWidget provider '" + component + '\'');
return null;
}
@@ -657,30 +657,30 @@ class GadgetService extends IGadgetService.Stub
}
String nodeName = parser.getName();
- if (!"gadget-provider".equals(nodeName)) {
- Log.w(TAG, "Meta-data does not start with gadget-provider tag for"
- + " gadget provider '" + component + '\'');
+ if (!"appwidget-provider".equals(nodeName)) {
+ Log.w(TAG, "Meta-data does not start with appwidget-provider tag for"
+ + " AppWidget provider '" + component + '\'');
return null;
}
p = new Provider();
- GadgetProviderInfo info = p.info = new GadgetProviderInfo();
+ AppWidgetProviderInfo info = p.info = new AppWidgetProviderInfo();
info.provider = component;
p.uid = activityInfo.applicationInfo.uid;
TypedArray sa = mContext.getResources().obtainAttributes(attrs,
- com.android.internal.R.styleable.GadgetProviderInfo);
+ com.android.internal.R.styleable.AppWidgetProviderInfo);
info.minWidth = sa.getDimensionPixelSize(
- com.android.internal.R.styleable.GadgetProviderInfo_minWidth, 0);
+ com.android.internal.R.styleable.AppWidgetProviderInfo_minWidth, 0);
info.minHeight = sa.getDimensionPixelSize(
- com.android.internal.R.styleable.GadgetProviderInfo_minHeight, 0);
+ com.android.internal.R.styleable.AppWidgetProviderInfo_minHeight, 0);
info.updatePeriodMillis = sa.getInt(
- com.android.internal.R.styleable.GadgetProviderInfo_updatePeriodMillis, 0);
+ com.android.internal.R.styleable.AppWidgetProviderInfo_updatePeriodMillis, 0);
info.initialLayout = sa.getResourceId(
- com.android.internal.R.styleable.GadgetProviderInfo_initialLayout, 0);
+ com.android.internal.R.styleable.AppWidgetProviderInfo_initialLayout, 0);
String className = sa.getString(
- com.android.internal.R.styleable.GadgetProviderInfo_configure);
+ com.android.internal.R.styleable.AppWidgetProviderInfo_configure);
if (className != null) {
info.configure = new ComponentName(component.getPackageName(), className);
}
@@ -691,7 +691,7 @@ class GadgetService extends IGadgetService.Stub
// Ok to catch Exception here, because anything going wrong because
// of what a client process passes to us should not be fatal for the
// system process.
- Log.w(TAG, "XML parsing failed for gadget provider '" + component + '\'', e);
+ Log.w(TAG, "XML parsing failed for AppWidget provider '" + component + '\'', e);
return null;
} finally {
if (parser != null) parser.close();
@@ -724,15 +724,15 @@ class GadgetService extends IGadgetService.Stub
}
void sendInitialBroadcasts() {
- synchronized (mGadgetIds) {
+ synchronized (mAppWidgetIds) {
final int N = mInstalledProviders.size();
for (int i=0; i<N; i++) {
Provider p = mInstalledProviders.get(i);
if (p.instances.size() > 0) {
sendEnableIntentLocked(p);
- int[] gadgetIds = getGadgetIds(p);
- sendUpdateIntentLocked(p, gadgetIds);
- registerForBroadcastsLocked(p, gadgetIds);
+ int[] appWidgetIds = getAppWidgetIds(p);
+ sendUpdateIntentLocked(p, appWidgetIds);
+ registerForBroadcastsLocked(p, appWidgetIds);
}
}
}
@@ -820,11 +820,11 @@ class GadgetService extends IGadgetService.Stub
host.tag = i;
}
- N = mGadgetIds.size();
+ N = mAppWidgetIds.size();
for (int i=0; i<N; i++) {
- GadgetId id = mGadgetIds.get(i);
+ AppWidgetId id = mAppWidgetIds.get(i);
out.startTag(null, "g");
- out.attribute(null, "id", Integer.toHexString(id.gadgetId));
+ out.attribute(null, "id", Integer.toHexString(id.appWidgetId));
out.attribute(null, "h", Integer.toHexString(id.host.tag));
if (id.provider != null) {
out.attribute(null, "p", Integer.toHexString(id.provider.tag));
@@ -875,7 +875,7 @@ class GadgetService extends IGadgetService.Stub
if (p == null && mSafeMode) {
// if we're in safe mode, make a temporary one
p = new Provider();
- p.info = new GadgetProviderInfo();
+ p.info = new AppWidgetProviderInfo();
p.info.provider = new ComponentName(pkg, cl);
p.zombie = true;
mInstalledProviders.add(p);
@@ -906,10 +906,10 @@ class GadgetService extends IGadgetService.Stub
}
}
else if ("g".equals(tag)) {
- GadgetId id = new GadgetId();
- id.gadgetId = Integer.parseInt(parser.getAttributeValue(null, "id"), 16);
- if (id.gadgetId >= mNextGadgetId) {
- mNextGadgetId = id.gadgetId + 1;
+ AppWidgetId id = new AppWidgetId();
+ id.appWidgetId = Integer.parseInt(parser.getAttributeValue(null, "id"), 16);
+ if (id.appWidgetId >= mNextAppWidgetId) {
+ mNextAppWidgetId = id.appWidgetId + 1;
}
String providerString = parser.getAttributeValue(null, "p");
@@ -920,7 +920,7 @@ class GadgetService extends IGadgetService.Stub
int pIndex = Integer.parseInt(providerString, 16);
id.provider = loadedProviders.get(pIndex);
if (false) {
- Log.d(TAG, "bound gadgetId=" + id.gadgetId + " to provider "
+ Log.d(TAG, "bound appWidgetId=" + id.appWidgetId + " to provider "
+ pIndex + " which is " + id.provider);
}
if (id.provider == null) {
@@ -941,7 +941,7 @@ class GadgetService extends IGadgetService.Stub
id.provider.instances.add(id);
}
id.host.instances.add(id);
- mGadgetIds.add(id);
+ mAppWidgetIds.add(id);
}
}
} while (type != XmlPullParser.END_DOCUMENT);
@@ -973,7 +973,7 @@ class GadgetService extends IGadgetService.Stub
}
} else {
// failed reading, clean up
- mGadgetIds.clear();
+ mAppWidgetIds.clear();
mHosts.clear();
final int N = mInstalledProviders.size();
for (int i=0; i<N; i++) {
@@ -1009,7 +1009,7 @@ class GadgetService extends IGadgetService.Stub
}
if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
- synchronized (mGadgetIds) {
+ synchronized (mAppWidgetIds) {
Bundle extras = intent.getExtras();
if (extras != null && extras.getBoolean(Intent.EXTRA_REPLACING, false)) {
// The package was just upgraded
@@ -1026,7 +1026,7 @@ class GadgetService extends IGadgetService.Stub
if (extras != null && extras.getBoolean(Intent.EXTRA_REPLACING, false)) {
// The package is being updated. We'll receive a PACKAGE_ADDED shortly.
} else {
- synchronized (mGadgetIds) {
+ synchronized (mAppWidgetIds) {
removeProvidersForPackageLocked(pkgName);
saveStateLocked();
}
@@ -1039,7 +1039,7 @@ class GadgetService extends IGadgetService.Stub
// TODO: If there's a better way of matching an intent filter against the
// packages for a given package, use that.
void addProvidersForPackageLocked(String pkgName) {
- Intent intent = new Intent(GadgetManager.ACTION_GADGET_UPDATE);
+ Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
List<ResolveInfo> broadcastReceivers = mPackageManager.queryBroadcastReceivers(intent,
PackageManager.GET_META_DATA);
@@ -1058,7 +1058,7 @@ class GadgetService extends IGadgetService.Stub
// packages for a given package, use that.
void updateProvidersForPackageLocked(String pkgName) {
HashSet<String> keep = new HashSet();
- Intent intent = new Intent(GadgetManager.ACTION_GADGET_UPDATE);
+ Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
List<ResolveInfo> broadcastReceivers = mPackageManager.queryBroadcastReceivers(intent,
PackageManager.GET_META_DATA);
@@ -1078,24 +1078,24 @@ class GadgetService extends IGadgetService.Stub
Provider parsed = parseProviderInfoXml(component, ri);
if (parsed != null) {
keep.add(ai.name);
- // Use the new GadgetProviderInfo.
- GadgetProviderInfo oldInfo = p.info;
+ // Use the new AppWidgetProviderInfo.
+ AppWidgetProviderInfo oldInfo = p.info;
p.info = parsed.info;
// If it's enabled
final int M = p.instances.size();
if (M > 0) {
- int[] gadgetIds = getGadgetIds(p);
+ int[] appWidgetIds = getAppWidgetIds(p);
// Reschedule for the new updatePeriodMillis (don't worry about handling
// it specially if updatePeriodMillis didn't change because we just sent
// an update, and the next one will be updatePeriodMillis from now).
cancelBroadcasts(p);
- registerForBroadcastsLocked(p, gadgetIds);
- // If it's currently showing, call back with the new GadgetProviderInfo.
+ registerForBroadcastsLocked(p, appWidgetIds);
+ // If it's currently showing, call back with the new AppWidgetProviderInfo.
for (int j=0; j<M; j++) {
- GadgetId id = p.instances.get(j);
+ AppWidgetId id = p.instances.get(j);
if (id.host != null && id.host.callbacks != null) {
try {
- id.host.callbacks.providerChanged(id.gadgetId, p.info);
+ id.host.callbacks.providerChanged(id.appWidgetId, p.info);
} catch (RemoteException ex) {
// It failed; remove the callback. No need to prune because
// we know that this host is still referenced by this
@@ -1105,7 +1105,7 @@ class GadgetService extends IGadgetService.Stub
}
}
// Now that we've told the host, push out an update.
- sendUpdateIntentLocked(p, gadgetIds);
+ sendUpdateIntentLocked(p, appWidgetIds);
}
}
}
@@ -1134,7 +1134,7 @@ class GadgetService extends IGadgetService.Stub
// Delete the hosts for this package too
//
- // By now, we have removed any gadgets that were in any hosts here,
+ // By now, we have removed any AppWidgets that were in any hosts here,
// so we don't need to worry about sending DISABLE broadcasts to them.
N = mHosts.size();
for (int i=N-1; i>=0; i--) {
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 77383bd..a629ec6 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -181,7 +181,7 @@ class ServerThread extends Thread {
StatusBarService statusBar = null;
InputMethodManagerService imm = null;
- GadgetService gadget = null;
+ AppWidgetService appWidget = null;
if (factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
try {
@@ -308,11 +308,11 @@ class ServerThread extends Thread {
}
try {
- Log.i(TAG, "Starting Gadget Service");
- gadget = new GadgetService(context);
- ServiceManager.addService(Context.GADGET_SERVICE, gadget);
+ Log.i(TAG, "Starting AppWidget Service");
+ appWidget = new AppWidgetService(context);
+ ServiceManager.addService(Context.APPWIDGET_SERVICE, appWidget);
} catch (Throwable e) {
- Log.e(TAG, "Failure starting Gadget Service", e);
+ Log.e(TAG, "Failure starting AppWidget Service", e);
}
try {
@@ -344,8 +344,8 @@ class ServerThread extends Thread {
pm.systemReady();
} catch (RemoteException e) {
}
- if (gadget != null) {
- gadget.systemReady(safeMode);
+ if (appWidget != null) {
+ appWidget.systemReady(safeMode);
}
// After making the following code, third party code may be running...
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index cb16c98..e4bd3c3 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -1373,10 +1373,9 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
removeWindowInnerLocked(session, win);
// Removing a visible window will effect the computed orientation
// So just update orientation if needed.
- if (wasVisible) {
- if (updateOrientationFromAppTokens(null) != null) {
- sendNewConfiguration();
- }
+ if (wasVisible && computeForcedAppOrientationLocked()
+ != mForcedAppOrientation) {
+ mH.sendMessage(mH.obtainMessage(H.COMPUTE_AND_SEND_NEW_CONFIGURATION));
}
updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL);
Binder.restoreCallingIdentity(origId);
@@ -2141,23 +2140,19 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
* @see android.view.IWindowManager#updateOrientationFromAppTokens(
* android.os.IBinder)
*/
- public Configuration updateOrientationFromAppTokensLocked(
+ Configuration updateOrientationFromAppTokensLocked(
IBinder freezeThisOneIfNeeded) {
boolean changed = false;
- Configuration config = null;
long ident = Binder.clearCallingIdentity();
try {
- int req = getOrientationFromWindowsLocked();
- if (req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
- req = getOrientationFromAppTokensLocked();
- }
+ int req = computeForcedAppOrientationLocked();
if (req != mForcedAppOrientation) {
changed = true;
mForcedAppOrientation = req;
//send a message to Policy indicating orientation change to take
//action like disabling/enabling sensors etc.,
- mPolicy.setCurrentOrientation(req);
+ mPolicy.setCurrentOrientationLw(req);
}
if (changed) {
@@ -2182,6 +2177,14 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
return null;
}
+ int computeForcedAppOrientationLocked() {
+ int req = getOrientationFromWindowsLocked();
+ if (req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
+ req = getOrientationFromAppTokensLocked();
+ }
+ return req;
+ }
+
public void setAppOrientation(IApplicationToken token, int requestedOrientation) {
if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
"setAppOrientation()")) {
@@ -3284,7 +3287,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
mRequestedRotation = rotation;
}
if (DEBUG_ORIENTATION) Log.v(TAG, "Overwriting rotation value from " + rotation);
- rotation = mPolicy.rotationForOrientation(mForcedAppOrientation,
+ rotation = mPolicy.rotationForOrientationLw(mForcedAppOrientation,
mRotation, mDisplayEnabled);
if (DEBUG_ORIENTATION) Log.v(TAG, "new rotation is set to " + rotation);
changed = mDisplayEnabled && mRotation != rotation;
@@ -4960,7 +4963,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
if (holding) {
mHoldingScreen.acquire();
} else {
- mPolicy.screenOnStopped();
+ mPolicy.screenOnStoppedLw();
mHoldingScreen.release();
}
}
@@ -5290,7 +5293,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
synchronized(mWindowMap) {
long ident = Binder.clearCallingIdentity();
try {
- return mPolicy.performHapticFeedback(
+ return mPolicy.performHapticFeedbackLw(
windowForClientLocked(this, window), effectId, always);
} finally {
Binder.restoreCallingIdentity(ident);
@@ -6944,6 +6947,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
public static final int FORCE_GC = 15;
public static final int ENABLE_SCREEN = 16;
public static final int APP_FREEZE_TIMEOUT = 17;
+ public static final int COMPUTE_AND_SEND_NEW_CONFIGURATION = 18;
private Session mLastReportedHold;
@@ -7274,6 +7278,13 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
break;
}
+ case COMPUTE_AND_SEND_NEW_CONFIGURATION: {
+ if (updateOrientationFromAppTokens(null) != null) {
+ sendNewConfiguration();
+ }
+ break;
+ }
+
}
}
}