diff options
Diffstat (limited to 'telecomm/java/android/telecom/Log.java')
-rw-r--r-- | telecomm/java/android/telecom/Log.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/telecomm/java/android/telecom/Log.java b/telecomm/java/android/telecom/Log.java index 4f6a9d6450f8..a90d0532b721 100644 --- a/telecomm/java/android/telecom/Log.java +++ b/telecomm/java/android/telecom/Log.java @@ -16,7 +16,9 @@ package android.telecom; +import android.annotation.NonNull; import android.compat.annotation.UnsupportedAppUsage; +import android.content.ComponentName; import android.content.Context; import android.net.Uri; import android.os.Build; @@ -29,8 +31,10 @@ import android.text.TextUtils; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.IndentingPrintWriter; +import java.util.Arrays; import java.util.IllegalFormatException; import java.util.Locale; +import java.util.stream.Collectors; /** * Manages logging for the entire module. @@ -212,6 +216,16 @@ public class Log { return getSessionManager().getExternalSession(); } + /** + * Retrieves external session information, providing a context for the recipient of the session + * info where the external session came from. + * @param ownerInfo The external owner info. + * @return New {@link Session.Info} instance with owner info set. + */ + public static Session.Info getExternalSession(@NonNull String ownerInfo) { + return getSessionManager().getExternalSession(ownerInfo); + } + public static void cancelSubsession(Session subsession) { getSessionManager().cancelSubsession(subsession); } @@ -481,4 +495,34 @@ public class Log { } return String.format(Locale.US, "%s: %s%s", prefix, msg, sessionPostfix); } + + /** + * Generates an abbreviated version of the package name from a component. + * E.g. com.android.phone becomes cap + * @param componentName The component name to abbreviate. + * @return Abbreviation of empty string if component is null. + * @hide + */ + public static String getPackageAbbreviation(ComponentName componentName) { + if (componentName == null) { + return ""; + } + return getPackageAbbreviation(componentName.getPackageName()); + } + + /** + * Generates an abbreviated version of the package name. + * E.g. com.android.phone becomes cap + * @param packageName The packageName name to abbreviate. + * @return Abbreviation of empty string if package is null. + * @hide + */ + public static String getPackageAbbreviation(String packageName) { + if (packageName == null) { + return ""; + } + return Arrays.stream(packageName.split("\\.")) + .map(s -> s.substring(0,1)) + .collect(Collectors.joining("")); + } } |