Merge change I6983cab3 into eclair-mr2
* changes: Add saving/restoring state in CredentialInstaller and ...
This commit is contained in:
@@ -321,7 +321,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="CredentialInstaller"
|
<activity android:name="CredentialInstaller"
|
||||||
android:label="@string/credential_installer_activity_title">
|
android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.credentials.SYSTEM_INSTALL" />
|
<action android:name="android.credentials.SYSTEM_INSTALL" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
@@ -1937,9 +1937,6 @@ found in the list of installed applications.</string>
|
|||||||
<string name="gadget_toggle_wifi">Updating Wi-Fi setting</string>
|
<string name="gadget_toggle_wifi">Updating Wi-Fi setting</string>
|
||||||
<string name="gadget_toggle_bluetooth">Updating Bluetooth setting</string>
|
<string name="gadget_toggle_bluetooth">Updating Bluetooth setting</string>
|
||||||
|
|
||||||
<!-- credential installer title -->
|
|
||||||
<string name="credential_installer_activity_title">Credential installer</string>
|
|
||||||
|
|
||||||
<string name="vpn_settings_activity_title">VPN settings</string>
|
<string name="vpn_settings_activity_title">VPN settings</string>
|
||||||
|
|
||||||
<!-- Title of VPN connect dialog -->
|
<!-- Title of VPN connect dialog -->
|
||||||
|
@@ -32,6 +32,7 @@ import android.util.Log;
|
|||||||
*/
|
*/
|
||||||
public class CredentialInstaller extends Activity {
|
public class CredentialInstaller extends Activity {
|
||||||
private static final String TAG = "CredentialInstaller";
|
private static final String TAG = "CredentialInstaller";
|
||||||
|
private static final String UNLOCKING = "ulck";
|
||||||
|
|
||||||
private KeyStore mKeyStore = KeyStore.getInstance();
|
private KeyStore mKeyStore = KeyStore.getInstance();
|
||||||
private boolean mUnlocking = false;
|
private boolean mUnlocking = false;
|
||||||
@@ -42,15 +43,26 @@ public class CredentialInstaller extends Activity {
|
|||||||
|
|
||||||
if (!"com.android.certinstaller".equals(getCallingPackage())) finish();
|
if (!"com.android.certinstaller".equals(getCallingPackage())) finish();
|
||||||
|
|
||||||
if (!isKeyStoreLocked()) {
|
if (isKeyStoreUnlocked()) {
|
||||||
install();
|
install();
|
||||||
finish();
|
|
||||||
} else if (!mUnlocking) {
|
} else if (!mUnlocking) {
|
||||||
mUnlocking = true;
|
mUnlocking = true;
|
||||||
Credentials.getInstance().unlock(this);
|
Credentials.getInstance().unlock(this);
|
||||||
} else {
|
return;
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(Bundle outStates) {
|
||||||
|
super.onSaveInstanceState(outStates);
|
||||||
|
outStates.putBoolean(UNLOCKING, mUnlocking);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRestoreInstanceState(Bundle savedStates) {
|
||||||
|
super.onRestoreInstanceState(savedStates);
|
||||||
|
mUnlocking = savedStates.getBoolean(UNLOCKING);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void install() {
|
private void install() {
|
||||||
@@ -61,13 +73,13 @@ public class CredentialInstaller extends Activity {
|
|||||||
byte[] data = bundle.getByteArray(key);
|
byte[] data = bundle.getByteArray(key);
|
||||||
if (data == null) continue;
|
if (data == null) continue;
|
||||||
boolean success = mKeyStore.put(key.getBytes(), data);
|
boolean success = mKeyStore.put(key.getBytes(), data);
|
||||||
Log.v(TAG, "install " + key + ": " + data.length + " success? " + success);
|
Log.d(TAG, "install " + key + ": " + data.length + " success? " + success);
|
||||||
if (!success) return;
|
if (!success) return;
|
||||||
}
|
}
|
||||||
setResult(RESULT_OK);
|
setResult(RESULT_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isKeyStoreLocked() {
|
private boolean isKeyStoreUnlocked() {
|
||||||
return (mKeyStore.test() != KeyStore.NO_ERROR);
|
return (mKeyStore.test() == KeyStore.NO_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user