mirror of
https://gitlab.com/xynngh/YetAnotherCallBlocker.git
synced 2025-06-05 22:19:12 +02:00
Properly quote numbers in logs
This commit is contained in:
@@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||
|
||||
import static dummydomain.yetanothercallblocker.utils.StringUtils.quote;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
public class CallMonitoringService extends Service {
|
||||
@@ -125,7 +126,7 @@ public class CallMonitoringService extends Service {
|
||||
|
||||
@Override
|
||||
public void onCallStateChanged(int state, String phoneNumber) {
|
||||
LOG.info("onCallStateChanged({}, \"{}\")", state, phoneNumber);
|
||||
LOG.info("onCallStateChanged({}, {})", state, quote(phoneNumber));
|
||||
|
||||
/*
|
||||
* According to docs, an empty string may be passed if the app lacks permissions.
|
||||
|
@@ -11,6 +11,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||
|
||||
import static dummydomain.yetanothercallblocker.utils.StringUtils.quote;
|
||||
|
||||
public class CallReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CallReceiver.class);
|
||||
@@ -43,7 +45,7 @@ public class CallReceiver extends BroadcastReceiver {
|
||||
String incomingNumber = intent.getStringExtra(extraIncomingNumber);
|
||||
boolean hasNumberExtra = intent.hasExtra(extraIncomingNumber);
|
||||
LOG.info("onReceive() extraState={}, incomingNumber={}, hasNumberExtra={}",
|
||||
telephonyExtraState, incomingNumber, hasNumberExtra);
|
||||
telephonyExtraState, quote(incomingNumber), hasNumberExtra);
|
||||
|
||||
extraLogging(intent); // TODO: make optional or remove
|
||||
|
||||
|
@@ -20,6 +20,7 @@ import dummydomain.yetanothercallblocker.event.CallOngoingEvent;
|
||||
import dummydomain.yetanothercallblocker.utils.PhoneUtils;
|
||||
|
||||
import static dummydomain.yetanothercallblocker.EventUtils.postEvent;
|
||||
import static dummydomain.yetanothercallblocker.utils.StringUtils.quote;
|
||||
|
||||
public class PhoneStateHandler {
|
||||
|
||||
@@ -51,7 +52,7 @@ public class PhoneStateHandler {
|
||||
}
|
||||
|
||||
public void onRinging(Source source, String phoneNumber) {
|
||||
LOG.debug("onRinging({}, \"{}\")", source, phoneNumber);
|
||||
LOG.debug("onRinging({}, {})", source, quote(phoneNumber));
|
||||
|
||||
boolean ignore = false;
|
||||
|
||||
@@ -117,7 +118,7 @@ public class PhoneStateHandler {
|
||||
}
|
||||
|
||||
public void onOffHook(Source source, String phoneNumber) {
|
||||
LOG.debug("onOffHook({}, \"{}\")", source, phoneNumber);
|
||||
LOG.debug("onOffHook({}, {})", source, quote(phoneNumber));
|
||||
|
||||
isOffHook = true;
|
||||
|
||||
@@ -125,7 +126,7 @@ public class PhoneStateHandler {
|
||||
}
|
||||
|
||||
public void onIdle(Source source, String phoneNumber) {
|
||||
LOG.debug("onIdle({}, \"{}\")", source, phoneNumber);
|
||||
LOG.debug("onIdle({}, {})", source, quote(phoneNumber));
|
||||
|
||||
isOffHook = false;
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
package dummydomain.yetanothercallblocker.utils;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
public static String quote(String s) {
|
||||
return s == null ? null : '"' + s + '"';
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user