mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-14 10:24:32 -05:00
58923f2ef9
Signed-off-by: Tavi <tavi@divested.dev>
145 lines
6.3 KiB
Diff
145 lines
6.3 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 | 27 ++++++++++++++-----
|
|
5 files changed, 31 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/res/layout/wifi_network_config.xml b/res/layout/wifi_network_config.xml
|
|
index 3de1a38c3ea..52cc8cf9e74 100644
|
|
--- a/res/layout/wifi_network_config.xml
|
|
+++ b/res/layout/wifi_network_config.xml
|
|
@@ -707,7 +707,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 99f52b499c2..a0030084801 100644
|
|
--- a/res/values/arrays.xml
|
|
+++ b/res/values/arrays.xml
|
|
@@ -1192,6 +1192,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>
|
|
@@ -1209,6 +1215,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 598f9d86173..fa1fa6cab61 100644
|
|
--- a/res/xml/wifi_network_details_fragment2.xml
|
|
+++ b/res/xml/wifi_network_details_fragment2.xml
|
|
@@ -94,7 +94,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"/>
|
|
|
|
<com.android.settings.spa.preference.ComposePreference
|
|
diff --git a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
|
|
index b67c84832fb..e0c9ba89ab7 100644
|
|
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
|
|
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
|
|
@@ -747,7 +747,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 5d393e54a21..504ec1f9dd5 100644
|
|
--- a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
|
|
+++ b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
|
|
@@ -17,6 +17,7 @@
|
|
package com.android.settings.wifi.details2;
|
|
|
|
import android.content.Context;
|
|
+import android.net.wifi.WifiConfiguration;
|
|
import android.net.wifi.WifiManager;
|
|
|
|
import androidx.annotation.NonNull;
|
|
@@ -39,6 +40,10 @@ public class WifiPrivacyPreferenceController2 extends BasePreferenceController i
|
|
private final WifiManager mWifiManager;
|
|
private WifiEntry mWifiEntry;
|
|
|
|
+ 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);
|
|
|
|
@@ -94,8 +99,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.
|
|
@@ -104,8 +107,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;
|
|
+ }
|
|
}
|
|
|
|
/**
|
|
@@ -115,8 +124,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) {
|