Skip to content

Commit

Permalink
Use Google androidId for Licensing
Browse files Browse the repository at this point in the history
Licensing app feature expects a Google AndroidId.
  • Loading branch information
jonathanklee authored and fynngodau committed Jan 11, 2024
1 parent b65aaee commit e84bdce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ public void checkLicense(Account account, AccountManager accountManager, String
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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;
Expand All @@ -45,16 +44,17 @@ 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 SETTINGS_PROVIDER = Uri.parse("content://com.google.android.gms.microg.settings/play");
private static final Uri PROFILE_PROVIDER = Uri.parse("content://com.google.android.gms.microg.profile");

private static final String PREFERENCE_LICENSING_ENABLED = "play_licensing";
private static final Uri CHECKIN_SETTINGS_PROVIDER = Uri.parse("content://com.google.android.gms.microg.settings/check-in");

private static final Uri PROFILE_PROVIDER = Uri.parse("content://com.google.android.gms.microg.profile");
private static final Uri SETTINGS_PROVIDER = Uri.parse("content://com.google.android.gms.microg.settings/play");

private String androidId;
private static final String PREFERENCE_LICENSING_ENABLED = "play_licensing";

private final ILicensingService.Stub mLicenseService = new ILicensingService.Stub() {

Expand Down Expand Up @@ -202,7 +202,20 @@ public IBinder onBind(Intent intent) {
}
}

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);
Expand Down

0 comments on commit e84bdce

Please sign in to comment.