Refine Wi-Fi privacy settings
- When changing two configurations, the configuration must be refreshed before modifying the second configuration to prevent the first configuration from being rolled back by the old configuration. Fix: 360313149 Flag: EXEMPT bugfix Test: Manual testing atest -c WifiPrivacyPageProviderTest Change-Id: If0e2c2b6a708fa59929b23409aff1254c6566fef
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settings.wifi.details2
|
package com.android.settings.wifi.details2
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.wifi.WifiConfiguration
|
|
||||||
import android.net.wifi.WifiManager
|
import android.net.wifi.WifiManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
@@ -114,19 +113,19 @@ fun WifiPrivacyPage(wifiEntry: WifiEntry) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
wifiEntry.wifiConfiguration?.let {
|
wifiEntry.wifiConfiguration?.let {
|
||||||
DeviceNameSwitchPreference(it)
|
DeviceNameSwitchPreference(wifiEntry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DeviceNameSwitchPreference(wifiConfiguration: WifiConfiguration){
|
fun DeviceNameSwitchPreference(wifiEntry: WifiEntry) {
|
||||||
Spacer(modifier = Modifier.width(SettingsDimension.itemDividerHeight))
|
Spacer(modifier = Modifier.width(SettingsDimension.itemDividerHeight))
|
||||||
CategoryTitle(title = stringResource(R.string.wifi_privacy_device_name_settings))
|
CategoryTitle(title = stringResource(R.string.wifi_privacy_device_name_settings))
|
||||||
Spacer(modifier = Modifier.width(SettingsDimension.itemDividerHeight))
|
Spacer(modifier = Modifier.width(SettingsDimension.itemDividerHeight))
|
||||||
var checked by remember {
|
var checked by remember {
|
||||||
mutableStateOf(wifiConfiguration.isSendDhcpHostnameEnabled)
|
mutableStateOf(wifiEntry.wifiConfiguration?.isSendDhcpHostnameEnabled)
|
||||||
}
|
}
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val wifiManager = context.getSystemService(WifiManager::class.java)!!
|
val wifiManager = context.getSystemService(WifiManager::class.java)!!
|
||||||
@@ -143,9 +142,11 @@ fun DeviceNameSwitchPreference(wifiConfiguration: WifiConfiguration){
|
|||||||
}
|
}
|
||||||
override val checked = { checked }
|
override val checked = { checked }
|
||||||
override val onCheckedChange: (Boolean) -> Unit = { newChecked ->
|
override val onCheckedChange: (Boolean) -> Unit = { newChecked ->
|
||||||
wifiConfiguration.isSendDhcpHostnameEnabled = newChecked
|
wifiEntry.wifiConfiguration?.let {
|
||||||
wifiManager.save(wifiConfiguration, null /* listener */)
|
it.isSendDhcpHostnameEnabled = newChecked
|
||||||
checked = newChecked
|
wifiManager.save(it, null /* listener */)
|
||||||
|
checked = newChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user