Fix 2223769 - Uninstalling a widget (via adb uninstall) crashed launcher2 and com.cooliris.media
If we haven't even initialized yet, don't respond to app list changes.
I think this will fix that bug. It's possible that there's some other race in there somehow.
diff --git a/src/com/android/launcher2/LauncherApplication.java b/src/com/android/launcher2/LauncherApplication.java
index ee6006c..9b63524 100644
--- a/src/com/android/launcher2/LauncherApplication.java
+++ b/src/com/android/launcher2/LauncherApplication.java
@@ -17,7 +17,6 @@
package com.android.launcher2;
import android.app.Application;
-import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -27,7 +26,11 @@
import dalvik.system.VMRuntime;
public class LauncherApplication extends Application {
- public static final LauncherModel sModel = new LauncherModel();
+ public final LauncherModel mModel;
+
+ public LauncherApplication() {
+ mModel = new LauncherModel(this);
+ }
@Override
public void onCreate() {
@@ -40,7 +43,7 @@
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addDataScheme("package");
- registerReceiver(mApplicationsReceiver, filter);
+ registerReceiver(mModel, filter);
// Register for changes to the favorites
ContentResolver resolver = getContentResolver();
@@ -55,36 +58,26 @@
public void onTerminate() {
super.onTerminate();
- unregisterReceiver(mApplicationsReceiver);
+ unregisterReceiver(mModel);
ContentResolver resolver = getContentResolver();
resolver.unregisterContentObserver(mFavoritesObserver);
}
/**
- * Receives notifications when applications are added/removed.
- */
- private final BroadcastReceiver mApplicationsReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- sModel.onReceiveIntent(LauncherApplication.this, intent);
- }
- };
-
- /**
* Receives notifications whenever the user favorites have changed.
*/
private final ContentObserver mFavoritesObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
// TODO: lockAllApps();
- sModel.setWorkspaceDirty();
- sModel.startLoader(LauncherApplication.this, false);
+ mModel.setWorkspaceDirty();
+ mModel.startLoader(LauncherApplication.this, false);
}
};
LauncherModel setLauncher(Launcher launcher) {
- sModel.initialize(launcher);
- return sModel;
+ mModel.initialize(launcher);
+ return mModel;
}
}