new password shouldn't be empty string
enter "Home screen backup password" in "Developer Settings", do nothings and then click "Set backup password", There will be a toast display "New backup password set". The new password field cannot be empty. Bug: https://partnerissuetracker.corp.google.com/u/2/issues/111261338 Test: empty string can not be set as a password Signed-off-by: xiamin <xiamin@xiaomi.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import android.app.backup.IBackupManager;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@@ -45,7 +46,7 @@ public class SetFullBackupPassword extends Activity {
|
|||||||
|
|
||||||
if (!newPw.equals(confirmPw)) {
|
if (!newPw.equals(confirmPw)) {
|
||||||
// Mismatch between new pw and its confirmation re-entry
|
// Mismatch between new pw and its confirmation re-entry
|
||||||
Log.i(TAG, "password mismatch");
|
Log.i(TAG, "password mismatch");
|
||||||
Toast.makeText(SetFullBackupPassword.this,
|
Toast.makeText(SetFullBackupPassword.this,
|
||||||
R.string.local_backup_password_toast_confirmation_mismatch,
|
R.string.local_backup_password_toast_confirmation_mismatch,
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
@@ -56,14 +57,14 @@ Log.i(TAG, "password mismatch");
|
|||||||
|
|
||||||
if (setBackupPassword(curPw, newPw)) {
|
if (setBackupPassword(curPw, newPw)) {
|
||||||
// success
|
// success
|
||||||
Log.i(TAG, "password set successfully");
|
Log.i(TAG, "password set successfully");
|
||||||
Toast.makeText(SetFullBackupPassword.this,
|
Toast.makeText(SetFullBackupPassword.this,
|
||||||
R.string.local_backup_password_toast_success,
|
R.string.local_backup_password_toast_success,
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
// failure -- bad existing pw, usually
|
// failure -- bad existing pw, usually
|
||||||
Log.i(TAG, "failure; password mismatch?");
|
Log.i(TAG, "failure; password mismatch?");
|
||||||
Toast.makeText(SetFullBackupPassword.this,
|
Toast.makeText(SetFullBackupPassword.this,
|
||||||
R.string.local_backup_password_toast_validation_failure,
|
R.string.local_backup_password_toast_validation_failure,
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
@@ -96,6 +97,11 @@ Log.i(TAG, "failure; password mismatch?");
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean setBackupPassword(String currentPw, String newPw) {
|
private boolean setBackupPassword(String currentPw, String newPw) {
|
||||||
|
// new password can't be empty
|
||||||
|
if (TextUtils.isEmpty(newPw)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return mBackupManager.setBackupPassword(currentPw, newPw);
|
return mBackupManager.setBackupPassword(currentPw, newPw);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
Reference in New Issue
Block a user