diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 1e392b4c4a11a17b61cfe86d57c877f7559c90dc..3f99083264ffaeb26f165f421913f36bcaa8c2d8 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -20,6 +20,8 @@ to be updated. This will be fixed later
+
+
+
diff --git a/src/org/lineageos/updater/UpdatesCheckReceiver.java b/src/org/lineageos/updater/UpdatesCheckReceiver.java
index 993c3b69dece704da0dec543606d052960469ef6..ed70029be151da95cd4fbc45cc5657130f42ef08 100644
--- a/src/org/lineageos/updater/UpdatesCheckReceiver.java
+++ b/src/org/lineageos/updater/UpdatesCheckReceiver.java
@@ -24,6 +24,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.SystemClock;
+import android.provider.Settings;
import android.util.Log;
import androidx.core.app.NotificationCompat;
@@ -52,6 +53,14 @@ public class UpdatesCheckReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
+ // Check if the current value is empty or null and set license id.
+ String eLicenseID = Settings.Secure.getString(context.getContentResolver(),
+ Settings.Secure.E_LICENSE_ID);
+ if (eLicenseID == null || eLicenseID.isEmpty()) {
+ Settings.Secure.putString(context.getContentResolver(),
+ Settings.Secure.E_LICENSE_ID, Utils.generateRandomID());
+ }
+
Utils.cleanupDownloadsDir(context);
}
diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java
index d795a7c9bf9639e69880dad3647f5cd62ee4b9a3..a68901be83a99329af5dddcd7fb141640b31f428 100644
--- a/src/org/lineageos/updater/misc/Utils.java
+++ b/src/org/lineageos/updater/misc/Utils.java
@@ -58,6 +58,7 @@ import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Locale;
+import java.util.UUID;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -94,6 +95,11 @@ public class Utils {
return new File(context.getCacheDir(), "updates.json");
}
+ public static String generateRandomID() {
+ String uuid = UUID.randomUUID().toString().replace("-", "");
+ return "anon" + uuid;
+ }
+
// This should really return an UpdateBaseInfo object, but currently this only
// used to initialize UpdateInfo objects
private static UpdateInfo parseJsonUpdate(JSONObject object) throws JSONException {
@@ -214,6 +220,8 @@ public class Utils {
String device = SystemProperties.get(Constants.PROP_NEXT_DEVICE,
SystemProperties.get(Constants.PROP_DEVICE));
String type = SystemProperties.get(Constants.PROP_RELEASE_TYPE).toLowerCase(Locale.ROOT);
+ String eLicenseID = Settings.Secure.getString(context.getContentResolver(),
+ Settings.Secure.E_LICENSE_ID);
String serverUrl = "";
if (retrieveStatus(context) != null) {
@@ -232,6 +240,11 @@ public class Utils {
if (serverUrl.trim().isEmpty()) {
serverUrl = context.getString(R.string.updater_server_url);
}
+
+ if (eLicenseID != null && !eLicenseID.isEmpty()) {
+ serverUrl += "?license_id=" + eLicenseID;
+ }
+
return serverUrl.replace("{device}", device)
.replace("{type}", type)
.replace("{incr}", incrementalVersion);