mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-23 04:33:54 -04:00
Injected wifi-p2p-manager
This commit is contained in:
parent
03ee5065d0
commit
6935fa6141
2
.github/workflows/coverage.yml
vendored
2
.github/workflows/coverage.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
|||||||
coverageReport:
|
coverageReport:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
api-level: [21, 21]
|
api-level: [21, 27, 27, 21]
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
runs-on: macOS-latest
|
runs-on: macOS-latest
|
||||||
steps:
|
steps:
|
||||||
|
@ -21,14 +21,15 @@ package org.kiwix.kiwixmobile.di.modules
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.location.LocationManager
|
import android.location.LocationManager
|
||||||
import android.net.wifi.WifiManager
|
import android.net.wifi.WifiManager
|
||||||
|
import android.net.wifi.p2p.WifiP2pManager
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||||
|
import org.kiwix.kiwixmobile.core.zim_manager.MountPointProducer
|
||||||
import org.kiwix.kiwixmobile.di.KiwixScope
|
import org.kiwix.kiwixmobile.di.KiwixScope
|
||||||
import org.kiwix.kiwixmobile.zim_manager.Fat32Checker
|
import org.kiwix.kiwixmobile.zim_manager.Fat32Checker
|
||||||
import org.kiwix.kiwixmobile.zim_manager.FileWritingFileSystemChecker
|
import org.kiwix.kiwixmobile.zim_manager.FileWritingFileSystemChecker
|
||||||
import org.kiwix.kiwixmobile.zim_manager.MountFileSystemChecker
|
import org.kiwix.kiwixmobile.zim_manager.MountFileSystemChecker
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.MountPointProducer
|
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
object KiwixModule {
|
object KiwixModule {
|
||||||
@ -52,4 +53,9 @@ object KiwixModule {
|
|||||||
sharedPreferenceUtil,
|
sharedPreferenceUtil,
|
||||||
listOf(MountFileSystemChecker(mountPointProducer), FileWritingFileSystemChecker())
|
listOf(MountFileSystemChecker(mountPointProducer), FileWritingFileSystemChecker())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@KiwixScope
|
||||||
|
fun providesWiFiP2pManager(context: Context): WifiP2pManager =
|
||||||
|
context.getSystemService(Context.WIFI_P2P_SERVICE) as WifiP2pManager
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,11 @@ package org.kiwix.kiwixmobile.di.modules
|
|||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.app.Service
|
import android.app.Service
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.net.wifi.p2p.WifiP2pManager
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import org.kiwix.kiwixlib.Library
|
|
||||||
import org.kiwix.kiwixlib.JNIKiwixServer
|
import org.kiwix.kiwixlib.JNIKiwixServer
|
||||||
|
import org.kiwix.kiwixlib.Library
|
||||||
import org.kiwix.kiwixmobile.di.ServiceScope
|
import org.kiwix.kiwixmobile.di.ServiceScope
|
||||||
import org.kiwix.kiwixmobile.webserver.WebServerHelper
|
import org.kiwix.kiwixmobile.webserver.WebServerHelper
|
||||||
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotNotificationManager
|
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotNotificationManager
|
||||||
|
@ -19,7 +19,6 @@ package org.kiwix.kiwixmobile.localFileTransfer
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.net.wifi.WpsInfo
|
import android.net.wifi.WpsInfo
|
||||||
@ -61,7 +60,8 @@ import javax.inject.Inject
|
|||||||
class WifiDirectManager @Inject constructor(
|
class WifiDirectManager @Inject constructor(
|
||||||
private val activity: Activity,
|
private val activity: Activity,
|
||||||
private val sharedPreferenceUtil: SharedPreferenceUtil,
|
private val sharedPreferenceUtil: SharedPreferenceUtil,
|
||||||
private val alertDialogShower: AlertDialogShower
|
private val alertDialogShower: AlertDialogShower,
|
||||||
|
private val manager: WifiP2pManager
|
||||||
) : ChannelListener, PeerListListener, ConnectionInfoListener, P2pEventListener {
|
) : ChannelListener, PeerListListener, ConnectionInfoListener, P2pEventListener {
|
||||||
var callbacks: Callbacks? = null
|
var callbacks: Callbacks? = null
|
||||||
|
|
||||||
@ -74,12 +74,14 @@ class WifiDirectManager @Inject constructor(
|
|||||||
// Whether channel has retried connecting previously
|
// Whether channel has retried connecting previously
|
||||||
private var shouldRetry = true
|
private var shouldRetry = true
|
||||||
|
|
||||||
|
// @Inject
|
||||||
|
// lateinit var manager: WifiP2pManager
|
||||||
// Overall manager of Wifi p2p connections for the module
|
// Overall manager of Wifi p2p connections for the module
|
||||||
// Initialize as Nullable WifiP2pManager to counter Kt. TypeCastException on API 27;
|
// Initialize as Nullable WifiP2pManager to counter Kt. TypeCastException on API 27;
|
||||||
// See: https://github.com/kiwix/kiwix-android/issues/2488
|
// See: https://github.com/kiwix/kiwix-android/issues/2488
|
||||||
private val manager: WifiP2pManager? by lazy(LazyThreadSafetyMode.NONE) {
|
// private val manager: WifiP2pManager? by lazy(LazyThreadSafetyMode.NONE) {
|
||||||
activity.getSystemService(Context.WIFI_P2P_SERVICE) as WifiP2pManager?
|
// activity.getSystemService(Context.WIFI_P2P_SERVICE) as WifiP2pManager?
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Interface to the device's underlying wifi-p2p framework
|
// Interface to the device's underlying wifi-p2p framework
|
||||||
private var channel: Channel? = null
|
private var channel: Channel? = null
|
||||||
|
@ -26,8 +26,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import org.kiwix.kiwixlib.JNIKiwixException;
|
import org.kiwix.kiwixlib.JNIKiwixException;
|
||||||
import org.kiwix.kiwixlib.Library;
|
|
||||||
import org.kiwix.kiwixlib.JNIKiwixServer;
|
import org.kiwix.kiwixlib.JNIKiwixServer;
|
||||||
|
import org.kiwix.kiwixlib.Library;
|
||||||
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
|
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
|
||||||
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks;
|
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user