donut snapshot

This commit is contained in:
Jean-Baptiste Queru
2009-07-21 11:16:54 -07:00
parent 4cf03d381b
commit cf4550c319
1032 changed files with 81415 additions and 15221 deletions

View File

@@ -29,7 +29,6 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.PackageItemInfo;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.net.Uri;
@@ -40,6 +39,7 @@ import android.os.RemoteException;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.util.Xml;
import android.widget.RemoteViews;
@@ -56,7 +56,6 @@ import java.util.HashSet;
import com.android.internal.appwidget.IAppWidgetService;
import com.android.internal.appwidget.IAppWidgetHost;
import com.android.internal.util.XmlUtils;
import com.android.internal.util.FastXmlSerializer;
import org.xmlpull.v1.XmlPullParser;
@@ -79,7 +78,7 @@ class AppWidgetService extends IAppWidgetService.Stub
static class Provider {
int uid;
AppWidgetProviderInfo info;
ArrayList<AppWidgetId> instances = new ArrayList();
ArrayList<AppWidgetId> instances = new ArrayList<AppWidgetId>();
PendingIntent broadcast;
boolean zombie; // if we're in safe mode, don't prune this just because nobody references it
@@ -90,7 +89,7 @@ class AppWidgetService extends IAppWidgetService.Stub
int uid;
int hostId;
String packageName;
ArrayList<AppWidgetId> instances = new ArrayList();
ArrayList<AppWidgetId> instances = new ArrayList<AppWidgetId>();
IAppWidgetHost callbacks;
boolean zombie; // if we're in safe mode, don't prune this just because nobody references it
@@ -107,10 +106,10 @@ class AppWidgetService extends IAppWidgetService.Stub
Context mContext;
PackageManager mPackageManager;
AlarmManager mAlarmManager;
ArrayList<Provider> mInstalledProviders = new ArrayList();
ArrayList<Provider> mInstalledProviders = new ArrayList<Provider>();
int mNextAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID + 1;
ArrayList<AppWidgetId> mAppWidgetIds = new ArrayList();
ArrayList<Host> mHosts = new ArrayList();
final ArrayList<AppWidgetId> mAppWidgetIds = new ArrayList<AppWidgetId>();
ArrayList<Host> mHosts = new ArrayList<Host>();
boolean mSafeMode;
AppWidgetService(Context context) {
@@ -174,7 +173,7 @@ class AppWidgetService extends IAppWidgetService.Stub
for (int i=0; i<N; i++) {
AppWidgetId id = mAppWidgetIds.get(i);
pw.print(" ["); pw.print(i); pw.print("] id=");
pw.println(id.appWidgetId);;
pw.println(id.appWidgetId);
pw.print(" hostId=");
pw.print(id.host.hostId); pw.print(' ');
pw.print(id.host.packageName); pw.print('/');
@@ -384,7 +383,7 @@ class AppWidgetService extends IAppWidgetService.Stub
public List<AppWidgetProviderInfo> getInstalledProviders() {
synchronized (mAppWidgetIds) {
final int N = mInstalledProviders.size();
ArrayList<AppWidgetProviderInfo> result = new ArrayList(N);
ArrayList<AppWidgetProviderInfo> result = new ArrayList<AppWidgetProviderInfo>(N);
for (int i=0; i<N; i++) {
Provider p = mInstalledProviders.get(i);
if (!p.zombie) {
@@ -619,7 +618,6 @@ class AppWidgetService extends IAppWidgetService.Stub
// 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(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
intent.setComponent(p.info.provider);
@@ -695,10 +693,16 @@ class AppWidgetService extends IAppWidgetService.Stub
TypedArray sa = mContext.getResources().obtainAttributes(attrs,
com.android.internal.R.styleable.AppWidgetProviderInfo);
info.minWidth = sa.getDimensionPixelSize(
com.android.internal.R.styleable.AppWidgetProviderInfo_minWidth, 0);
info.minHeight = sa.getDimensionPixelSize(
com.android.internal.R.styleable.AppWidgetProviderInfo_minHeight, 0);
// These dimensions has to be resolved in the application's context.
// We simply send back the raw complex data, which will be
// converted to dp in {@link AppWidgetManager#getAppWidgetInfo}.
TypedValue value = sa.peekValue(
com.android.internal.R.styleable.AppWidgetProviderInfo_minWidth);
info.minWidth = value != null ? value.data : 0;
value = sa.peekValue(com.android.internal.R.styleable.AppWidgetProviderInfo_minHeight);
info.minHeight = value != null ? value.data : 0;
info.updatePeriodMillis = sa.getInt(
com.android.internal.R.styleable.AppWidgetProviderInfo_updatePeriodMillis, 0);
info.initialLayout = sa.getResourceId(
@@ -773,10 +777,12 @@ class AppWidgetService extends IAppWidgetService.Stub
if (real.exists()) {
readStateFromFileLocked(real);
if (temp.exists()) {
//noinspection ResultOfMethodCallIgnored
temp.delete();
}
} else if (temp.exists()) {
readStateFromFileLocked(temp);
//noinspection ResultOfMethodCallIgnored
temp.renameTo(real);
}
}
@@ -792,18 +798,23 @@ class AppWidgetService extends IAppWidgetService.Stub
// use the temporary one until it's fully written, create an empty file
// for real, which will we'll shortly delete.
try {
//noinspection ResultOfMethodCallIgnored
real.createNewFile();
} catch (IOException e) {
// Ignore
}
}
if (temp.exists()) {
//noinspection ResultOfMethodCallIgnored
temp.delete();
}
writeStateToFileLocked(temp);
//noinspection ResultOfMethodCallIgnored
real.delete();
//noinspection ResultOfMethodCallIgnored
temp.renameTo(real);
}
@@ -866,8 +877,10 @@ class AppWidgetService extends IAppWidgetService.Stub
stream.close();
}
} catch (IOException ex) {
// Ignore
}
if (file.exists()) {
//noinspection ResultOfMethodCallIgnored
file.delete();
}
}
@@ -885,7 +898,7 @@ class AppWidgetService extends IAppWidgetService.Stub
int type;
int providerIndex = 0;
HashMap<Integer,Provider> loadedProviders = new HashMap();
HashMap<Integer,Provider> loadedProviders = new HashMap<Integer, Provider>();
do {
type = parser.next();
if (type == XmlPullParser.START_TAG) {
@@ -986,6 +999,7 @@ class AppWidgetService extends IAppWidgetService.Stub
stream.close();
}
} catch (IOException e) {
// Ignore
}
if (success) {
@@ -1081,7 +1095,7 @@ class AppWidgetService extends IAppWidgetService.Stub
// TODO: If there's a better way of matching an intent filter against the
// packages for a given package, use that.
void updateProvidersForPackageLocked(String pkgName) {
HashSet<String> keep = new HashSet();
HashSet<String> keep = new HashSet<String>();
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
List<ResolveInfo> broadcastReceivers = mPackageManager.queryBroadcastReceivers(intent,
PackageManager.GET_META_DATA);
@@ -1103,7 +1117,6 @@ class AppWidgetService extends IAppWidgetService.Stub
if (parsed != null) {
keep.add(ai.name);
// Use the new AppWidgetProviderInfo.
AppWidgetProviderInfo oldInfo = p.info;
p.info = parsed.info;
// If it's enabled
final int M = p.instances.size();