Android Open Source - ghetto-unlock Wifi Monitor






From Project

Back to project page ghetto-unlock.

License

The source code is released under:

Apache License

If you think the Android project ghetto-unlock listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.nick.ghettounlock;
//from w ww  .j av a2s .  c o m
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.util.Log;

public class WifiMonitor extends BroadcastReceiver {

    private static final String TAG = WifiMonitor.class.getSimpleName();

    @Override
    public void onReceive(Context context, Intent intent) {
        if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
            NetworkInfo netInfo = (NetworkInfo) intent
                    .getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
            Log.d(TAG, "NetworkInfo: " + netInfo);
            if (netInfo.getState() == NetworkInfo.State.CONNECTED) {
                WifiInfo wifiInfo = (WifiInfo) intent
                        .getParcelableExtra(WifiManager.EXTRA_WIFI_INFO);
                String ssid = wifiInfo.getSSID();
                String secureSsid = GhettoTrustAgent.getTrustedSsid(context);
                if (secureSsid == null) {
                    return;
                }

                if (secureSsid.equals(ssid)) {
                    Log.d(TAG, "Found secure SSID: " + ssid);
                    GhettoTrustAgent.sendGrantTrust(context, "GhettoTrustAgent::WiFi",
                            GhettoTrustAgentSettings.TRUST_DURATION_5MINS,
                            false);
                }
                else {
                    Log.d(TAG, "Found insecure SSID: " + ssid);
                    GhettoTrustAgent.sendRevokeTrust(context);
                }
            }
        } else {
            Log.d(TAG, "Disconnected from WiFi, revoking trust");
            GhettoTrustAgent.sendRevokeTrust(context);
        }
    }
}




Java Source Code List

org.nick.ghettounlock.GhettoApp.java
org.nick.ghettounlock.GhettoNfcUnlockHandler.java
org.nick.ghettounlock.GhettoTrustAgentSettings.java
org.nick.ghettounlock.GhettoTrustAgent.java
org.nick.ghettounlock.PowerMonitor.java
org.nick.ghettounlock.WifiMonitor.java
org.nick.ghettounlock.muscle.Hex.java
org.nick.ghettounlock.muscle.MuscleCard.java
org.nick.ghettounlock.muscle.MuscleException.java
org.nick.ghettounlock.muscle.ResponseApdu.java