From 1dc7b05ca352740e8f759e4750de4a26f3efe702 Mon Sep 17 00:00:00 2001 From: Soonil Nagarkar Date: Mon, 22 Mar 2021 11:27:43 -0700 Subject: Fix logging bugs Adds additional logging around user switches, and fixes a bug where location toggle changes were not logged correctly. Bug: 183409327 Test: manual Change-Id: I36fdef5c3eddd3db70d7c18506f82bb687677120 --- .../location/util/identity/CallerIdentity.java | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'location/java') diff --git a/location/java/android/location/util/identity/CallerIdentity.java b/location/java/android/location/util/identity/CallerIdentity.java index 85a083ee84bc..ade0ea40e157 100644 --- a/location/java/android/location/util/identity/CallerIdentity.java +++ b/location/java/android/location/util/identity/CallerIdentity.java @@ -54,6 +54,20 @@ public final class CallerIdentity { return new CallerIdentity(uid, pid, packageName, attributionTag, listenerId); } + /** + * Returns a CallerIdentity with PID and listener ID information stripped. This is mostly + * useful for aggregating information for debug purposes, and should not be used in any API with + * security requirements. + */ + public static CallerIdentity forAggregation(CallerIdentity callerIdentity) { + if (callerIdentity.getPid() == 0 && callerIdentity.getListenerId() == null) { + return callerIdentity; + } + + return new CallerIdentity(callerIdentity.getUid(), 0, callerIdentity.getPackageName(), + callerIdentity.getAttributionTag(), null); + } + /** * Creates a CallerIdentity for the current process and context. */ @@ -180,17 +194,6 @@ public final class CallerIdentity { } } - /** - * Returns a CallerIdentity corrosponding to this CallerIdentity but with a null listener id. - */ - public CallerIdentity stripListenerId() { - if (mListenerId == null) { - return this; - } else { - return new CallerIdentity(mUid, mPid, mPackageName, mAttributionTag, null); - } - } - @Override public String toString() { int length = 10 + mPackageName.length(); -- cgit v1.2.3-59-g8ed1b