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 6e4dcbb984c293ad7bc6795a07c761973286a534..1b38e23c473612026ca430e8b311960d8496f8a3 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 7bae79c43b7b44e5776461d7e6922cd154dcf17c..227ab776d441fcf08c075630d5800a09c3fff131 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);