Merge "Fix potential null package name" into tm-qpr-dev
diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java b/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java
index 625f193..8857892 100644
--- a/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java
+++ b/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java
@@ -322,6 +322,17 @@
} else {
mPendingIntentRequest = new PendingIntentRequest(pendingIntent, nanoAppId);
}
+
+ if (packageName == null) {
+ String[] packages = mContext.getPackageManager().getPackagesForUid(
+ Binder.getCallingUid());
+ if (packages != null && packages.length > 0) {
+ packageName = packages[0];
+ }
+ Log.e(TAG, "createClient: Provided package name null. Using first package name "
+ + packageName);
+ }
+
mPackage = packageName;
mAttributionTag = attributionTag;
mTransactionManager = transactionManager;