From 42d42308698309ec0bd25d02463673d6c4538fce Mon Sep 17 00:00:00 2001 From: althafvly Date: Wed, 9 Aug 2023 14:50:10 +0530 Subject: [PATCH 1/2] Updater: Rename license id to anon hash Change-Id: I327cddd1ef3b9f9067b09a8b1222bbf6d1978426 --- src/org/lineageos/updater/UpdatesCheckReceiver.java | 10 +++++----- src/org/lineageos/updater/misc/Utils.java | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesCheckReceiver.java b/src/org/lineageos/updater/UpdatesCheckReceiver.java index 28fa7f32..abe5b33c 100644 --- a/src/org/lineageos/updater/UpdatesCheckReceiver.java +++ b/src/org/lineageos/updater/UpdatesCheckReceiver.java @@ -67,12 +67,12 @@ 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()) { + // Check if the current value is empty or null and set anon hash. + String anonHash = Settings.Secure.getString(context.getContentResolver(), + Settings.Secure.OTA_ANON_HASH); + if (anonHash == null || anonHash.isEmpty()) { Settings.Secure.putString(context.getContentResolver(), - Settings.Secure.E_LICENSE_ID, Utils.generateRandomID()); + Settings.Secure.OTA_ANON_HASH, Utils.generateRandomID()); } Utils.cleanupDownloadsDir(context); diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 086eb908..cc83ccd4 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -239,8 +239,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 anonHash = Settings.Secure.getString(context.getContentResolver(), + Settings.Secure.OTA_ANON_HASH); String serverUrl = SystemProperties.get(Constants.PROP_UPDATER_URI); if (retrieveStatus(context) != null && retrieveStatus(context).equals("true") @@ -252,8 +252,8 @@ public class Utils { serverUrl = context.getString(R.string.updater_server_url); } - if (eLicenseID != null && !eLicenseID.isEmpty()) { - serverUrl += "?license_id=" + eLicenseID; + if (anonHash != null && !anonHash.isEmpty()) { + serverUrl += "?ota_anon_hash=" + anonHash; } return serverUrl.replace("{device}", device) -- GitLab From 4d8e27f0713d4ea1f76bc7abc9211a8f532e1729 Mon Sep 17 00:00:00 2001 From: althafvly Date: Wed, 9 Aug 2023 20:26:36 +0530 Subject: [PATCH 2/2] Updater: Migrate old anon value Change-Id: I7ea81aab7cd4fc271901a7d856d08f6b3687ab2c --- src/org/lineageos/updater/UpdatesCheckReceiver.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/org/lineageos/updater/UpdatesCheckReceiver.java b/src/org/lineageos/updater/UpdatesCheckReceiver.java index abe5b33c..a6860e29 100644 --- a/src/org/lineageos/updater/UpdatesCheckReceiver.java +++ b/src/org/lineageos/updater/UpdatesCheckReceiver.java @@ -68,11 +68,14 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { 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 anon hash. + String eLicenseID = Settings.Secure.getString(context.getContentResolver(), + "e_license_id"); String anonHash = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.OTA_ANON_HASH); if (anonHash == null || anonHash.isEmpty()) { Settings.Secure.putString(context.getContentResolver(), - Settings.Secure.OTA_ANON_HASH, Utils.generateRandomID()); + Settings.Secure.OTA_ANON_HASH, (eLicenseID != null && + !eLicenseID.isEmpty()) ? eLicenseID : Utils.generateRandomID()); } Utils.cleanupDownloadsDir(context); -- GitLab