Some fixes for setting platform ap config
This commit is contained in:
@@ -238,36 +238,51 @@ class TetheringFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClick
|
|||||||
AlertDialogFragment.setResultListener<WifiApDialogFragment, WifiApDialogFragment.Arg>(this) { which, ret ->
|
AlertDialogFragment.setResultListener<WifiApDialogFragment, WifiApDialogFragment.Arg>(this) { which, ret ->
|
||||||
if (which == DialogInterface.BUTTON_POSITIVE) GlobalScope.launch {
|
if (which == DialogInterface.BUTTON_POSITIVE) GlobalScope.launch {
|
||||||
val configuration = ret!!.configuration
|
val configuration = ret!!.configuration
|
||||||
@Suppress("DEPRECATION")
|
if (Build.VERSION.SDK_INT < 30) @Suppress("DEPRECATION") {
|
||||||
if (Build.VERSION.SDK_INT < 30 &&
|
if (configuration.isAutoShutdownEnabled != TetherTimeoutMonitor.enabled) try {
|
||||||
configuration.isAutoShutdownEnabled != TetherTimeoutMonitor.enabled) try {
|
|
||||||
TetherTimeoutMonitor.setEnabled(configuration.isAutoShutdownEnabled)
|
TetherTimeoutMonitor.setEnabled(configuration.isAutoShutdownEnabled)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.w(e)
|
Timber.w(e)
|
||||||
SmartSnackbar.make(e).show()
|
SmartSnackbar.make(e).show()
|
||||||
}
|
}
|
||||||
val success = try {
|
val wc = configuration.toWifiConfiguration()
|
||||||
if (Build.VERSION.SDK_INT < 30) @Suppress("DEPRECATION") {
|
try {
|
||||||
WifiApManager.setConfiguration(configuration.toWifiConfiguration())
|
if (WifiApManager.setConfiguration(wc)) return@launch
|
||||||
} else WifiApManager.setConfiguration(configuration.toPlatform())
|
|
||||||
} catch (e: InvocationTargetException) {
|
} catch (e: InvocationTargetException) {
|
||||||
try {
|
try {
|
||||||
if (Build.VERSION.SDK_INT < 30) @Suppress("DEPRECATION") {
|
if (RootManager.use { it.execute(WifiApCommands.SetConfigurationLegacy(wc)) }
|
||||||
val wc = configuration.toWifiConfiguration()
|
.value) return@launch
|
||||||
RootManager.use { it.execute(WifiApCommands.SetConfigurationLegacy(wc)) }
|
} catch (e: CancellationException) {
|
||||||
} else {
|
return@launch SmartSnackbar.make(e).show()
|
||||||
val platform = configuration.toPlatform()
|
|
||||||
RootManager.use { it.execute(WifiApCommands.SetConfiguration(platform)) }
|
|
||||||
}
|
|
||||||
} catch (_: CancellationException) {
|
|
||||||
} catch (eRoot: Exception) {
|
} catch (eRoot: Exception) {
|
||||||
eRoot.addSuppressed(e)
|
eRoot.addSuppressed(e)
|
||||||
Timber.w(eRoot)
|
Timber.w(eRoot)
|
||||||
SmartSnackbar.make(eRoot).show()
|
return@launch SmartSnackbar.make(eRoot).show()
|
||||||
null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (success == false) SmartSnackbar.make(R.string.configuration_rejected).show()
|
} else {
|
||||||
|
val platform = try {
|
||||||
|
configuration.toPlatform()
|
||||||
|
} catch (e: InvocationTargetException) {
|
||||||
|
Timber.w(e)
|
||||||
|
return@launch SmartSnackbar.make(e).show()
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (WifiApManager.setConfiguration(platform)) return@launch
|
||||||
|
} catch (e: InvocationTargetException) {
|
||||||
|
try {
|
||||||
|
if (RootManager.use { it.execute(WifiApCommands.SetConfiguration(platform)) }
|
||||||
|
.value) return@launch
|
||||||
|
} catch (e: CancellationException) {
|
||||||
|
return@launch SmartSnackbar.make(e).show()
|
||||||
|
} catch (eRoot: Exception) {
|
||||||
|
eRoot.addSuppressed(e)
|
||||||
|
Timber.w(eRoot)
|
||||||
|
return@launch SmartSnackbar.make(eRoot).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SmartSnackbar.make(R.string.configuration_rejected).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding = FragmentTetheringBinding.inflate(inflater, container, false)
|
binding = FragmentTetheringBinding.inflate(inflater, container, false)
|
||||||
|
|||||||
Reference in New Issue
Block a user