Skip to content

Commit

Permalink
Prevent from seldon NPE on S2MSP registration (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
frimtec authored Jun 17, 2022
1 parent c068ebc commit 87b66d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Fragment createFragment(int position) {
switch (fragmentPosition) {
case STATE:
StateFragment stateFragment = new StateFragment();
stateFragment.setActivityFacade(MainActivity.this, new StateFragment.BillingAccess() {
stateFragment.setActivityFacade(new StateFragment.BillingAccess() {
@Override
public List<BillingProvider.BillingState> getProducts() {
return MainActivity.this.billingAdapter.getAllProducts();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import static com.github.frimtec.android.pikettassist.ui.overview.State.TrafficLight.YELLOW;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
Expand Down Expand Up @@ -92,7 +91,6 @@ public interface BillingAccess {

private AlertService alertService;
private SecureSmsProxyFacade s2msp;
private Activity activity;
private BillingAccess billingAccess;

private SignalStrengthService signalStrengthService;
Expand All @@ -114,8 +112,7 @@ public StateFragment() {
this.testAlarmDao = testAlarmDao;
}

public void setActivityFacade(Activity parent, BillingAccess billingAccess) {
this.activity = parent;
public void setActivityFacade(BillingAccess billingAccess) {
this.billingAccess = billingAccess;
}

Expand Down Expand Up @@ -224,7 +221,7 @@ private void regularStates(List<State> states) {
this,
getContext(),
this::refresh,
() -> this.s2msp.register(activity, REGISTER_SMS_ADAPTER_REQUEST_CODE, operationsCenterPhoneNumbers, SmsListener.class),
() -> this.s2msp.register(getActivity(), REGISTER_SMS_ADAPTER_REQUEST_CODE, operationsCenterPhoneNumbers, SmsListener.class),
() -> this.s2msp.sendSms(new Sms(SecureSmsProxyFacade.PHONE_NUMBER_LOOPBACK, ":-)"), ApplicationState.instance().getSmsAdapterSecret()),
() -> this.alertService.confirmAlert(),
() -> this.alertService.closeAlert(),
Expand Down

0 comments on commit 87b66d8

Please sign in to comment.