Tying LauncherAppState lifecycle with LauncherProvider

The content provider is the first component started with the main process,
which makes it ideal for initiating LauncherAppState

Change-Id: I03db82a8949ad1376af53a0033592f421dbf0b15
This commit is contained in:
Sunny Goyal
2015-11-24 11:40:40 -08:00
parent 4ee66259eb
commit 7bce5f7988
5 changed files with 5 additions and 6 deletions

View File

@@ -171,7 +171,6 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
private static void queuePendingShortcutInfo(PendingInstallShortcutInfo info, Context context) {
// Queue the item up for adding if launcher has not loaded properly yet
LauncherAppState.setApplicationContext(context.getApplicationContext());
LauncherAppState app = LauncherAppState.getInstance();
boolean launcherNotLoaded = app.getModel().getCallback() == null;

View File

@@ -417,7 +417,6 @@ public class Launcher extends Activity
super.onCreate(savedInstanceState);
LauncherAppState.setApplicationContext(getApplicationContext());
LauncherAppState app = LauncherAppState.getInstance();
// Load configuration-specific DeviceProfile

View File

@@ -84,6 +84,10 @@ public class LauncherProvider extends ContentProvider {
@Override
public boolean onCreate() {
final Context context = getContext();
// The content provider exists for the entire duration of the launcher main process and
// is the first component to get created. Initializing application context here ensures
// that LauncherAppState always exists in the main process.
LauncherAppState.setApplicationContext(context.getApplicationContext());
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
mOpenHelper = new DatabaseHelper(context);
StrictMode.setThreadPolicy(oldPolicy);

View File

@@ -22,8 +22,6 @@ import android.content.Intent;
public class WallpaperChangedReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent data) {
LauncherAppState.setApplicationContext(context.getApplicationContext());
LauncherAppState appState = LauncherAppState.getInstance();
appState.onWallpaperChanged();
LauncherAppState.getInstance().onWallpaperChanged();
}
}

View File

@@ -43,7 +43,6 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
PackageInstallerCompatVL(Context context) {
mInstaller = context.getPackageManager().getPackageInstaller();
LauncherAppState.setApplicationContext(context.getApplicationContext());
mCache = LauncherAppState.getInstance().getIconCache();
mWorker = new Handler(LauncherModel.getWorkerLooper());