Search in sources :

Example 26 with WifiManager

use of android.net.wifi.WifiManager in project carat by amplab.

the class SamplingLibrary method getWifiSignalStrength.

/* Get current WiFi signal Strength */
public static int getWifiSignalStrength(Context context) {
    WifiManager myWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo myWifiInfo = myWifiManager.getConnectionInfo();
    int wifiRssi = myWifiInfo.getRssi();
    // Log.v("WifiRssi", "Rssi:" + wifiRssi);
    return wifiRssi;
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiInfo(android.net.wifi.WifiInfo)

Example 27 with WifiManager

use of android.net.wifi.WifiManager in project carat by amplab.

the class SamplingLibrary method getWifiEnabled.

/* Check whether WiFi is enabled */
public static boolean getWifiEnabled(Context context) {
    boolean wifiEnabled = false;
    WifiManager myWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    wifiEnabled = myWifiManager.isWifiEnabled();
    // Log.v("WifiEnabled", "Wifi is enabled:" + wifiEnabled);
    return wifiEnabled;
}
Also used : WifiManager(android.net.wifi.WifiManager)

Example 28 with WifiManager

use of android.net.wifi.WifiManager in project android by cSploit.

the class System method init.

public static void init(Context context) throws Exception {
    mContext = context;
    try {
        Logger.debug("initializing System...");
        mStoragePath = getSettings().getString("PREF_SAVE_PATH", Environment.getExternalStorageDirectory().toString());
        mSessionName = "csploit-session-" + java.lang.System.currentTimeMillis();
        mKnownIssues = new KnownIssues();
        mPlugins = new ArrayList<>();
        mOpenPorts = new SparseIntArray(3);
        mServices = new HashMap<>();
        mPorts = new HashMap<>();
        // if we are here, network initialization didn't throw any error, lock wifi
        WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
        if (mWifiLock == null)
            mWifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, "wifiLock");
        if (!mWifiLock.isHeld())
            mWifiLock.acquire();
        // wake lock if enabled
        if (getSettings().getBoolean("PREF_WAKE_LOCK", true)) {
            PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
            if (mWakeLock == null)
                mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "wakeLock");
            if (!mWakeLock.isHeld())
                mWakeLock.acquire();
        }
        // set ports
        try {
            HTTP_PROXY_PORT = Integer.parseInt(getSettings().getString("PREF_HTTP_PROXY_PORT", "8080"));
            HTTP_SERVER_PORT = Integer.parseInt(getSettings().getString("PREF_HTTP_SERVER_PORT", "8081"));
            HTTPS_REDIR_PORT = Integer.parseInt(getSettings().getString("PREF_HTTPS_REDIRECTOR_PORT", "8082"));
            MSF_RPC_PORT = Integer.parseInt(getSettings().getString("MSF_RPC_PORT", "55553"));
        } catch (NumberFormatException e) {
            HTTP_PROXY_PORT = 8080;
            HTTP_SERVER_PORT = 8081;
            HTTPS_REDIR_PORT = 8082;
            MSF_RPC_PORT = 55553;
        }
        // initialize network data at the end
        uncaughtReloadNetworkMapping();
        if (isCoreInstalled())
            beginLoadServicesAndVendors();
    } catch (Exception e) {
        if (!(e instanceof NoRouteToHostException))
            errorLogging(e);
        throw e;
    }
}
Also used : PowerManager(android.os.PowerManager) WifiManager(android.net.wifi.WifiManager) SparseIntArray(android.util.SparseIntArray) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 29 with WifiManager

use of android.net.wifi.WifiManager in project AndroidTraining by mixi-inc.

the class DefaultModule method configure.

@SuppressWarnings("unchecked")
protected void configure() {
    bind(Application.class).toProvider(ApplicationProvider.class).in(ApplicationScoped.class);
    bind(Context.class).toProvider(ContextProvider.class);
    bind(Handler.class).toProvider(HandlerProvider.class).in(ApplicationScoped.class);
    bind(ActivityManager.class).toProvider(new SystemServiceProvider<ActivityManager>(Context.ACTIVITY_SERVICE));
    bind(AlarmManager.class).toProvider(new SystemServiceProvider<AlarmManager>(Context.ALARM_SERVICE));
    bind(AudioManager.class).toProvider(new SystemServiceProvider<AudioManager>(Context.AUDIO_SERVICE));
    bind(ConnectivityManager.class).toProvider(new SystemServiceProvider<ConnectivityManager>(Context.CONNECTIVITY_SERVICE));
    bind(InputMethodManager.class).toProvider(new SystemServiceProvider<InputMethodManager>(Context.INPUT_METHOD_SERVICE));
    bind(KeyguardManager.class).toProvider(new SystemServiceProvider<KeyguardManager>(Context.KEYGUARD_SERVICE));
    bind(LocationManager.class).toProvider(new SystemServiceProvider<LocationManager>(Context.LOCATION_SERVICE));
    bind(NotificationManager.class).toProvider(new SystemServiceProvider<NotificationManager>(Context.NOTIFICATION_SERVICE));
    bind(PowerManager.class).toProvider(new SystemServiceProvider<PowerManager>(Context.POWER_SERVICE));
    bind(SensorManager.class).toProvider(new SystemServiceProvider<SensorManager>(Context.SENSOR_SERVICE));
    bind(TelephonyManager.class).toProvider(new SystemServiceProvider<TelephonyManager>(Context.TELEPHONY_SERVICE));
    bind(Vibrator.class).toProvider(new SystemServiceProvider<Vibrator>(Context.VIBRATOR_SERVICE));
    bind(WifiManager.class).toProvider(new SystemServiceProvider<WifiManager>(Context.WIFI_SERVICE));
    bind(WindowManager.class).toProvider(new SystemServiceProvider<WindowManager>(Context.WINDOW_SERVICE));
    bind(mAccountManagerClass).toProvider(AccountManagerProvider.class);
    bind(ObserverManager.class);
    bindProviderListener(new ObserverRegister());
    bind(StateManager.class).in(ApplicationScoped.class);
    bind(StateEventObserver.class);
    bindFieldListener(RetainState.class, new RetainStateListener());
}
Also used : WifiManager(android.net.wifi.WifiManager) ConnectivityManager(android.net.ConnectivityManager) InputMethodManager(android.view.inputmethod.InputMethodManager) ActivityManager(android.app.ActivityManager) WindowManager(android.view.WindowManager) PowerManager(android.os.PowerManager) AudioManager(android.media.AudioManager) StateManager(proton.inject.state.StateManager) TelephonyManager(android.telephony.TelephonyManager) Context(android.content.Context) LocationManager(android.location.LocationManager) ApplicationProvider(proton.inject.provider.ApplicationProvider) NotificationManager(android.app.NotificationManager) HandlerProvider(proton.inject.provider.HandlerProvider) RetainStateListener(proton.inject.state.RetainStateListener) SensorManager(android.hardware.SensorManager) AlarmManager(android.app.AlarmManager) Vibrator(android.os.Vibrator) KeyguardManager(android.app.KeyguardManager) ObserverRegister(proton.inject.observer.ObserverRegister)

Example 30 with WifiManager

use of android.net.wifi.WifiManager in project OpenMEAP by OpenMEAP.

the class MainActivity method onCreate.

/**
	 * Called when the activity is first created.
	 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Get rid of the android title bar
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);
    CredentialsProviderFactory.setDefaultCredentialsProviderFactory(new OmSlicCredentialsProvider.Factory(this));
    HttpRequestExecuterFactory.setDefaultType(HttpRequestExecuterImpl.class);
    DigestInputStreamFactory.setDigestInputStreamForName("md5", Md5DigestInputStream.class);
    DigestInputStreamFactory.setDigestInputStreamForName("sha1", Sha1DigestInputStream.class);
    // setup the SLICConfig instance
    Preferences prefs = new SharedPreferencesImpl(getSharedPreferences(SLICConfig.PREFERENCES_FILE, MODE_PRIVATE));
    try {
        Properties props = new Properties();
        props.load(getAssets().open(SLICConfig.PROPERTIES_FILE));
        config = new AndroidSLICConfig(this, prefs, props);
    } catch (IOException ioe) {
        // then the application is fail
        throw new RuntimeException("The primary configuration file (" + SLICConfig.PROPERTIES_FILE + ") could not be opened.");
    }
    // perform our first-run-check
    Object o = getSystemService(Context.WIFI_SERVICE);
    if (o instanceof WifiManager) {
        WifiManager wifiManager = (WifiManager) o;
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        if (wifiInfo != null && wifiInfo.getMacAddress() != null) {
            Runnable firstRunCheck = new FirstRunCheck(config, wifiInfo.getMacAddress(), HttpRequestExecuterFactory.newDefault());
            new Thread(firstRunCheck).start();
        }
    }
    if (config.isDevelopmentMode()) {
        System.setProperty(HttpRequestExecuter.SSL_PEER_NOVERIFY_PROPERTY, "true");
    } else {
        System.setProperty(HttpRequestExecuter.SSL_PEER_NOVERIFY_PROPERTY, "false");
    }
    storage = new LocalStorageImpl(this);
    updateHandler = new UpdateHandler(this, config, storage);
// Calls the title from client.properties
// setupWindowTitle();
}
Also used : WifiManager(android.net.wifi.WifiManager) UpdateHandler(com.openmeap.thinclient.update.UpdateHandler) IOException(java.io.IOException) Properties(java.util.Properties) WifiInfo(android.net.wifi.WifiInfo) FirstRunCheck(com.openmeap.thinclient.FirstRunCheck) Preferences(com.openmeap.thinclient.Preferences)

Aggregations

WifiManager (android.net.wifi.WifiManager)169 WifiInfo (android.net.wifi.WifiInfo)53 WifiConfiguration (android.net.wifi.WifiConfiguration)42 IOException (java.io.IOException)24 IntentFilter (android.content.IntentFilter)13 WifiEnterpriseConfig (android.net.wifi.WifiEnterpriseConfig)10 Context (android.content.Context)9 ConnectivityManager (android.net.ConnectivityManager)8 NetworkInfo (android.net.NetworkInfo)8 Test (org.junit.Test)8 Intent (android.content.Intent)7 File (java.io.File)6 SAXException (org.xml.sax.SAXException)6 SharedPreferences (android.content.SharedPreferences)5 PowerManager (android.os.PowerManager)5 TelephonyManager (android.telephony.TelephonyManager)5 X509Certificate (java.security.cert.X509Certificate)5 BufferedReader (java.io.BufferedReader)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 FileReader (java.io.FileReader)4