Cleanup a bunch of warnings in app widgets code.

This commit is contained in:
Romain Guy
2009-07-01 17:20:08 -07:00
parent 392282f1e0
commit a54755962c
4 changed files with 55 additions and 61 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;
@@ -57,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;
@@ -80,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
@@ -91,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
@@ -108,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) {
@@ -175,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('/');
@@ -385,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) {
@@ -620,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);
@@ -780,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);
}
}
@@ -799,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);
}
@@ -873,8 +877,10 @@ class AppWidgetService extends IAppWidgetService.Stub
stream.close();
}
} catch (IOException ex) {
// Ignore
}
if (file.exists()) {
//noinspection ResultOfMethodCallIgnored
file.delete();
}
}
@@ -892,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) {
@@ -993,6 +999,7 @@ class AppWidgetService extends IAppWidgetService.Stub
stream.close();
}
} catch (IOException e) {
// Ignore
}
if (success) {
@@ -1088,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);
@@ -1110,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();