Reformat WifiHotspotManager

This commit is contained in:
Adeel Zafar 2019-08-15 16:47:27 +05:00
parent 008818161d
commit 228b8aceb5

View File

@ -32,42 +32,42 @@ public class WifiHotspotManager {
//Workaround to turn on hotspot for Oreo versions //Workaround to turn on hotspot for Oreo versions
@RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O)
public void turnOnHotspot(@NonNull ServerStateListener serverStateListener) { public void turnOnHotspot(@NonNull ServerStateListener serverStateListener) {
wifiManager.startLocalOnlyHotspot(new WifiManager.LocalOnlyHotspotCallback() { wifiManager.startLocalOnlyHotspot(new WifiManager.LocalOnlyHotspotCallback() {
@Override @Override
public void onStarted(WifiManager.LocalOnlyHotspotReservation reservation) { public void onStarted(WifiManager.LocalOnlyHotspotReservation reservation) {
super.onStarted(reservation); super.onStarted(reservation);
hotspotReservation = reservation; hotspotReservation = reservation;
currentConfig = hotspotReservation.getWifiConfiguration(); currentConfig = hotspotReservation.getWifiConfiguration();
Log.v(TAG, "THE PASSWORD IS: " Log.v(TAG, "THE PASSWORD IS: "
+ currentConfig.preSharedKey + currentConfig.preSharedKey
+ " \n SSID is : " + " \n SSID is : "
+ currentConfig.SSID); + currentConfig.SSID);
serverStateListener.hotspotTurnedOn(currentConfig); serverStateListener.hotspotTurnedOn(currentConfig);
isHotspotEnabled = true; isHotspotEnabled = true;
Log.v(TAG, "Is hotspot enabled? " + isHotspotEnabled); Log.v(TAG, "Is hotspot enabled? " + isHotspotEnabled);
} }
@Override @Override
public void onStopped() { public void onStopped() {
super.onStopped(); super.onStopped();
Log.v(TAG, "Local Hotspot Stopped"); Log.v(TAG, "Local Hotspot Stopped");
serverStateListener.serverStopped(); serverStateListener.serverStopped();
} }
@Override @Override
public void onFailed(int reason) { public void onFailed(int reason) {
super.onFailed(reason); super.onFailed(reason);
Log.v(TAG, "Local Hotspot failed to start"); Log.v(TAG, "Local Hotspot failed to start");
serverStateListener.hotspotFailed(); serverStateListener.hotspotFailed();
isHotspotEnabled = false; isHotspotEnabled = false;
Log.v(TAG, "Is hotspot enabled? " + isHotspotEnabled); Log.v(TAG, "Is hotspot enabled? " + isHotspotEnabled);
} }
}, new Handler()); }, new Handler());
} }
//Workaround to turn off hotspot for Oreo versions //Workaround to turn off hotspot for Oreo versions