mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-15 02:44:23 -05:00
11b9ae5bc4
Signed-off-by: Tad <tad@spotco.us>
146 lines
6.5 KiB
Diff
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_dialog.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_dialog.xml b/res/layout/wifi_dialog.xml
|
|
index 8111d3aaa9..de57fb3525 100644
|
|
--- a/res/layout/wifi_dialog.xml
|
|
+++ b/res/layout/wifi_dialog.xml
|
|
@@ -694,7 +694,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 abecdd1a40..f50d130936 100644
|
|
--- a/res/values/arrays.xml
|
|
+++ b/res/values/arrays.xml
|
|
@@ -1397,6 +1397,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>
|
|
@@ -1414,6 +1420,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 1c4fe9147a..191b4f80ae 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 f9d0db07b2..5f46d9b71e 100644
|
|
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
|
|
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
|
|
@@ -799,7 +799,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 c484922564..d0b98b6086 100644
|
|
--- a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
|
|
+++ b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
|
|
@@ -42,6 +42,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);
|
|
|
|
@@ -99,8 +103,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.
|
|
@@ -109,8 +111,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;
|
|
+ }
|
|
}
|
|
|
|
/**
|
|
@@ -120,8 +128,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(DropDownPreference preference, int macRandomized) {
|
|
@@ -151,6 +165,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;
|
|
}
|