From 66976ad713d41e773669a02217f8001463af7c50 Mon Sep 17 00:00:00 2001 From: Joseph Steele Date: Sat, 16 May 2026 18:03:48 +0100 Subject: [PATCH] wearable: restore ClientIdentity population in WearableLocationService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `generateClientIdentity` has been returning `null` since the `ClientIdentity` constructor was retired in favour of the AutoSafeParcelable public-field layout. The callsite still wraps the result into `request.clients`, so every per-client entry in the forwarded `LocationRequestInternal` was a null reference — anything downstream that branched on `client.uid` / `client.packageName` silently lost the package association coming from the watch. Restore the original behaviour against the current ClientIdentity: - Look up the supplied package name via `PackageManager`, populate `uid` and `packageName` from the resolved `ApplicationInfo`. - On `NameNotFoundException`, fall back to the host process's own UID/package (matching the historical fallback that was commented out alongside the null return) and log a warning. Touches one file, ~10 LOC of behavioural change. Non-overlapping with the WearOS transport work in PR #3473 — that PR keeps the watch link alive; this restores the per-client identity needed for the relayed location requests to do anything useful once they arrive. Relates to #2843 --- .../location/WearableLocationService.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/play-services-wearable/core/src/main/java/org/microg/gms/wearable/location/WearableLocationService.java b/play-services-wearable/core/src/main/java/org/microg/gms/wearable/location/WearableLocationService.java index fa472a351a..fe3554e5fe 100644 --- a/play-services-wearable/core/src/main/java/org/microg/gms/wearable/location/WearableLocationService.java +++ b/play-services-wearable/core/src/main/java/org/microg/gms/wearable/location/WearableLocationService.java @@ -17,6 +17,7 @@ package org.microg.gms.wearable.location; import android.content.Context; +import android.content.pm.PackageManager; import android.util.Log; import com.google.android.gms.common.api.GoogleApiClient; @@ -139,12 +140,21 @@ private static LocationRequestInternal readLocationRequest(DataMap dataMap, Cont } private static ClientIdentity generateClientIdentity(String packageName, Context context) { - return null; - /*try { - return new ClientIdentity(context.getPackageManager().getApplicationInfo(packageName, 0).uid, packageName); + // Previously returned null, which produced null-bearing + // List entries downstream and made the per-client UID + // path on the watch-side unusable. ClientIdentity is now an + // AutoSafeParcelable with public fields rather than a constructor, so + // populate the fields directly and fall back to the host package when + // the wearable-supplied package name is not installed. + ClientIdentity identity = new ClientIdentity(); + try { + identity.uid = context.getPackageManager().getApplicationInfo(packageName, 0).uid; + identity.packageName = packageName; } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, "Unknown client identity: " + packageName, e); - return new ClientIdentity(context.getApplicationInfo().uid, context.getPackageName()); - }*/ + identity.uid = context.getApplicationInfo().uid; + identity.packageName = context.getPackageName(); + } + return identity; } }