[Settings] Device without EID crash settings UI
Device without EID should hide the UI, and avoid from null pointer exception. Bug: 268104585 Test: local Change-Id: I3e0016dbbae11d089de534b3fc383611719d7cbe
This commit is contained in:
@@ -144,6 +144,7 @@ public class EidStatus {
|
|||||||
}
|
}
|
||||||
return eid;
|
return eid;
|
||||||
})
|
})
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
@@ -121,11 +121,11 @@ public class SimEidPreferenceController extends BasePreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
String summary = mShowEidOnSummary ? mEidStatus.getEid() : null;
|
if (!mShowEidOnSummary) {
|
||||||
if (TextUtils.isEmpty(summary)) {
|
return mContext.getString(R.string.device_info_protected_single_press);
|
||||||
summary = mContext.getString(R.string.device_info_protected_single_press);
|
|
||||||
}
|
}
|
||||||
return summary;
|
String summary = mEidStatus.getEid();
|
||||||
|
return (summary == null) ? "" : summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -135,7 +135,8 @@ public class SimEidPreferenceController extends BasePreferenceController
|
|||||||
}
|
}
|
||||||
boolean isAvailable = SubscriptionUtil.isSimHardwareVisible(mContext) &&
|
boolean isAvailable = SubscriptionUtil.isSimHardwareVisible(mContext) &&
|
||||||
mContext.getSystemService(UserManager.class).isAdminUser() &&
|
mContext.getSystemService(UserManager.class).isAdminUser() &&
|
||||||
!Utils.isWifiOnly(mContext);
|
!Utils.isWifiOnly(mContext) &&
|
||||||
|
((mEidStatus != null) && !TextUtils.isEmpty(mEidStatus.getEid()));
|
||||||
return isAvailable ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
return isAvailable ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,15 +150,20 @@ public class SimEidPreferenceController extends BasePreferenceController
|
|||||||
WindowManager.LayoutParams.FLAG_SECURE);
|
WindowManager.LayoutParams.FLAG_SECURE);
|
||||||
dialogShwon.setCanceledOnTouchOutside(false);
|
dialogShwon.setCanceledOnTouchOutside(false);
|
||||||
|
|
||||||
|
String eid = mEidStatus.getEid();
|
||||||
|
if (eid != null) {
|
||||||
TextView textView = dialogShwon.findViewById(R.id.esim_id_value);
|
TextView textView = dialogShwon.findViewById(R.id.esim_id_value);
|
||||||
textView.setText(PhoneNumberUtil.expandByTts(mEidStatus.getEid()));
|
textView.setText(PhoneNumberUtil.expandByTts(eid));
|
||||||
textView.setTextIsSelectable(true);
|
textView.setTextIsSelectable(true);
|
||||||
|
|
||||||
ImageView qrCodeView = dialogShwon.findViewById(R.id.esim_id_qrcode);
|
ImageView qrCodeView = dialogShwon.findViewById(R.id.esim_id_qrcode);
|
||||||
qrCodeView.setImageBitmap(getEidQRcode(mEidStatus.getEid().toString(),
|
qrCodeView.setImageBitmap(getEidQRcode(eid, qrCodeView.getWidth()));
|
||||||
qrCodeView.getWidth()));
|
}
|
||||||
|
|
||||||
mShowEidOnSummary = true;
|
mShowEidOnSummary = true;
|
||||||
|
|
||||||
|
dialogShwon.setOnDismissListener(dlg -> {
|
||||||
|
mPreference.setSummary(getSummary());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user