SupportLeanbackDemos: Fixed password crash when no payment is selected
The second Guided Step fragment crashed when a password was entered but no credit card info was selected, because it was trying to extract "Visa" or "Master" substrings from an empty string. Put a check for string sizes before this extraction is performed. Change-Id: I9b93a302f5f855b1853885ff4e5fc9a04c200766
This commit is contained in:
@@ -420,8 +420,10 @@ public class GuidedStepActivity extends Activity {
|
||||
|
||||
boolean isPaymentValid() {
|
||||
CharSequence paymentType = findActionById(PAYMENT).getDescription();
|
||||
return paymentType.subSequence(0, 4).toString().equals("Visa") ||
|
||||
paymentType.subSequence(0, 6).toString().equals("Master");
|
||||
return (paymentType.length() >= 4 &&
|
||||
paymentType.subSequence(0, 4).toString().equals("Visa")) ||
|
||||
(paymentType.length() >= 6 &&
|
||||
paymentType.subSequence(0, 6).toString().equals("Master"));
|
||||
}
|
||||
|
||||
boolean isPasswordValid() {
|
||||
|
||||
@@ -422,8 +422,10 @@ public class GuidedStepSupportActivity extends FragmentActivity {
|
||||
|
||||
boolean isPaymentValid() {
|
||||
CharSequence paymentType = findActionById(PAYMENT).getDescription();
|
||||
return paymentType.subSequence(0, 4).toString().equals("Visa") ||
|
||||
paymentType.subSequence(0, 6).toString().equals("Master");
|
||||
return (paymentType.length() >= 4 &&
|
||||
paymentType.subSequence(0, 4).toString().equals("Visa")) ||
|
||||
(paymentType.length() >= 6 &&
|
||||
paymentType.subSequence(0, 6).toString().equals("Master"));
|
||||
}
|
||||
|
||||
boolean isPasswordValid() {
|
||||
|
||||
Reference in New Issue
Block a user