// Path: app/src/main/java/wseemann/media/romote/model/ClientScanResult.java
// public class ClientScanResult {
//     private String IpAddr;
//     private String HWAddr;
//     private String Device;
//     private boolean isReachable;
// 
//     public ClientScanResult(String ipAddr, String hWAddr, String device, boolean isReachable) {
//         super();
//         this.IpAddr = ipAddr;
//         this.HWAddr = hWAddr;
//         this.Device = device;
//         this.isReachable = isReachable;
//     }
// 
//     public String getIpAddr() {
//         return IpAddr;
//     }
// 
//     public void setIpAddr(String ipAddr) {
//         IpAddr = ipAddr;
//     }
// 
//     public String getHWAddr() {
//         return HWAddr;
//     }
// 
//     public void setHWAddr(String hWAddr) {
//         HWAddr = hWAddr;
//     }
// 
//     public String getDevice() {
//         return Device;
//     }
// 
//     public void setDevice(String device) {
//         Device = device;
//     }
// 
//     public boolean isReachable() {
//         return isReachable;
//     }
// 
//     public void setReachable(boolean isReachable) {
//         this.isReachable = isReachable;
//     }
// }
// 
// Path: app/src/main/java/wseemann/media/romote/utils/Constants.java
// public enum WIFI_AP_STATE {
//     WIFI_AP_STATE_DISABLING,
//     WIFI_AP_STATE_DISABLED,
//     WIFI_AP_STATE_ENABLING,
//     WIFI_AP_STATE_ENABLED,
//     WIFI_AP_STATE_FAILED
// }


import android.util.Log;
import wseemann.media.romote.model.ClientScanResult;
import wseemann.media.romote.utils.Constants.WIFI_AP_STATE;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.util.ArrayList;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.provider.Settings;
/*
 * Copyright 2013 WhiteByte (Nick Russler, Ahmet Yueksektepe).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package wseemann.media.romote.utils;




public class WifiApManager {
    private final WifiManager mWifiManager;
    private Context context;

    public WifiApManager(Context context) {
        this.context = context;
        mWifiManager = (WifiManager) this.context.getSystemService(Context.WIFI_SERVICE);
    }

    /**
     * Show write permission settings page to user if necessary or forced
     * @param force show settings page even when rights are already granted
     */
    public void showWritePermissionSettings(boolean force) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (force || !Settings.System.canWrite(this.context)) {
                Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS);
                intent.setData(Uri.parse("package:" + this.context.getPackageName()));
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                this.context.startActivity(intent);
            }
        }
    }

    /**
     * Start AccessPoint mode with the specified
     * configuration. If the radio is already running in
     * AP mode, update the new configuration
     * Note that starting in access point mode disables station
     * mode operation
     *
     * @param wifiConfig SSID, security and channel details as part of WifiConfiguration
     * @return {@code true} if the operation succeeds, {@code false} otherwise
     */
    public boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {
        try {
            if (enabled) { // disable WiFi in any case
                mWifiManager.setWifiEnabled(false);
            }

            Method method = mWifiManager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class);
            return (Boolean) method.invoke(mWifiManager, wifiConfig, enabled);
        } catch (Exception e) {
            Log.e(this.getClass().toString(), "", e);
            return false;
        }
    }

    /**
     * Gets the Wi-Fi enabled state.
     *
     * @return {@link WIFI_AP_STATE}
     * @see #isWifiApEnabled()
     */
// Path: app/src/main/java/wseemann/media/romote/model/ClientScanResult.java
// public class ClientScanResult {
//     private String IpAddr;
//     private String HWAddr;
//     private String Device;
//     private boolean isReachable;
// 
//     public ClientScanResult(String ipAddr, String hWAddr, String device, boolean isReachable) {
//         super();
//         this.IpAddr = ipAddr;
//         this.HWAddr = hWAddr;
//         this.Device = device;
//         this.isReachable = isReachable;
//     }
// 
//     public String getIpAddr() {
//         return IpAddr;
//     }
// 
//     public void setIpAddr(String ipAddr) {
//         IpAddr = ipAddr;
//     }
// 
//     public String getHWAddr() {
//         return HWAddr;
//     }
// 
//     public void setHWAddr(String hWAddr) {
//         HWAddr = hWAddr;
//     }
// 
//     public String getDevice() {
//         return Device;
//     }
// 
//     public void setDevice(String device) {
//         Device = device;
//     }
// 
//     public boolean isReachable() {
//         return isReachable;
//     }
// 
//     public void setReachable(boolean isReachable) {
//         this.isReachable = isReachable;
//     }
// }
// 
// Path: app/src/main/java/wseemann/media/romote/utils/Constants.java
// public enum WIFI_AP_STATE {
//     WIFI_AP_STATE_DISABLING,
//     WIFI_AP_STATE_DISABLED,
//     WIFI_AP_STATE_ENABLING,
//     WIFI_AP_STATE_ENABLED,
//     WIFI_AP_STATE_FAILED
// }


// Path: app/src/main/java/wseemann/media/romote/utils/WifiApManager.java
import android.util.Log;
import wseemann.media.romote.model.ClientScanResult;
import wseemann.media.romote.utils.Constants.WIFI_AP_STATE;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.util.ArrayList;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.provider.Settings;

/*
 * Copyright 2013 WhiteByte (Nick Russler, Ahmet Yueksektepe).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package wseemann.media.romote.utils;




public class WifiApManager {
    private final WifiManager mWifiManager;
    private Context context;

    public WifiApManager(Context context) {
        this.context = context;
        mWifiManager = (WifiManager) this.context.getSystemService(Context.WIFI_SERVICE);
    }

    /**
     * Show write permission settings page to user if necessary or forced
     * @param force show settings page even when rights are already granted
     */
    public void showWritePermissionSettings(boolean force) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (force || !Settings.System.canWrite(this.context)) {
                Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS);
                intent.setData(Uri.parse("package:" + this.context.getPackageName()));
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                this.context.startActivity(intent);
            }
        }
    }

    /**
     * Start AccessPoint mode with the specified
     * configuration. If the radio is already running in
     * AP mode, update the new configuration
     * Note that starting in access point mode disables station
     * mode operation
     *
     * @param wifiConfig SSID, security and channel details as part of WifiConfiguration
     * @return {@code true} if the operation succeeds, {@code false} otherwise
     */
    public boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {
        try {
            if (enabled) { // disable WiFi in any case
                mWifiManager.setWifiEnabled(false);
            }

            Method method = mWifiManager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class);
            return (Boolean) method.invoke(mWifiManager, wifiConfig, enabled);
        } catch (Exception e) {
            Log.e(this.getClass().toString(), "", e);
            return false;
        }
    }

    /**
     * Gets the Wi-Fi enabled state.
     *
     * @return {@link WIFI_AP_STATE}
     * @see #isWifiApEnabled()
     */
    public WIFI_AP_STATE getWifiApState() {