Prevent NPE in onActivityResult

We're returning here in an unexpected condition;  Treat all inputs
as suspect and verify before proceeding.

Bug: 3399579
Change-Id: I389bd0528f8bc721afb5a9c4646a2e23fde77f77
This commit is contained in:
Andy Stadler
2011-02-01 16:22:41 -08:00
parent 1499740c13
commit 95ef5575a2

View File

@@ -31,6 +31,7 @@ import android.os.BatteryManager;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -184,11 +185,13 @@ public class CryptKeeperSettings extends Fragment {
// If the user entered a valid keyguard trace, present the final // If the user entered a valid keyguard trace, present the final
// confirmation prompt; otherwise, go back to the initial state. // confirmation prompt; otherwise, go back to the initial state.
if (resultCode == Activity.RESULT_OK) { if (resultCode == Activity.RESULT_OK && data != null) {
String password = data.getStringExtra("password"); String password = data.getStringExtra("password");
if (!TextUtils.isEmpty(password)) {
showFinalConfirmation(password); showFinalConfirmation(password);
} }
} }
}
private void showFinalConfirmation(String password) { private void showFinalConfirmation(String password) {
Preference preference = new Preference(getActivity()); Preference preference = new Preference(getActivity());