Rename CallReceiver

This commit is contained in:
xynngh 2020-09-11 13:28:13 +04:00
parent db33272fdc
commit c26157e808
3 changed files with 9 additions and 8 deletions

View File

@ -115,7 +115,7 @@
</intent-filter>
</receiver>
<receiver
android:name=".CallReceiver"
android:name=".PhoneStateBroadcastReceiver"
android:directBootAware="true">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />

View File

@ -28,7 +28,8 @@ public class CallMonitoringService extends Service {
private static final Logger LOG = LoggerFactory.getLogger(CallMonitoringService.class);
private final MyPhoneStateListener phoneStateListener = new MyPhoneStateListener();
private final CallReceiver callReceiver = new CallReceiver(
private final PhoneStateBroadcastReceiver phoneStateBroadcastReceiver
= new PhoneStateBroadcastReceiver(
PhoneStateHandler.Source.PHONE_STATE_BROADCAST_RECEIVER_MONITORING);
private boolean monitoringStarted;
@ -95,7 +96,7 @@ public class CallMonitoringService extends Service {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(TelephonyManager.EXTRA_STATE_RINGING); // TODO: check
intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
registerReceiver(callReceiver, intentFilter);
registerReceiver(phoneStateBroadcastReceiver, intentFilter);
} catch (Exception e) {
LOG.error("startMonitoring()", e);
}
@ -107,7 +108,7 @@ public class CallMonitoringService extends Service {
try {
getTelephonyManager().listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
unregisterReceiver(callReceiver);
unregisterReceiver(phoneStateBroadcastReceiver);
} catch (Exception e) {
LOG.error("stopMonitoring()", e);
}

View File

@ -13,18 +13,18 @@ import dummydomain.yetanothercallblocker.data.YacbHolder;
import static dummydomain.yetanothercallblocker.utils.StringUtils.quote;
public class CallReceiver extends BroadcastReceiver {
public class PhoneStateBroadcastReceiver extends BroadcastReceiver {
private static final Logger LOG = LoggerFactory.getLogger(CallReceiver.class);
private static final Logger LOG = LoggerFactory.getLogger(PhoneStateBroadcastReceiver.class);
private final PhoneStateHandler.Source source;
@SuppressWarnings({"unused", "RedundantSuppression"}) // required for BroadcastReceivers
public CallReceiver() {
public PhoneStateBroadcastReceiver() {
this(PhoneStateHandler.Source.PHONE_STATE_BROADCAST_RECEIVER);
}
public CallReceiver(PhoneStateHandler.Source source) {
public PhoneStateBroadcastReceiver(PhoneStateHandler.Source source) {
this.source = source;
}