mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-09-08 10:32:42 +00:00
107 lines
4.8 KiB
Diff
107 lines
4.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Renlord <me@renlord.com>
|
|
Date: Sun, 8 Dec 2019 23:58:24 +0100
|
|
Subject: [PATCH] add option to always randomize MAC
|
|
|
|
RANDOMIZATION_ALWAYS is set as the default option
|
|
---
|
|
res/values/arrays.xml | 4 ++-
|
|
.../WifiDetailPreferenceController.java | 3 +-
|
|
.../WifiPrivacyPreferenceController.java | 31 ++++++++++++++-----
|
|
3 files changed, 29 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
|
|
index 0a9a9a31e8..6d95bcc58b 100644
|
|
--- a/res/values/arrays.xml
|
|
+++ b/res/values/arrays.xml
|
|
@@ -1239,7 +1239,8 @@
|
|
</string-array>
|
|
|
|
<string-array name="wifi_privacy_entries">
|
|
- <item>Use randomized MAC (default)</item>
|
|
+ <item>Use fully randomized MAC (default)</item>
|
|
+ <item>Use per-network randomized MAC</item>
|
|
<item>Use device MAC</item>
|
|
</string-array>
|
|
|
|
@@ -1255,6 +1256,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/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
|
|
index afcf883fb6..ce45108f22 100644
|
|
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
|
|
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
|
|
@@ -700,7 +700,8 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
|
|
|
// return randomized MAC address
|
|
if (mWifiConfig != null &&
|
|
- mWifiConfig.macRandomizationSetting == WifiConfiguration.RANDOMIZATION_PERSISTENT) {
|
|
+ (mWifiConfig.macRandomizationSetting == WifiConfiguration.RANDOMIZATION_PERSISTENT
|
|
+ || mWifiConfig.macRandomizationSetting == WifiConfiguration.RANDOMIZATION_ALWAYS)) {
|
|
return mWifiConfig.getRandomizedMacAddress().toString();
|
|
}
|
|
|
|
diff --git a/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java b/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
|
|
index 950cc131f4..1ed9646a7f 100644
|
|
--- a/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
|
|
+++ b/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
|
|
@@ -112,11 +112,12 @@ public class WifiPrivacyPreferenceController extends BasePreferenceController im
|
|
if (mWifiConfiguration != null) {
|
|
return mWifiConfiguration.macRandomizationSetting;
|
|
}
|
|
- return WifiConfiguration.RANDOMIZATION_PERSISTENT;
|
|
+ return WifiConfiguration.RANDOMIZATION_ALWAYS;
|
|
}
|
|
|
|
- private static final int PREF_RANDOMIZATION_PERSISTENT = 0;
|
|
- private static final int PREF_RANDOMIZATION_NONE = 1;
|
|
+ private static final int PREF_RANDOMIZATION_ALWAYS = 0;
|
|
+ private static final int PREF_RANDOMIZATION_PERSISTENT = 1;
|
|
+ private static final int PREF_RANDOMIZATION_NONE = 2;
|
|
|
|
/**
|
|
* Returns preference index value.
|
|
@@ -125,8 +126,16 @@ public class WifiPrivacyPreferenceController extends BasePreferenceController im
|
|
* @return index value of preference
|
|
*/
|
|
public static int translateMacRandomizedValueToPrefValue(int macRandomized) {
|
|
- return (macRandomized == WifiConfiguration.RANDOMIZATION_PERSISTENT)
|
|
- ? PREF_RANDOMIZATION_PERSISTENT : PREF_RANDOMIZATION_NONE;
|
|
+ switch (macRandomized) {
|
|
+ case WifiConfiguration.RANDOMIZATION_ALWAYS:
|
|
+ return PREF_RANDOMIZATION_ALWAYS;
|
|
+ case WifiConfiguration.RANDOMIZATION_PERSISTENT:
|
|
+ return PREF_RANDOMIZATION_PERSISTENT;
|
|
+ case WifiConfiguration.RANDOMIZATION_NONE:
|
|
+ return PREF_RANDOMIZATION_NONE;
|
|
+ default:
|
|
+ return PREF_RANDOMIZATION_ALWAYS;
|
|
+ }
|
|
}
|
|
|
|
/**
|
|
@@ -136,8 +145,16 @@ public class WifiPrivacyPreferenceController extends BasePreferenceController im
|
|
* @return mac randomized value
|
|
*/
|
|
public static int translatePrefValueToMacRandomizedValue(int prefMacRandomized) {
|
|
- return (prefMacRandomized == PREF_RANDOMIZATION_PERSISTENT)
|
|
- ? WifiConfiguration.RANDOMIZATION_PERSISTENT : WifiConfiguration.RANDOMIZATION_NONE;
|
|
+ switch (prefMacRandomized) {
|
|
+ case PREF_RANDOMIZATION_ALWAYS:
|
|
+ return WifiConfiguration.RANDOMIZATION_ALWAYS;
|
|
+ case PREF_RANDOMIZATION_PERSISTENT:
|
|
+ return WifiConfiguration.RANDOMIZATION_PERSISTENT;
|
|
+ case PREF_RANDOMIZATION_NONE:
|
|
+ return WifiConfiguration.RANDOMIZATION_NONE;
|
|
+ default:
|
|
+ return WifiConfiguration.RANDOMIZATION_ALWAYS;
|
|
+ }
|
|
}
|
|
|
|
private void updateSummary(DropDownPreference preference, int macRandomized) {
|