DivestOS/Patches/LineageOS-20.0/android_packages_apps_Settings/0011-Random_MAC.patch
Tad 9475615e77
A13 QPR2 Churn
Signed-off-by: Tad <tad@spotco.us>
2023-03-19 20:52:48 -04:00

146 lines
6.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: renlord <me@renlord.com>
Date: Fri, 15 Oct 2021 20:02:51 +0530
Subject: [PATCH] add option to always randomize MAC RANDOMIZATION_ALWAYS is
set as the default option
---
res/layout/wifi_network_config.xml | 2 +-
res/values/arrays.xml | 7 +++++
res/xml/wifi_network_details_fragment2.xml | 2 +-
.../WifiDetailPreferenceController2.java | 2 +-
.../WifiPrivacyPreferenceController2.java | 28 +++++++++++++++----
5 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/res/layout/wifi_network_config.xml b/res/layout/wifi_network_config.xml
index f91f7385c1..c0907b19ee 100644
--- a/res/layout/wifi_network_config.xml
+++ b/res/layout/wifi_network_config.xml
@@ -675,7 +675,7 @@
android:layout_height="wrap_content"
style="@style/wifi_item_spinner"
android:prompt="@string/wifi_privacy_settings"
- android:entries="@array/wifi_privacy_entries"/>
+ android:entries="@array/wifi_privacy_entries_extended"/>
</LinearLayout>
<LinearLayout
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index bb5fdd8762..b061e1c3d4 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1412,6 +1412,12 @@
<item>Treat as unmetered</item>
</string-array>
+ <string-array name="wifi_privacy_entries_extended">
+ <item>Use per-connection randomized MAC (default)</item>
+ <item>Use per-network randomized MAC</item>
+ <item>Use device MAC</item>
+ </string-array>
+
<string-array name="wifi_privacy_entries">
<item>Use randomized MAC (default)</item>
<item>Use device MAC</item>
@@ -1429,6 +1435,7 @@
</string-array>
<string-array name="wifi_privacy_values" translatable="false">
+ <item>100</item>
<item>1</item>
<item>0</item>
</string-array>
diff --git a/res/xml/wifi_network_details_fragment2.xml b/res/xml/wifi_network_details_fragment2.xml
index eb9add14f6..2079ef1675 100644
--- a/res/xml/wifi_network_details_fragment2.xml
+++ b/res/xml/wifi_network_details_fragment2.xml
@@ -69,7 +69,7 @@
android:key="privacy"
android:icon="@drawable/ic_wifi_privacy_24dp"
android:title="@string/wifi_privacy_settings"
- android:entries="@array/wifi_privacy_entries"
+ android:entries="@array/wifi_privacy_entries_extended"
android:entryValues="@array/wifi_privacy_values"/>
<Preference
diff --git a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
index f7fc07a90b..c967377727 100644
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
@@ -787,7 +787,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
}
private int getMacAddressTitle() {
- if (mWifiEntry.getPrivacy() == WifiEntry.PRIVACY_RANDOMIZED_MAC) {
+ if (mWifiEntry.getPrivacy() != WifiEntry.PRIVACY_DEVICE_MAC) {
return mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED
? R.string.wifi_advanced_randomized_mac_address_title
: R.string.wifi_advanced_randomized_mac_address_disconnected_title;
diff --git a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
index 632a5624c4..d695b8a825 100644
--- a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
@@ -41,6 +41,10 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
private WifiEntry mWifiEntry;
private Preference mPreference;
+ private static final int PREF_RANDOMIZATION_ALWAYS = 0;
+ private static final int PREF_RANDOMIZATION_PERSISTENT = 1;
+ private static final int PREF_RANDOMIZATION_NONE = 2;
+
public WifiPrivacyPreferenceController2(Context context) {
super(context, KEY_WIFI_PRIVACY);
@@ -98,8 +102,6 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
return mWifiEntry.getPrivacy();
}
- private static final int PREF_RANDOMIZATION_PERSISTENT = 0;
- private static final int PREF_RANDOMIZATION_NONE = 1;
/**
* Returns preference index value.
@@ -108,8 +110,14 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
* @return index value of preference
*/
public static int translateMacRandomizedValueToPrefValue(int macRandomized) {
- return (macRandomized == WifiEntry.PRIVACY_RANDOMIZED_MAC)
- ? PREF_RANDOMIZATION_PERSISTENT : PREF_RANDOMIZATION_NONE;
+ switch (macRandomized) {
+ case WifiEntry.PRIVACY_RANDOMIZED_MAC:
+ return PREF_RANDOMIZATION_PERSISTENT;
+ case WifiEntry.PRIVACY_DEVICE_MAC:
+ return PREF_RANDOMIZATION_NONE;
+ default:
+ return PREF_RANDOMIZATION_ALWAYS;
+ }
}
/**
@@ -119,8 +127,14 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
* @return mac randomized value
*/
public static int translatePrefValueToMacRandomizedValue(int prefMacRandomized) {
- return (prefMacRandomized == PREF_RANDOMIZATION_PERSISTENT)
- ? WifiEntry.PRIVACY_RANDOMIZED_MAC : WifiEntry.PRIVACY_DEVICE_MAC;
+ switch (prefMacRandomized) {
+ case PREF_RANDOMIZATION_PERSISTENT:
+ return WifiEntry.PRIVACY_RANDOMIZED_MAC;
+ case PREF_RANDOMIZATION_NONE:
+ return WifiEntry.PRIVACY_DEVICE_MAC;
+ default:
+ return WifiEntry.PRIVACY_RANDOMIZATION_ALWAYS;
+ }
}
private void updateSummary(ListPreference preference, int macRandomized) {
@@ -150,6 +164,8 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
return WifiEntry.PRIVACY_DEVICE_MAC;
case WifiConfiguration.RANDOMIZATION_PERSISTENT:
return WifiEntry.PRIVACY_RANDOMIZED_MAC;
+ case WifiConfiguration.RANDOMIZATION_ALWAYS:
+ return WifiEntry.PRIVACY_RANDOMIZATION_ALWAYS;
default:
return WifiEntry.PRIVACY_UNKNOWN;
}