Add logging in ZenLog for calls to matchesCallFilter.
Test: manual Bug: 192592755 Change-Id: Id8e3b1b2247f6d6389e6c21579216eb9c17245cc
This commit is contained in:
@@ -65,6 +65,7 @@ public class ZenLog {
|
||||
private static final int TYPE_LISTENER_HINTS_CHANGED = 15;
|
||||
private static final int TYPE_SET_NOTIFICATION_POLICY = 16;
|
||||
private static final int TYPE_SET_CONSOLIDATED_ZEN_POLICY = 17;
|
||||
private static final int TYPE_MATCHES_CALL_FILTER = 18;
|
||||
|
||||
private static int sNext;
|
||||
private static int sSize;
|
||||
@@ -166,6 +167,13 @@ public class ZenLog {
|
||||
+ hintsToString(newHints) + ",listeners=" + listenerCount);
|
||||
}
|
||||
|
||||
/*
|
||||
* Trace calls to matchesCallFilter with the result of the call and the reason for the result.
|
||||
*/
|
||||
public static void traceMatchesCallFilter(boolean result, String reason) {
|
||||
append(TYPE_MATCHES_CALL_FILTER, "result=" + result + ", reason=" + reason);
|
||||
}
|
||||
|
||||
private static String subscribeResult(IConditionProvider provider, RemoteException e) {
|
||||
return provider == null ? "no provider" : e != null ? e.getMessage() : "ok";
|
||||
}
|
||||
@@ -189,6 +197,7 @@ public class ZenLog {
|
||||
case TYPE_LISTENER_HINTS_CHANGED: return "listener_hints_changed";
|
||||
case TYPE_SET_NOTIFICATION_POLICY: return "set_notification_policy";
|
||||
case TYPE_SET_CONSOLIDATED_ZEN_POLICY: return "set_consolidated_policy";
|
||||
case TYPE_MATCHES_CALL_FILTER: return "matches_call_filter";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,20 +89,34 @@ public class ZenModeFiltering {
|
||||
public static boolean matchesCallFilter(Context context, int zen, NotificationManager.Policy
|
||||
consolidatedPolicy, UserHandle userHandle, Bundle extras,
|
||||
ValidateNotificationPeople validator, int contactsTimeoutMs, float timeoutAffinity) {
|
||||
if (zen == Global.ZEN_MODE_NO_INTERRUPTIONS) return false; // nothing gets through
|
||||
if (zen == Global.ZEN_MODE_ALARMS) return false; // not an alarm
|
||||
if (zen == Global.ZEN_MODE_NO_INTERRUPTIONS) {
|
||||
ZenLog.traceMatchesCallFilter(false, "no interruptions");
|
||||
return false; // nothing gets through
|
||||
}
|
||||
if (zen == Global.ZEN_MODE_ALARMS) {
|
||||
ZenLog.traceMatchesCallFilter(false, "alarms only");
|
||||
return false; // not an alarm
|
||||
}
|
||||
if (zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) {
|
||||
if (consolidatedPolicy.allowRepeatCallers()
|
||||
&& REPEAT_CALLERS.isRepeat(context, extras)) {
|
||||
ZenLog.traceMatchesCallFilter(true, "repeat caller");
|
||||
return true;
|
||||
}
|
||||
if (!consolidatedPolicy.allowCalls()) return false; // no other calls get through
|
||||
if (!consolidatedPolicy.allowCalls()) {
|
||||
ZenLog.traceMatchesCallFilter(false, "calls not allowed");
|
||||
return false; // no other calls get through
|
||||
}
|
||||
if (validator != null) {
|
||||
final float contactAffinity = validator.getContactAffinity(userHandle, extras,
|
||||
contactsTimeoutMs, timeoutAffinity);
|
||||
return audienceMatches(consolidatedPolicy.allowCallsFrom(), contactAffinity);
|
||||
boolean match =
|
||||
audienceMatches(consolidatedPolicy.allowCallsFrom(), contactAffinity);
|
||||
ZenLog.traceMatchesCallFilter(match, "contact affinity " + contactAffinity);
|
||||
return match;
|
||||
}
|
||||
}
|
||||
ZenLog.traceMatchesCallFilter(true, "no restrictions");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user