incidentd: creating PolicyProto for NotificationManager
The previous code saved a String in the proto like "NotificationManager.Policy[priorityCategories=PRIORITY_CATEGORY_REMINDERS,PRIORITY_CATEGORY_EVENTS,PRIORITY_CATEGORY_MESSAGES,PRIORITY_CATEGORY_CALLS,PRIORITY_CATEGORY_REPEAT_CALLERS,priorityCallSenders=PRIORITY_SENDERS_STARRED,priorityMessageSenders=PRIORITY_SENDERS_STARRED,suppressedVisualEffects=SUPPRESSED_EFFECT_SCREEN_OFF]". This unfortunately would mean that the String would have to be parsed on the server-side, which kinda defeats the purpose of migrating to protos, so I made a proto for this :) BUG: 65750824 Test: flash device and check incident.proto output, comparing it to the previous output Change-Id: I87607dc7b72ce3519132da23167b4bdce3b7ef4c
This commit is contained in:
@@ -41,6 +41,7 @@ import android.provider.Settings.Global;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.service.notification.ZenModeConfig;
|
||||
import android.util.Log;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -1061,6 +1062,27 @@ public class NotificationManager {
|
||||
+ "]";
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void toProto(ProtoOutputStream proto, long fieldId) {
|
||||
final long pToken = proto.start(fieldId);
|
||||
|
||||
bitwiseToProtoEnum(proto, PolicyProto.PRIORITY_CATEGORIES, priorityCategories);
|
||||
proto.write(PolicyProto.PRIORITY_CALL_SENDER, priorityCallSenders);
|
||||
proto.write(PolicyProto.PRIORITY_MESSAGE_SENDER, priorityMessageSenders);
|
||||
bitwiseToProtoEnum(
|
||||
proto, PolicyProto.SUPPRESSED_VISUAL_EFFECTS, suppressedVisualEffects);
|
||||
|
||||
proto.end(pToken);
|
||||
}
|
||||
|
||||
private static void bitwiseToProtoEnum(ProtoOutputStream proto, long fieldId, int data) {
|
||||
for (int i = 1; data > 0; ++i, data >>>= 1) {
|
||||
if ((data & 1) == 1) {
|
||||
proto.write(fieldId, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String suppressedEffectsToString(int effects) {
|
||||
if (effects <= 0) return "";
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user