Deprecate reset credentials

Due to persistent groups no longer useful in Android Q, this feature will be removed. Users on older releases can remove remembered groups from Wi-Fi Direct settings manually.
This commit is contained in:
Mygod
2019-04-04 13:08:00 +08:00
parent 926783cc25
commit 834498b1ff
6 changed files with 10 additions and 32 deletions

View File

@@ -95,18 +95,6 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
fun shutdown() {
if (active) removeGroup()
}
fun resetCredentials() {
val channel = channel
if (channel == null) SmartSnackbar.make(R.string.repeater_failure_disconnected).show()
else p2pManager.deletePersistentGroup(channel, (group ?: return).netId,
object : WifiP2pManager.ActionListener {
override fun onSuccess() = SmartSnackbar.make(R.string.repeater_reset_credentials_success)
.shortToast().show()
override fun onFailure(reason: Int) = SmartSnackbar.make(
formatReason(R.string.repeater_reset_credentials_failure, reason)).show()
})
}
}
private val p2pManager get() = RepeaterService.p2pManager!!

View File

@@ -168,18 +168,15 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic
}
}
fun onEditResult(which: Int, data: Intent?) {
when (which) {
DialogInterface.BUTTON_POSITIVE -> try {
val master = holder.config ?: return
val config = AlertDialogFragment.getRet<WifiP2pDialogFragment.Arg>(data!!).configuration
master.update(config.SSID, config.preSharedKey)
binder!!.group = null
} catch (e: Exception) {
Timber.w(e)
SmartSnackbar.make(e).show()
}
DialogInterface.BUTTON_NEUTRAL -> binder!!.resetCredentials()
fun onEditResult(data: Intent?) {
val master = holder.config ?: return
try {
val config = AlertDialogFragment.getRet<WifiP2pDialogFragment.Arg>(data!!).configuration
master.update(config.SSID, config.preSharedKey)
binder!!.group = null
} catch (e: Exception) {
Timber.w(e)
SmartSnackbar.make(e).show()
}
holder.config = null
}

View File

@@ -133,7 +133,7 @@ class TetheringFragment : Fragment(), ServiceConnection, MenuItem.OnMenuItemClic
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) = when (requestCode) {
REPEATER_WPS -> adapter.repeaterManager.onWpsResult(resultCode, data)
REPEATER_EDIT_CONFIGURATION -> adapter.repeaterManager.onEditResult(resultCode, data)
REPEATER_EDIT_CONFIGURATION -> adapter.repeaterManager.onEditResult(data)
else -> super.onActivityResult(requestCode, resultCode, data)
}

View File

@@ -48,7 +48,6 @@ class WifiP2pDialogFragment : AlertDialogFragment<WifiP2pDialogFragment.Arg, Wif
mPassword = mView.password
setPositiveButton(context.getString(R.string.wifi_save), listener)
setNegativeButton(context.getString(R.string.wifi_cancel), null)
setNeutralButton(context.getString(R.string.repeater_reset_credentials), listener)
mSsid.text = arg.configuration.SSID
mSsid.addTextChangedListener(this@WifiP2pDialogFragment)
mPassword.setText(arg.configuration.preSharedKey)