Fixes Settings app crashing when NfcAdapter is null
If a device doesn't support NFC then android.settings.NFCSHARING_SETTINGS and android.nfc.cardemulation.action.ACTION_CHANGE_DEFAULT intents shouldn't do anything and gracefully exit. Test: Manual; Emulate a non-NFC device and test with apks sending intents Bug: 80094104 Bug: 80092438 Change-Id: I5b3c3fdd582679e2cb16f474ef3331bc246b0d42
This commit is contained in:
@@ -53,6 +53,8 @@ public class AndroidBeam extends InstrumentedFragment
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mNfcAdapter = NfcAdapter.getDefaultAdapter(getActivity());
|
||||
if (mNfcAdapter == null)
|
||||
getActivity().finish();
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@@ -90,7 +92,6 @@ public class AndroidBeam extends InstrumentedFragment
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
SettingsActivity activity = (SettingsActivity) getActivity();
|
||||
|
||||
mOldActivityTitle = activity.getActionBar().getTitle();
|
||||
|
@@ -42,7 +42,11 @@ public final class PaymentDefaultDialog extends AlertActivity implements
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
try {
|
||||
mBackend = new PaymentBackend(this);
|
||||
} catch (NullPointerException e) {
|
||||
finish();
|
||||
}
|
||||
Intent intent = getIntent();
|
||||
ComponentName component = intent.getParcelableExtra(
|
||||
CardEmulation.EXTRA_SERVICE_COMPONENT);
|
||||
|
Reference in New Issue
Block a user