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;
}
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;
}
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;
}
}
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());
}
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();
}
Aggregations