Update ACTION_WIFI_P2P_PERSISTENT_GROUPS_CHANGED

This commit is contained in:
Mygod
2020-06-14 08:07:46 +08:00
parent bf79573b27
commit 3c012cf948
3 changed files with 8 additions and 4 deletions

View File

@@ -170,7 +170,7 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene
lastMac = device.deviceAddress
}
}
WifiP2pManagerHelper.WIFI_P2P_PERSISTENT_GROUPS_CHANGED_ACTION -> if (!safeMode) onPersistentGroupsChanged()
WifiP2pManagerHelper.ACTION_WIFI_P2P_PERSISTENT_GROUPS_CHANGED -> if (!safeMode) onPersistentGroupsChanged()
}
}
/**
@@ -203,7 +203,7 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene
super.onCreate()
onChannelDisconnected()
registerReceiver(deviceListener, intentFilter(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION,
WifiP2pManagerHelper.WIFI_P2P_PERSISTENT_GROUPS_CHANGED_ACTION))
WifiP2pManagerHelper.ACTION_WIFI_P2P_PERSISTENT_GROUPS_CHANGED))
app.pref.registerOnSharedPreferenceChangeListener(this)
}

View File

@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.net.wifi.WpsInfo
import android.net.wifi.p2p.WifiP2pGroup
import android.net.wifi.p2p.WifiP2pManager
import android.os.Build
import be.mygod.vpnhotspot.App.Companion.app
import be.mygod.vpnhotspot.util.callSuper
import timber.log.Timber
@@ -13,7 +14,9 @@ import java.lang.reflect.Proxy
object WifiP2pManagerHelper {
const val UNSUPPORTED = -2
const val WIFI_P2P_PERSISTENT_GROUPS_CHANGED_ACTION = "android.net.wifi.p2p.PERSISTENT_GROUPS_CHANGED"
val ACTION_WIFI_P2P_PERSISTENT_GROUPS_CHANGED = if (Build.VERSION.SDK_INT >= 30) {
"android.net.wifi.p2p.action.WIFI_P2P_PERSISTENT_GROUPS_CHANGED"
} else "android.net.wifi.p2p.PERSISTENT_GROUPS_CHANGED"
/**
* Available since Android 4.4.