mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-24 05:04:50 -04:00
Add documentation to the code.
This commit is contained in:
parent
dc425c2199
commit
c8e975f8ed
@ -1,5 +1,10 @@
|
|||||||
package org.kiwix.kiwixmobile.wifi_hotspot;
|
package org.kiwix.kiwixmobile.wifi_hotspot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WIFI_AP_STATE_ENUMS class is used to get current state of the wifi access point using enums.
|
||||||
|
* Created by Adeel Zafar on 28/5/2019.
|
||||||
|
*/
|
||||||
|
|
||||||
public enum WIFI_AP_STATE_ENUMS {
|
public enum WIFI_AP_STATE_ENUMS {
|
||||||
WIFI_AP_STATE_DISABLING, WIFI_AP_STATE_DISABLED, WIFI_AP_STATE_ENABLING, WIFI_AP_STATE_ENABLED, WIFI_AP_STATE_FAILED
|
WIFI_AP_STATE_DISABLING, WIFI_AP_STATE_DISABLED, WIFI_AP_STATE_ENABLING, WIFI_AP_STATE_ENABLED, WIFI_AP_STATE_FAILED
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,12 @@ import android.provider.Settings;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WifiHotstopManager class makes use of the Android's WifiManager and WifiConfiguration class
|
||||||
|
* to implement the wifi hotspot feature.
|
||||||
|
* Created by Adeel Zafar on 28/5/2019.
|
||||||
|
*/
|
||||||
|
|
||||||
public class WifiHotspotManager {
|
public class WifiHotspotManager {
|
||||||
private final WifiManager wifiManager;
|
private final WifiManager wifiManager;
|
||||||
private Context context;
|
private Context context;
|
||||||
@ -19,6 +25,7 @@ public class WifiHotspotManager {
|
|||||||
wifiManager = (WifiManager) this.context.getSystemService(Context.WIFI_SERVICE);
|
wifiManager = (WifiManager) this.context.getSystemService(Context.WIFI_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//To get write permission settings, we use this method.
|
||||||
public void showWritePermissionSettings(boolean force) {
|
public void showWritePermissionSettings(boolean force) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
if (force || !Settings.System.canWrite(this.context)) {
|
if (force || !Settings.System.canWrite(this.context)) {
|
||||||
@ -32,7 +39,7 @@ public class WifiHotspotManager {
|
|||||||
|
|
||||||
public boolean setWifiEnabled(WifiConfiguration wifiConfig, boolean enabled) {
|
public boolean setWifiEnabled(WifiConfiguration wifiConfig, boolean enabled) {
|
||||||
try {
|
try {
|
||||||
if (enabled) {
|
if (enabled) { //disables wifi hotspot if it's already enabled
|
||||||
wifiManager.setWifiEnabled(false);
|
wifiManager.setWifiEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,6 +52,7 @@ public class WifiHotspotManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This method returns the current state of the Wifi access point
|
||||||
public WIFI_AP_STATE_ENUMS getWifiApState() {
|
public WIFI_AP_STATE_ENUMS getWifiApState() {
|
||||||
try {
|
try {
|
||||||
Method method = wifiManager.getClass().getMethod("getWifiApState");
|
Method method = wifiManager.getClass().getMethod("getWifiApState");
|
||||||
@ -63,10 +71,12 @@ public class WifiHotspotManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//This method returns if wifi access point is enabled or not
|
||||||
public boolean isWifiApEnabled() {
|
public boolean isWifiApEnabled() {
|
||||||
return getWifiApState() == WIFI_AP_STATE_ENUMS.WIFI_AP_STATE_ENABLED;
|
return getWifiApState() == WIFI_AP_STATE_ENUMS.WIFI_AP_STATE_ENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//This method is to get the wifi ap configuration
|
||||||
public WifiConfiguration getWifiApConfiguration() {
|
public WifiConfiguration getWifiApConfiguration() {
|
||||||
try {
|
try {
|
||||||
Method method = wifiManager.getClass().getMethod("getWifiApConfiguration");
|
Method method = wifiManager.getClass().getMethod("getWifiApConfiguration");
|
||||||
@ -77,6 +87,7 @@ public class WifiHotspotManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//This method is to set the wifi ap configuration
|
||||||
public boolean setWifiApConfiguration(WifiConfiguration wifiConfig) {
|
public boolean setWifiApConfiguration(WifiConfiguration wifiConfig) {
|
||||||
try {
|
try {
|
||||||
Method method =
|
Method method =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user