summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/CryptKeeper.java
diff options
context:
space:
mode:
authorPaul Lawrence <paullawrence@google.com>2014-06-05 07:24:23 -0700
committerPaul Lawrence <paullawrence@google.com>2014-06-05 20:15:37 +0000
commitb15c68fbf19c021eb0a3bed1ccc4dd7fda384ec7 (patch)
tree8eefd2fb547120cc7689de649ed82ceef33e0049 /src/com/android/settings/CryptKeeper.java
parent77d1f1a41208406bf7a3f4950ebfd647902ea295 (diff)
downloadpackages_apps_Settings-b15c68fbf19c021eb0a3bed1ccc4dd7fda384ec7.tar.gz
packages_apps_Settings-b15c68fbf19c021eb0a3bed1ccc4dd7fda384ec7.tar.bz2
packages_apps_Settings-b15c68fbf19c021eb0a3bed1ccc4dd7fda384ec7.zip
Show time to go while encrypting drive
Bug: 15159008 Change-Id: I9bb6f86c2941cbd93572c25716d21691a4fefbef
Diffstat (limited to 'src/com/android/settings/CryptKeeper.java')
-rw-r--r--src/com/android/settings/CryptKeeper.java30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index d24c741b6..4e20823a5 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -40,6 +40,7 @@ import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
+import android.text.format.DateUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -508,23 +509,40 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
return;
}
- int progress = 0;
+ // Get status as percentage first
+ CharSequence status = getText(R.string.crypt_keeper_setup_description);
+ int percent = 0;
try {
// Force a 50% progress state when debugging the view.
- progress = isDebugView() ? 50 : Integer.parseInt(state);
+ percent = isDebugView() ? 50 : Integer.parseInt(state);
} catch (Exception e) {
Log.w(TAG, "Error parsing progress: " + e.toString());
}
+ String progress = Integer.toString(percent);
- final CharSequence status = getText(R.string.crypt_keeper_setup_description);
+ // Now try to get status as time remaining and replace as appropriate
Log.v(TAG, "Encryption progress: " + progress);
+ try {
+ final String timeProperty = SystemProperties.get("vold.encrypt_time_remaining");
+ int time = Integer.parseInt(timeProperty);
+ if (time >= 0) {
+ // Round up to multiple of 10 - this way display is less jerky
+ time = (time + 9) / 10 * 10;
+ progress = DateUtils.formatElapsedTime(time);
+ status = getText(R.string.crypt_keeper_setup_time_remaining);
+ }
+ } catch (Exception e) {
+ // Will happen if no time etc - show percentage
+ }
+
final TextView tv = (TextView) findViewById(R.id.status);
if (tv != null) {
- tv.setText(TextUtils.expandTemplate(status, Integer.toString(progress)));
+ tv.setText(TextUtils.expandTemplate(status, progress));
}
- // Check the progress every 5 seconds
+
+ // Check the progress every 1 seconds
mHandler.removeMessages(MESSAGE_UPDATE_PROGRESS);
- mHandler.sendEmptyMessageDelayed(MESSAGE_UPDATE_PROGRESS, 5000);
+ mHandler.sendEmptyMessageDelayed(MESSAGE_UPDATE_PROGRESS, 1000);
}
/** Disable password input for a while to force the user to waste time between retries */