diff options
| author | 2015-12-03 10:51:58 -0500 | |
|---|---|---|
| committer | 2015-12-03 10:51:58 -0500 | |
| commit | 2a5d79aa6fd882ef6f46439f5156c516f173f06a (patch) | |
| tree | 74981ed55ac9adb2c09bb04ee2f0f0dc73454155 | |
| parent | 8f7f3184d55850b1c4d2036319794151f564e9c0 (diff) | |
Fix crashes in Settings + SUW
Bug: 25981625
Bug: 25989520
Bug: 25987331
Change-Id: Ib53c99edf45bb4550bfb9761ed09ca3677068591
| -rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java | 6 | ||||
| -rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java | 29 |
2 files changed, 22 insertions, 13 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java index c9a5f8f68606..e6fe447c8d98 100644 --- a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java +++ b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java @@ -116,7 +116,7 @@ public class ApplicationsState { final HandlerThread mThread; final BackgroundHandler mBackgroundHandler; - final MainHandler mMainHandler = new MainHandler(); + final MainHandler mMainHandler = new MainHandler(Looper.getMainLooper()); private ApplicationsState(Application app) { mContext = app; @@ -687,6 +687,10 @@ public class ApplicationsState { static final int MSG_LAUNCHER_INFO_CHANGED = 7; static final int MSG_LOAD_ENTRIES_COMPLETE = 8; + public MainHandler(Looper looper) { + super(looper); + } + @Override public void handleMessage(Message msg) { rebuildActiveSessions(); diff --git a/packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java b/packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java index 581c810c7444..102e47ab1870 100644 --- a/packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java +++ b/packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java @@ -77,10 +77,7 @@ public class SettingsDrawerActivity extends Activity { mDrawerLayout = null; return; } - if (sDashboardCategories == null) { - sTileCache = new HashMap<>(); - sDashboardCategories = TileUtils.getCategories(this, sTileCache); - } + getDashboardCategories(); setActionBar(toolbar); mDrawerAdapter = new SettingsDrawerAdapter(this); ListView listView = (ListView) findViewById(R.id.left_drawer); @@ -109,19 +106,23 @@ public class SettingsDrawerActivity extends Activity { protected void onResume() { super.onResume(); - final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); - filter.addAction(Intent.ACTION_PACKAGE_REMOVED); - filter.addAction(Intent.ACTION_PACKAGE_CHANGED); - filter.addAction(Intent.ACTION_PACKAGE_REPLACED); - filter.addDataScheme("package"); - registerReceiver(mPackageReceiver, filter); + if (mDrawerLayout != null) { + final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); + filter.addAction(Intent.ACTION_PACKAGE_REMOVED); + filter.addAction(Intent.ACTION_PACKAGE_CHANGED); + filter.addAction(Intent.ACTION_PACKAGE_REPLACED); + filter.addDataScheme("package"); + registerReceiver(mPackageReceiver, filter); - new CategoriesUpdater().execute(); + new CategoriesUpdater().execute(); + } } @Override protected void onPause() { - unregisterReceiver(mPackageReceiver); + if (mDrawerLayout != null) { + unregisterReceiver(mPackageReceiver); + } super.onPause(); } @@ -178,6 +179,10 @@ public class SettingsDrawerActivity extends Activity { } public List<DashboardCategory> getDashboardCategories() { + if (sDashboardCategories == null) { + sTileCache = new HashMap<>(); + sDashboardCategories = TileUtils.getCategories(this, sTileCache); + } return sDashboardCategories; } |