SetupWizard: Fix race condition on finish
Change-Id: Ie4a5893c49db7ce9622091e05776cb5523ed5c45
This commit is contained in:
parent
226687c0b2
commit
7c8e091320
@ -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,7 +291,21 @@ 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() {
|
||||
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) {
|
||||
@ -301,33 +314,12 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish(boolean isSuccess) {
|
||||
finishSetup();
|
||||
}
|
||||
};
|
||||
tm.addClient(mThemeChangeListener);
|
||||
mSetupData.finishPages();
|
||||
SetupStats.addEvent(SetupStats.Categories.APP_FINISHED, TAG,
|
||||
SetupStats.Label.TOTAL_TIME, String.valueOf(
|
||||
System.nanoTime() - sLaunchTime));
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -342,9 +334,6 @@ 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 =
|
||||
@ -357,25 +346,15 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
|
||||
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) {
|
||||
if (cropped != null) {
|
||||
mReveal.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
mReveal.setImageBitmap(croppedWallpaper);
|
||||
mReveal.setImageBitmap(cropped);
|
||||
} else {
|
||||
mReveal.setBackground(wallpaperManager
|
||||
.getBuiltInDrawable(p.x, p.y, false, 0, 0));
|
||||
}
|
||||
animateOut();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
}
|
||||
|
||||
private void animateOut() {
|
||||
int cx = (mReveal.getLeft() + mReveal.getRight()) / 2;
|
||||
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user