Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61dc1078 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Merge branch '1818-t-use-google-androidId' into 'master'

Use Google androidId for Licensing

See merge request !100
parents 76984931 55e98a25
Loading
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -120,7 +120,11 @@ public abstract class LicenseChecker<D, R> {
                            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) {
+17 −4
Original line number Diff line number Diff line
@@ -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);