diff options
author | cretin45 <cretin45@gmail.com> | 2016-01-12 14:43:36 -0800 |
---|---|---|
committer | cretin45 <cretin45@gmail.com> | 2016-01-12 14:47:32 -0800 |
commit | 1141611f911f853da424d9b0d8ebbce8800aa2b4 (patch) | |
tree | 761e34f8dbf00a09c29c03d857827e3a09649483 /src | |
parent | 3e68503d9ef53e0d8f0e9c7631dc4cc29e5e38c5 (diff) | |
download | packages_apps_SetupWizard-1141611f911f853da424d9b0d8ebbce8800aa2b4.zip packages_apps_SetupWizard-1141611f911f853da424d9b0d8ebbce8800aa2b4.tar.gz packages_apps_SetupWizard-1141611f911f853da424d9b0d8ebbce8800aa2b4.tar.bz2 |
SetupWizard: Don't disable packages on main thread
Issue-id: YAM-69
Change-Id: I81ea039a7444d3db5d97b1d798bffe9a6b8ec498
Diffstat (limited to 'src')
-rw-r--r-- | src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java | 37 | ||||
-rw-r--r-- | src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java | 2 |
2 files changed, 31 insertions, 8 deletions
diff --git a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java index 77efb96..81121fa 100644 --- a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java +++ b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java @@ -26,6 +26,7 @@ import android.content.res.Resources; /*import android.content.res.ThemeManager;*/ import android.graphics.Bitmap; import android.graphics.Point; +import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.UserHandle; @@ -425,18 +426,40 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks tm.removeClient(SetupWizardActivity.this);*/ SetupStats.sendEvents(SetupWizardActivity.this); SetupWizardUtils.disableGMSSetupWizard(SetupWizardActivity.this); - Intent intent = new Intent(Intent.ACTION_MAIN); - intent.addCategory(Intent.CATEGORY_HOME); - startActivity(intent); final WallpaperManager wallpaperManager = WallpaperManager.getInstance(SetupWizardActivity.this); wallpaperManager.forgetLoadedWallpaper(); } }); - for (Runnable runnable : mFinishRunnables) { - runnable.run(); + new FinishTask(this, mFinishRunnables).execute(); + } + + private static class FinishTask extends AsyncTask<Void, Void, Boolean> { + + private final SetupWizardActivity mActivity; + private final ArrayList<Runnable> mFinishRunnables; + + public FinishTask(SetupWizardActivity activity, + ArrayList<Runnable> finishRunnables) { + mActivity = activity; + mFinishRunnables = finishRunnables; + } + + @Override + protected Boolean doInBackground(Void... params) { + for (Runnable runnable : mFinishRunnables) { + runnable.run(); + } + SetupWizardUtils.disableSetupWizard(mActivity); + return Boolean.TRUE; + } + + @Override + protected void onPostExecute(Boolean aBoolean) { + Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_HOME); + mActivity.startActivity(intent); + mActivity.finish(); } - finish(); - SetupWizardUtils.disableSetupWizard(SetupWizardActivity.this); } } diff --git a/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java b/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java index 4918b11..67671d3 100644 --- a/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java +++ b/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java @@ -261,7 +261,7 @@ public class SetupWizardUtils { private static void disableComponent(Context context, ComponentName component) { context.getPackageManager().setComponentEnabledSetting(component, - PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); + PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } private static void enableComponentArray(Context context, ComponentInfo[] components) { |