summaryrefslogtreecommitdiff
path: root/telecomm/java/android/telecom/Logging/Session.java
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2020-08-31 21:21:38 -0700
committerXin Li <delphij@google.com>2020-08-31 21:21:38 -0700
commit628590d7ec80e10a3fc24b1c18a1afb55cca10a8 (patch)
tree4b1c3f52d86d7fb53afbe9e9438468588fa489f8 /telecomm/java/android/telecom/Logging/Session.java
parentb11b8ec3aec8bb42f2c07e1c5ac7942da293baa8 (diff)
parentd2d3a20624d968199353ccf6ddbae6f3ac39c9af (diff)
Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507 Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27 Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2
Diffstat (limited to 'telecomm/java/android/telecom/Logging/Session.java')
-rw-r--r--telecomm/java/android/telecom/Logging/Session.java40
1 files changed, 37 insertions, 3 deletions
diff --git a/telecomm/java/android/telecom/Logging/Session.java b/telecomm/java/android/telecom/Logging/Session.java
index 8d3f4e1df8bc..4aa3614fa004 100644
--- a/telecomm/java/android/telecom/Logging/Session.java
+++ b/telecomm/java/android/telecom/Logging/Session.java
@@ -17,6 +17,7 @@
package android.telecom.Logging;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
import android.telecom.Log;
@@ -59,10 +60,12 @@ public class Session {
public static class Info implements Parcelable {
public final String sessionId;
public final String methodPath;
+ public final String ownerInfo;
- private Info(String id, String path) {
+ private Info(String id, String path, String owner) {
sessionId = id;
methodPath = path;
+ ownerInfo = owner;
}
public static Info getInfo (Session s) {
@@ -70,7 +73,28 @@ public class Session {
// not get multiple stacking external sessions (unless we have DEBUG level logging or
// lower).
return new Info(s.getFullSessionId(), s.getFullMethodPath(
- !Log.DEBUG && s.isSessionExternal()));
+ !Log.DEBUG && s.isSessionExternal()), s.getOwnerInfo());
+ }
+
+ public static Info getExternalInfo(Session s, @Nullable String ownerInfo) {
+ // When creating session information for an existing session, the caller may pass in a
+ // context to be passed along to the recipient of the external session info.
+ // So, for example, if telecom has an active session with owner 'cad', and Telecom is
+ // calling into Telephony and providing external session info, it would pass in 'cast'
+ // as the owner info. This would result in Telephony seeing owner info 'cad/cast',
+ // which would make it very clear in the Telephony logs the chain of package calls which
+ // ultimately resulted in the logs.
+ String newInfo = ownerInfo != null && s.getOwnerInfo() != null
+ // If we've got both, concatenate them.
+ ? s.getOwnerInfo() + "/" + ownerInfo
+ // Otherwise use whichever is present.
+ : ownerInfo != null ? ownerInfo : s.getOwnerInfo();
+
+ // Create Info based on the truncated method path if the session is external, so we do
+ // not get multiple stacking external sessions (unless we have DEBUG level logging or
+ // lower).
+ return new Info(s.getFullSessionId(), s.getFullMethodPath(
+ !Log.DEBUG && s.isSessionExternal()), newInfo);
}
/** Responsible for creating Info objects for deserialized Parcels. */
@@ -80,7 +104,8 @@ public class Session {
public Info createFromParcel(Parcel source) {
String id = source.readString();
String methodName = source.readString();
- return new Info(id, methodName);
+ String ownerInfo = source.readString();
+ return new Info(id, methodName, ownerInfo);
}
@Override
@@ -100,6 +125,7 @@ public class Session {
public void writeToParcel(Parcel destination, int flags) {
destination.writeString(sessionId);
destination.writeString(methodPath);
+ destination.writeString(ownerInfo);
}
}
@@ -206,6 +232,14 @@ public class Session {
return Info.getInfo(this);
}
+ public Info getExternalInfo(@Nullable String ownerInfo) {
+ return Info.getExternalInfo(this, ownerInfo);
+ }
+
+ public String getOwnerInfo() {
+ return mOwnerInfo;
+ }
+
@VisibleForTesting
public String getSessionId() {
return mSessionId;