summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod/setupwizard/ui
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2015-03-06 14:01:53 -0800
committercretin45 <cretin45@gmail.com>2015-03-06 14:01:53 -0800
commit7c8e09132012cdf1d576f930b46b2f54c2f39102 (patch)
tree36ac675f9ac6f0ab1b8accb5cba66867ec544183 /src/com/cyanogenmod/setupwizard/ui
parent226687c0b2cb905ed6017632704ba29f9b76e208 (diff)
downloadpackages_apps_SetupWizard-7c8e09132012cdf1d576f930b46b2f54c2f39102.zip
packages_apps_SetupWizard-7c8e09132012cdf1d576f930b46b2f54c2f39102.tar.gz
packages_apps_SetupWizard-7c8e09132012cdf1d576f930b46b2f54c2f39102.tar.bz2
SetupWizard: Fix race condition on finish
Change-Id: Ie4a5893c49db7ce9622091e05776cb5523ed5c45
Diffstat (limited to 'src/com/cyanogenmod/setupwizard/ui')
-rw-r--r--src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java103
1 files changed, 41 insertions, 62 deletions
diff --git a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java
index 16fefc7..1ee4ebb 100644
--- a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java
+++ b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java
@@ -51,7 +51,8 @@ import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
import java.util.ArrayList;
-public class SetupWizardActivity extends Activity implements SetupDataCallbacks {
+public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
+ ThemeManager.ThemeChangeListener {
private static final String TAG = SetupWizardActivity.class.getSimpleName();
@@ -76,8 +77,6 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
private final ArrayList<Runnable> mFinishRunnables = new ArrayList<Runnable>();
- private ThemeManager.ThemeChangeListener mThemeChangeListener;
-
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (sLaunchTime == 0) {
@@ -292,41 +291,34 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
mFinishingProgressBar.setIndeterminate(true);
mFinishingProgressBar.startAnimation(fadeIn);
final ThemeManager tm = (ThemeManager) getSystemService(Context.THEME_SERVICE);
- mThemeChangeListener = new ThemeManager.ThemeChangeListener() {
- @Override
- public void onProgress(int progress) {
- if (progress > 0) {
- mFinishingProgressBar.setIndeterminate(false);
- mFinishingProgressBar.setProgress(progress);
- }
- }
-
- @Override
- public void onFinish(boolean isSuccess) {
- finishSetup();
- }
- };
- tm.addClient(mThemeChangeListener);
+ tm.addClient(this);
mSetupData.finishPages();
SetupStats.addEvent(SetupStats.Categories.APP_FINISHED, TAG,
SetupStats.Label.TOTAL_TIME, String.valueOf(
System.nanoTime() - sLaunchTime));
+ setupWizardApp.sendStickyBroadcastAsUser(
+ new Intent(SetupWizardApp.ACTION_FINISHED),
+ UserHandle.getCallingUserHandle());
+ }
+
+ @Override
+ public void onFinish(boolean isSuccess) {
+ finishSetup();
+ }
+
+ @Override
+ public void onProgress(int progress) {
+ if (progress > 0) {
+ mFinishingProgressBar.setIndeterminate(false);
+ mFinishingProgressBar.setProgress(progress);
+ }
}
@Override
public void finishSetup() {
if (!mIsFinishing) {
mIsFinishing = true;
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- final SetupWizardApp setupWizardApp = (SetupWizardApp)getApplication();
- setupWizardApp.sendStickyBroadcastAsUser(
- new Intent(SetupWizardApp.ACTION_FINISHED),
- UserHandle.getCallingUserHandle());
- setupRevealImage();
- }
- });
+ setupRevealImage();
}
}
@@ -342,39 +334,26 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
mFinishingProgressBar.startAnimation(fadeOut);
mFinishingProgressBar.setVisibility(View.INVISIBLE);
- final Thread t = new Thread() {
- @Override
- public void run() {
- final Point p = new Point();
- getWindowManager().getDefaultDisplay().getRealSize(p);
- final WallpaperManager wallpaperManager =
- WallpaperManager.getInstance(SetupWizardActivity.this);
- wallpaperManager.forgetLoadedWallpaper();
- final Bitmap wallpaper = wallpaperManager.getBitmap();
- Bitmap cropped = null;
- if (wallpaper != null) {
- cropped = Bitmap.createBitmap(wallpaper, 0,
- 0, Math.min(p.x, wallpaper.getWidth()),
- Math.min(p.y, wallpaper.getHeight()));
- }
- final Bitmap croppedWallpaper = cropped;
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- if (croppedWallpaper != null) {
- mReveal.setScaleType(ImageView.ScaleType.CENTER_CROP);
- mReveal.setImageBitmap(croppedWallpaper);
- } else {
- mReveal.setBackground(wallpaperManager
- .getBuiltInDrawable(p.x, p.y, false, 0, 0));
- }
- animateOut();
- }
- });
-
- }
- };
- t.start();
+ final Point p = new Point();
+ getWindowManager().getDefaultDisplay().getRealSize(p);
+ final WallpaperManager wallpaperManager =
+ WallpaperManager.getInstance(SetupWizardActivity.this);
+ wallpaperManager.forgetLoadedWallpaper();
+ final Bitmap wallpaper = wallpaperManager.getBitmap();
+ Bitmap cropped = null;
+ if (wallpaper != null) {
+ cropped = Bitmap.createBitmap(wallpaper, 0,
+ 0, Math.min(p.x, wallpaper.getWidth()),
+ Math.min(p.y, wallpaper.getHeight()));
+ }
+ if (cropped != null) {
+ mReveal.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ mReveal.setImageBitmap(cropped);
+ } else {
+ mReveal.setBackground(wallpaperManager
+ .getBuiltInDrawable(p.x, p.y, false, 0, 0));
+ }
+ animateOut();
}
private void animateOut() {
@@ -421,7 +400,7 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
}
final ThemeManager tm =
(ThemeManager) SetupWizardActivity.this.getSystemService(THEME_SERVICE);
- tm.removeClient(mThemeChangeListener);
+ tm.removeClient(SetupWizardActivity.this);
SetupStats.sendEvents(SetupWizardActivity.this);
SetupWizardUtils.disableGMSSetupWizard(SetupWizardActivity.this);
Intent intent = new Intent(Intent.ACTION_MAIN);