From 55e98a25f116108a4140dfe7a965a80610fc7ab3 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Tue, 19 Dec 2023 09:32:25 +0100 Subject: [PATCH] Use Google androidId for Licensing Licensing app feature expects a Google AndroidId. --- .../vending/licensing/LicenseChecker.java | 6 +++++- .../vending/licensing/LicensingService.java | 21 +++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/vending-app/src/main/java/com/android/vending/licensing/LicenseChecker.java b/vending-app/src/main/java/com/android/vending/licensing/LicenseChecker.java index 6e4dcbb98..1b38e23c4 100644 --- a/vending-app/src/main/java/com/android/vending/licensing/LicenseChecker.java +++ b/vending-app/src/main/java/com/android/vending/licensing/LicenseChecker.java @@ -120,7 +120,11 @@ public abstract class LicenseChecker { String auth = future.getResult().getString(KEY_AUTHTOKEN); LicenseRequest request = createRequest(packageName, auth, versionCode, queryData, onRequestFinished, onRequestError); - request.ANDROID_ID = Long.decode("0x" + androidId); + + if (androidId != null) { + request.ANDROID_ID = Long.parseLong(androidId, 16); + } + request.setShouldCache(false); queue.add(request); } catch (AuthenticatorException | IOException | OperationCanceledException e) { diff --git a/vending-app/src/main/java/com/android/vending/licensing/LicensingService.java b/vending-app/src/main/java/com/android/vending/licensing/LicensingService.java index 7bae79c43..227ab776d 100644 --- a/vending-app/src/main/java/com/android/vending/licensing/LicensingService.java +++ b/vending-app/src/main/java/com/android/vending/licensing/LicensingService.java @@ -18,7 +18,6 @@ import android.net.Uri; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; -import android.provider.Settings; import android.util.Log; import com.android.volley.RequestQueue; @@ -40,12 +39,13 @@ public class LicensingService extends Service { private RequestQueue queue; private AccountManager accountManager; private LicenseServiceNotificationRunnable notificationRunnable; + private String androidId; private static final String KEY_V2_RESULT_JWT = "LICENSE_DATA"; private static final Uri PROFILE_PROVIDER = Uri.parse("content://com.google.android.gms.microg.profile"); - - private String androidId; + + private static final Uri CHECKIN_SETTINGS_PROVIDER = Uri.parse("content://com.google.android.gms.microg.settings/check-in"); private static final Uri SETTINGS_PROVIDER = Uri.parse("content://com.google.android.gms.microg.settings/play"); @@ -197,7 +197,20 @@ public class LicensingService extends Service { } } - androidId = String.valueOf(Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID)); + try { + cursor = getContentResolver().query( + CHECKIN_SETTINGS_PROVIDER, new String[] { "androidId" }, null, null, null + ); + + if (cursor != null) { + cursor.moveToNext(); + androidId = Long.toHexString(cursor.getLong(0)); + } + } finally { + if (cursor != null) { + cursor.close(); + } + } queue = Volley.newRequestQueue(this); accountManager = AccountManager.get(this); -- GitLab