Stop leaking wakelocks in cryptkeeper.

Also add in logging for certain events, as well as progress update to
help hunt down a stuck-in-progress bug

Bug: 5163155
Change-Id: I2e01a56b012f41f178beba0becfbe8173a1715ee
This commit is contained in:
Ben Komalo
2011-08-18 14:50:26 -07:00
parent 9403d8b239
commit 0460675b7c

View File

@@ -235,6 +235,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
if (lastInstance instanceof NonConfigurationInstanceState) { if (lastInstance instanceof NonConfigurationInstanceState) {
NonConfigurationInstanceState retained = (NonConfigurationInstanceState) lastInstance; NonConfigurationInstanceState retained = (NonConfigurationInstanceState) lastInstance;
mWakeLock = retained.wakelock; mWakeLock = retained.wakelock;
Log.d(TAG, "Restoring wakelock from NonConfigurationInstanceState");
} }
} }
@@ -276,6 +277,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
@Override @Override
public Object onRetainNonConfigurationInstance() { public Object onRetainNonConfigurationInstance() {
NonConfigurationInstanceState state = new NonConfigurationInstanceState(mWakeLock); NonConfigurationInstanceState state = new NonConfigurationInstanceState(mWakeLock);
Log.d(TAG, "Handing wakelock off to NonConfigurationInstanceState");
mWakeLock = null; mWakeLock = null;
return state; return state;
} }
@@ -285,6 +287,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
super.onDestroy(); super.onDestroy();
if (mWakeLock != null) { if (mWakeLock != null) {
Log.d(TAG, "Releasing and destroying wakelock");
mWakeLock.release(); mWakeLock.release();
mWakeLock = null; mWakeLock = null;
} }
@@ -295,10 +298,13 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
// we never release this wakelock as we will be restarted after the device // we never release this wakelock as we will be restarted after the device
// is encrypted. // is encrypted.
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); Log.d(TAG, "Encryption progress screen initializing.");
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG); if (mWakeLock != null) {
Log.d(TAG, "Acquiring wakelock.");
mWakeLock.acquire(); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG);
mWakeLock.acquire();
}
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar); ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
progressBar.setIndeterminate(true); progressBar.setIndeterminate(true);
@@ -349,6 +355,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
} }
CharSequence status = getText(R.string.crypt_keeper_setup_description); CharSequence status = getText(R.string.crypt_keeper_setup_description);
Log.v(TAG, "Encryption progress: " + progress);
TextView tv = (TextView) findViewById(R.id.status); TextView tv = (TextView) findViewById(R.id.status);
tv.setText(TextUtils.expandTemplate(status, Integer.toString(progress))); tv.setText(TextUtils.expandTemplate(status, Integer.toString(progress)));
@@ -418,6 +425,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
// cooldown period. // cooldown period.
mPasswordEntry.setEnabled(false); mPasswordEntry.setEnabled(false);
Log.d(TAG, "Attempting to send command to decrypt");
new DecryptTask().execute(password); new DecryptTask().execute(password);
return true; return true;