List of usage examples for android.net.wifi WifiManager getConnectionInfo
public WifiInfo getConnectionInfo()
From source file:org.restcomm.app.qoslib.Services.Events.EventManager.java
public WifiConfiguration getWifiConfig() { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); WifiConfiguration activeConfig = null; if (wifiManager.getConfiguredNetworks() == null) return null; for (WifiConfiguration conn : wifiManager.getConfiguredNetworks()) { if ((conn.BSSID != null && conn.BSSID.equals(wifiInfo.getBSSID())) || (conn.SSID != null && conn.SSID.equals(wifiInfo.getSSID()))) { activeConfig = conn;/*from w w w . java2 s . c o m*/ break; } } if (activeConfig != null) { return activeConfig; } return null; }
From source file:com.tapjoy.TapjoyConnectCore.java
/** * Initialize data from the device information and application info. * This data is used in our URL connection to the Tapjoy server. *//*w w w.j a v a2 s .c o m*/ private void init() { PackageManager manager = context.getPackageManager(); try { // ANDROID_ID androidID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); // Get app version. PackageInfo packageInfo = manager.getPackageInfo(context.getPackageName(), 0); appVersion = packageInfo.versionName; // Device platform. Same as device type. deviceType = TapjoyConstants.TJC_DEVICE_PLATFORM_TYPE; platformName = TapjoyConstants.TJC_DEVICE_PLATFORM_TYPE; // Get the device model. deviceModel = android.os.Build.MODEL; deviceManufacturer = android.os.Build.MANUFACTURER; // Get the Android OS Version. deviceOSVersion = android.os.Build.VERSION.RELEASE; // Get the device country and language code. deviceCountryCode = Locale.getDefault().getCountry(); deviceLanguage = Locale.getDefault().getLanguage(); // Tapjoy SDK Library version. libraryVersion = TapjoyConstants.TJC_LIBRARY_VERSION_NUMBER; SharedPreferences settings = context.getSharedPreferences(TapjoyConstants.TJC_PREFERENCE, 0); try { TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); if (telephonyManager != null) { deviceID = telephonyManager.getDeviceId(); carrierName = telephonyManager.getNetworkOperatorName(); carrierCountryCode = telephonyManager.getNetworkCountryIso(); // getNetworkOperator() returns MCC + MNC, so make sure it's 5 or 6 digits total. // MCC is 3 digits // MNC is 2 or 3 digits if (telephonyManager.getNetworkOperator() != null && (telephonyManager.getNetworkOperator().length() == 5 || telephonyManager.getNetworkOperator().length() == 6)) { mobileCountryCode = telephonyManager.getNetworkOperator().substring(0, 3); mobileNetworkCode = telephonyManager.getNetworkOperator().substring(3); } } TapjoyLog.i(TAPJOY_CONNECT, "deviceID: " + deviceID); boolean invalidDeviceID = false; //---------------------------------------- // Is the device ID null or empty? //---------------------------------------- if (deviceID == null) { TapjoyLog.e(TAPJOY_CONNECT, "Device id is null."); invalidDeviceID = true; } else //---------------------------------------- // Is this an emulator device ID? //---------------------------------------- if (deviceID.length() == 0 || deviceID.equals("000000000000000") || deviceID.equals("0")) { TapjoyLog.e(TAPJOY_CONNECT, "Device id is empty or an emulator."); invalidDeviceID = true; } //---------------------------------------- // Valid device ID. //---------------------------------------- else { // Lower case the device ID. deviceID = deviceID.toLowerCase(); } TapjoyLog.i(TAPJOY_CONNECT, "ANDROID SDK VERSION: " + android.os.Build.VERSION.SDK); // Is this at least Android 2.3+? // Then let's get the serial. if (Integer.parseInt(android.os.Build.VERSION.SDK) >= 9) { TapjoyLog.i(TAPJOY_CONNECT, "TRYING TO GET SERIAL OF 2.3+ DEVICE..."); // THIS CLASS IS ONLY LOADED FOR ANDROID 2.3+ TapjoyHardwareUtil hardware = new TapjoyHardwareUtil(); serialID = hardware.getSerial(); // Is there no IMEI or MEID? if (invalidDeviceID) { deviceID = serialID; } TapjoyLog.i(TAPJOY_CONNECT, "===================="); TapjoyLog.i(TAPJOY_CONNECT, "SERIAL: deviceID: [" + deviceID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "===================="); //---------------------------------------- // Is the device ID null or empty? //---------------------------------------- if (deviceID == null) { TapjoyLog.e(TAPJOY_CONNECT, "SERIAL: Device id is null."); invalidDeviceID = true; } else //---------------------------------------- // Is this an emulator device ID? //---------------------------------------- if (deviceID.length() == 0 || deviceID.equals("000000000000000") || deviceID.equals("0") || deviceID.equals("unknown")) { TapjoyLog.e(TAPJOY_CONNECT, "SERIAL: Device id is empty or an emulator."); invalidDeviceID = true; } //---------------------------------------- // Valid device ID. //---------------------------------------- else { // Lower case the device ID. deviceID = deviceID.toLowerCase(); invalidDeviceID = false; } } // Is the device ID invalid? This is probably an emulator or pre-production device. if (invalidDeviceID) { StringBuffer buff = new StringBuffer(); buff.append("EMULATOR"); String deviceId = settings.getString(TapjoyConstants.PREF_EMULATOR_DEVICE_ID, null); // Do we already have an emulator device id stored for this device? if (deviceId != null && !deviceId.equals("")) { deviceID = deviceId; } // Otherwise generate a deviceID for emulator testing. else { String constantChars = "1234567890abcdefghijklmnopqrstuvw"; for (int i = 0; i < 32; i++) { int randomChar = (int) (Math.random() * 100); int ch = randomChar % 30; buff.append(constantChars.charAt(ch)); } deviceID = buff.toString().toLowerCase(); // Save the emulator device ID in the prefs so we can reuse it. SharedPreferences.Editor editor = settings.edit(); editor.putString(TapjoyConstants.PREF_EMULATOR_DEVICE_ID, deviceID); editor.commit(); } } } catch (Exception e) { TapjoyLog.e(TAPJOY_CONNECT, "Error getting deviceID. e: " + e.toString()); deviceID = null; } // Set the userID to the deviceID as the initial value. if (userID.length() == 0) userID = deviceID; // Save the SHA-2 hash of the device id. sha2DeviceID = TapjoyUtil.SHA256(deviceID); // Get screen density, dimensions and layout. try { // This is a backwards compatibility fix for Android 1.5 which has no display metric API. // If this is 1.6 or higher, then load the class, otherwise the class never loads and // no crash occurs. if (Integer.parseInt(android.os.Build.VERSION.SDK) > 3) { TapjoyDisplayMetricsUtil displayMetricsUtil = new TapjoyDisplayMetricsUtil(context); deviceScreenDensity = "" + displayMetricsUtil.getScreenDensity(); deviceScreenLayoutSize = "" + displayMetricsUtil.getScreenLayoutSize(); } } catch (Exception e) { TapjoyLog.e(TAPJOY_CONNECT, "Error getting screen density/dimensions/layout: " + e.toString()); } // Get mac address. try { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wifiManager != null) { WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { macAddress = wifiInfo.getMacAddress(); if (macAddress != null && macAddress.length() > 0) { macAddress = macAddress.toUpperCase(); sha1MacAddress = TapjoyUtil.SHA1(macAddress); } } } } catch (Exception e) { TapjoyLog.e(TAPJOY_CONNECT, "Error getting device mac address: " + e.toString()); } // Alternate market. if (getFlagValue(TapjoyConnectFlag.ALTERNATE_MARKET) != null) { marketName = getFlagValue(TapjoyConnectFlag.ALTERNATE_MARKET); // Check for existing/supported market names. ArrayList<String> supportedMarketNames = new ArrayList<String>(); supportedMarketNames.add(TapjoyConnectFlag.MARKET_GFAN); // Warning for undefined market names. if (!supportedMarketNames.contains(marketName)) { Log.w(TAPJOY_CONNECT, "Warning -- undefined ALTERNATE_MARKET: " + marketName); } } // Get the referral URL String tempReferralURL = settings.getString(TapjoyConstants.PREF_REFERRAL_URL, null); if (tempReferralURL != null && !tempReferralURL.equals("")) referralURL = tempReferralURL; // Get the client package name. clientPackage = context.getPackageName(); TapjoyLog.i(TAPJOY_CONNECT, "Metadata successfully loaded"); TapjoyLog.i(TAPJOY_CONNECT, "APP_ID = [" + appID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "ANDROID_ID: [" + androidID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "CLIENT_PACKAGE = [" + clientPackage + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceID: [" + deviceID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "sha2DeviceID: [" + sha2DeviceID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_DEVICE_SERIAL_ID + ": [" + serialID + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_DEVICE_MAC_ADDRESS + ": [" + macAddress + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_DEVICE_SHA1_MAC_ADDRESS + ": [" + sha1MacAddress + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceName: [" + deviceModel + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceManufacturer: [" + deviceManufacturer + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceType: [" + deviceType + "]"); TapjoyLog.i(TAPJOY_CONNECT, "libraryVersion: [" + libraryVersion + "]"); TapjoyLog.i(TAPJOY_CONNECT, "deviceOSVersion: [" + deviceOSVersion + "]"); TapjoyLog.i(TAPJOY_CONNECT, "COUNTRY_CODE: [" + deviceCountryCode + "]"); TapjoyLog.i(TAPJOY_CONNECT, "LANGUAGE_CODE: [" + deviceLanguage + "]"); TapjoyLog.i(TAPJOY_CONNECT, "density: [" + deviceScreenDensity + "]"); TapjoyLog.i(TAPJOY_CONNECT, "screen_layout: [" + deviceScreenLayoutSize + "]"); TapjoyLog.i(TAPJOY_CONNECT, "carrier_name: [" + carrierName + "]"); TapjoyLog.i(TAPJOY_CONNECT, "carrier_country_code: [" + carrierCountryCode + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_MOBILE_COUNTRY_CODE + ": [" + mobileCountryCode + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_MOBILE_NETWORK_CODE + ": [" + mobileNetworkCode + "]"); TapjoyLog.i(TAPJOY_CONNECT, "" + TapjoyConstants.TJC_MARKET_NAME + ": [" + marketName + "]"); TapjoyLog.i(TAPJOY_CONNECT, "referralURL: [" + referralURL + "]"); if (connectFlags != null) { TapjoyLog.i(TAPJOY_CONNECT, "Connect Flags:"); TapjoyLog.i(TAPJOY_CONNECT, "--------------------"); Set<Entry<String, String>> entries = connectFlags.entrySet(); Iterator<Entry<String, String>> iterator = entries.iterator(); while (iterator.hasNext()) { Entry<String, String> item = iterator.next(); TapjoyLog.i(TAPJOY_CONNECT, "key: " + item.getKey() + ", value: " + Uri.encode(item.getValue())); } } } catch (Exception e) { TapjoyLog.e(TAPJOY_CONNECT, "Error initializing Tapjoy parameters. e=" + e.toString()); } }
From source file:org.deviceconnect.android.deviceplugin.irkit.IRKitManager.java
/** * ?./*from ww w . j a va 2 s .c o m*/ * * @param context */ public synchronized void startDetection(final ContextWrapper context) { if (isDetecting()) { return; } mIsDetecting = true; init(context); WifiManager wifi = getWifiManager(context); mMultiLock = wifi.createMulticastLock(MULTI_CAST_LOCK_TAG); mMultiLock.setReferenceCounted(true); mMultiLock.acquire(); WifiInfo info = wifi.getConnectionInfo(); if (info != null) { mIpValue = info.getIpAddress(); } else { mIpValue = 0; } new Thread(new Runnable() { @Override public void run() { synchronized (INSTANCE) { try { if (mDNS != null || mIpValue == 0) { mIsDetecting = false; return; } InetAddress ia = parseIPAddress(mIpValue); if (ia == null) { mIsDetecting = false; return; } mDNS = JmDNS.create(ia); mDNS.addServiceListener(SERVICE_TYPE, mServiceListener); mIsDetecting = true; if (BuildConfig.DEBUG) { Log.d(TAG, "start detection."); } } catch (IOException e) { if (BuildConfig.DEBUG) { e.printStackTrace(); } mIsDetecting = false; mDNS = null; } } } }).start(); }
From source file:com.wbtech.ums.UmsAgent.java
private static JSONObject getClientDataJSONObject(Context context) { TelephonyManager tm = (TelephonyManager) (context.getSystemService(Context.TELEPHONY_SERVICE)); WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics displaysMetrics = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(displaysMetrics); LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); JSONObject clientData = new JSONObject(); try {/*w w w .j a va2 s. co m*/ clientData.put("os_version", CommonUtil.getOsVersion(context)); clientData.put("platform", "android"); clientData.put("language", Locale.getDefault().getLanguage()); clientData.put("deviceid", tm.getDeviceId() == null ? "" : tm.getDeviceId());// clientData.put("appkey", CommonUtil.getAppKey(context)); clientData.put("resolution", displaysMetrics.widthPixels + "x" + displaysMetrics.heightPixels); clientData.put("ismobiledevice", true); clientData.put("phonetype", tm.getPhoneType());// clientData.put("imsi", tm.getSubscriberId()); clientData.put("network", CommonUtil.getNetworkTypeWIFI2G3G(context)); clientData.put("time", CommonUtil.getTime()); clientData.put("version", CommonUtil.getVersion(context)); clientData.put(UserIdentifier, CommonUtil.getUserIdentifier(context)); SCell sCell = CommonUtil.getCellInfo(context); clientData.put("mccmnc", sCell != null ? "" + sCell.MCCMNC : ""); clientData.put("cellid", sCell != null ? sCell.CID + "" : ""); clientData.put("lac", sCell != null ? sCell.LAC + "" : ""); clientData.put("modulename", Build.PRODUCT); clientData.put("devicename", CommonUtil.getDeviceName()); clientData.put("wifimac", wifiManager.getConnectionInfo().getMacAddress()); clientData.put("havebt", adapter == null ? false : true); clientData.put("havewifi", CommonUtil.isWiFiActive(context)); clientData.put("havegps", locationManager == null ? false : true); clientData.put("havegravity", CommonUtil.isHaveGravity(context));// LatitudeAndLongitude coordinates = CommonUtil.getLatitudeAndLongitude(context, UmsAgent.mUseLocationService); clientData.put("latitude", coordinates.latitude); clientData.put("longitude", coordinates.longitude); CommonUtil.printLog("clientData---------->", clientData.toString()); } catch (JSONException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return clientData; }
From source file:xj.property.ums.UmsAgent.java
public static JSONObject getClientDataJSONObject(Context context) { TelephonyManager tm = (TelephonyManager) (context.getSystemService(Context.TELEPHONY_SERVICE)); WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics displaysMetrics = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(displaysMetrics); LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); JSONObject clientData = new JSONObject(); try {//w w w . j a v a2s . com clientData.put("os_version", CommonUtil.getOsVersion(context)); clientData.put("platform", "android"); clientData.put("language", Locale.getDefault().getLanguage()); clientData.put("deviceid", tm.getDeviceId() == null ? "" : tm.getDeviceId());// clientData.put("appkey", CommonUtil.getAppKey(context)); clientData.put("resolution", displaysMetrics.widthPixels + "x" + displaysMetrics.heightPixels); clientData.put("ismobiledevice", true); clientData.put("phonetype", tm.getPhoneType());// clientData.put("imsi", tm.getSubscriberId()); clientData.put("network", CommonUtil.getNetworkTypeWIFI2G3G(context)); clientData.put("time", CommonUtil.getTime()); clientData.put("version", CommonUtil.getVersion(context)); clientData.put(UserIdentifier, CommonUtil.getUserIdentifier(context)); SCell sCell = CommonUtil.getCellInfo(context); clientData.put("mccmnc", sCell != null ? "" + sCell.MCCMNC : ""); clientData.put("cellid", sCell != null ? sCell.CID + "" : ""); clientData.put("lac", sCell != null ? sCell.LAC + "" : ""); clientData.put("modulename", Build.PRODUCT); clientData.put("devicename", CommonUtil.getDeviceName()); clientData.put("wifimac", wifiManager.getConnectionInfo().getMacAddress()); clientData.put("havebt", adapter == null ? false : true); clientData.put("havewifi", CommonUtil.isWiFiActive(context)); clientData.put("havegps", locationManager == null ? false : true); clientData.put("havegravity", CommonUtil.isHaveGravity(context));// LatitudeAndLongitude coordinates = CommonUtil.getLatitudeAndLongitude(context, UmsAgent.mUseLocationService); clientData.put("latitude", coordinates.latitude); clientData.put("longitude", coordinates.longitude); CommonUtil.printLog("clientData---------->", clientData.toString()); } catch (JSONException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return clientData; }
From source file:com.lewa.crazychapter11.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { //set to full screen // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); ///set to no title // requestWindowFeature(Window.FEATURE_NO_TITLE); // acionBar = getSupportActionBar(); // acionBar = getActionBar(); // acionBar.hide(); // Window win = getWindow(); // win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); // win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); // win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); // win.setStatusBarColor(Color.TRANSPARENT); // win.setNavigationBarColor(Color.TRANSPARENT); /*//*from w w w . j av a2s. c o m*/ win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); win.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); win.setStatusBarColor(Color.TRANSPARENT); win.setNavigationBarColor(Color.TRANSPARENT); //*/ super.onCreate(savedInstanceState); setContentView(R.layout.main); /* setTheme(R.style.CrazyTheme); */ AddGameBtn(); AddNoification(); LookupContact(); AddServiceBtn(); broadcastMain(); mediaPlayerMain(); mediaRecordSoundMain(); cameraMain(); recordvideoMain(); queMySql(); TestFragment(); justForTest(); LoadJson(); AddTestBtn(); AddUsageStatsBtn(); AddPeopleProvideBtn(); getInput(); ////just for test shutdown broadcast receiver IntentFilter mIntentFilter = new IntentFilter("android.intent.action.ACTION_SHUTDOWN"); mIntentFilter.addAction("com.lewa.alarm.test"); mIntentFilter.addAction("android.provider.Telephony.SECRET_CODE"); mIntentFilter.addAction("android.intent.action.SCREEN_ON"); mIntentFilter.addAction("android.intent.action.SCREEN_OFF"); mShoutdown = new shutdownReceiver(); registerReceiver(mShoutdown, mIntentFilter); ////test preferences = getSharedPreferences("crazyit", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE); editor = preferences.edit(); preferencestime = getSharedPreferences("RMS_Shutdown_time", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE); editortime = preferencestime.edit(); SharedShutdownTimeRead(); AddSharedPreBtn(); etNum = (EditText) findViewById(R.id.etNum); // // int maxLength = 4; InputFilter[] fArray = new InputFilter[1]; fArray[0] = new InputFilter.LengthFilter(maxLength); etNum.setFilters(fArray); // // calThread = new CalThread(); calThread.start(); Log.i("algerheMain", "MainActivity onCreate in!!"); String page = getString(R.string.str_page, "345", "24"); Log.i("algerheMain", "page=" + page); // /just for test here ComponentName comp = getIntent().getComponent(); show_txt = (EditText) findViewById(R.id.show_txt); show_txt.setText( "??" + comp.getPackageName() + " \n ??" + comp.getClassName()); ////MD5 check item ///1.IMEI TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); String szImei = TelephonyMgr.getDeviceId(); String m_szSIMSerialNm = TelephonyMgr.getSimSerialNumber(); CellLocation m_location = TelephonyMgr.getCellLocation(); String m_Line1Number = TelephonyMgr.getLine1Number(); String m_OperatorName = TelephonyMgr.getSimOperatorName(); Log.i("algerheTelephonyMgr", "szImei=" + szImei); Log.i("algerheTelephonyMgr", "m_szSIMSerialNm=" + m_szSIMSerialNm); Log.i("algerheTelephonyMgr", "m_location=" + m_location); Log.i("algerheTelephonyMgr", "m_Line1Number=" + m_Line1Number); Log.i("algerheTelephonyMgr", "m_OperatorName=" + m_OperatorName); Log.i("algerheMain01", "szImei=" + szImei); Log.i("algerheMain01", "m_szSIMSerialNm=" + m_szSIMSerialNm); ///2.Pseudo-Unique ID String m_szDevIDShort = "35" + //we make this look like a valid IMEI Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + Build.USER.length() % 10; //13 digits Log.i("algerheMain01", "m_szDevIDShort=" + m_szDevIDShort); ///3. Android ID String m_szAndroidID = Secure.getString(getContentResolver(), Secure.ANDROID_ID); Log.i("algerheMain01", "m_szAndroidID=" + m_szAndroidID); ///4.WLAN MAC Address string WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); String m_szWLANMAC = "unknow_wifi_mac"; if (wm != null && wm.getConnectionInfo() != null) { m_szWLANMAC = wm.getConnectionInfo().getMacAddress(); } Log.i("algerheMain01", "m_szWLANMAC=" + m_szWLANMAC); ///5.BT MAC Address string BluetoothAdapter m_BluetoothAdapter = null; // Local Bluetooth adapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); String m_szBTMAC = m_BluetoothAdapter.getAddress(); Log.i("algerheMain01", "m_szBTMAC=" + m_szBTMAC); ///6.sim serial number .getSimSerialNumber() // / ///reflect test checkMethod(); // */ final Intent alarmIntent = new Intent(); Log.i("algerheMain00", "isLewaRom=" + isLewaRom(this, alarmIntent)); handler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == 0x4567) { String languageStr = null; String countryStr = null; Locale[] locList = Locale.getAvailableLocales(); for (int i = 0; i < locList.length; i++) { languageStr += locList[i].getLanguage(); countryStr += locList[i].getCountry(); } // show_txt = (EditText) findViewById(R.id.show_txt); show_txt.setText("" + languageStr + " \n " + countryStr); } else if (msg.what == 0x2789) { Log.i("algerheAlarm", "send alarm message in time=" + System.currentTimeMillis() + "\n action=" + alarmIntent.getAction()); // sendBroadcast(alarmIntent); } } }; // String strApkPath = intent.getStringExtra("apkPath"); // String strCmd = "pm install -r " + strApkPath; // try { // Process install = Runtime.getRuntime().exec(strCmd); // Log.d(TAG, "install = " + install + ", strCmd =" + strCmd); // }catch (Exception ex){ // Log.d(TAG, ex.getMessage()); // } // */ }
From source file:org.restcomm.app.qoslib.Services.LibPhoneStateListener.java
public void processNewMMCSignal(SignalEx signal) { ContentValues values = null;//from ww w . j a v a2 s . c o m // if in a service outage, store a null signal // (I've seen cases where phone was out of service yet it was still returning a signal level) try { if (mPhoneState.getLastServiceState() == ServiceState.STATE_OUT_OF_SERVICE) signal = null; // avoid storing repeating identical signals if (mPhoneState.lastKnownMMCSignal != null && mPhoneState.lastKnownMMCSignal.getSignalStrength() != null && signal != null && signal.getSignalStrength() != null) if (mPhoneState.lastKnownMMCSignal.getSignalStrength().toString().equals( signal.getSignalStrength().toString()) && tmlastSig + 3000 > System.currentTimeMillis()) return; tmlastSig = System.currentTimeMillis(); Integer dbmValue = 0; boolean isLTE = false; if (signal == null) dbmValue = -256; else if (signal.getSignalStrength() == null) dbmValue = 0; //store the last known signal if (signal != null && signal.getSignalStrength() != null) { prevMMCSignal = mPhoneState.lastKnownMMCSignal; // used for looking at signal just before a call ended mPhoneState.lastKnownMMCSignal = signal; } else if (signal == null) mPhoneState.lastKnownMMCSignal = null; //push the new signal level into the sqlite database long stagedEventId = owner.getEventManager().getStagedEventId(); int serviceState = mPhoneState.getLastServiceState(); int wifiSignal = -1; WifiManager wifiManager = (WifiManager) owner.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiinfo = wifiManager.getConnectionInfo(); if (wifiinfo != null && wifiinfo.getBSSID() != null) wifiSignal = wifiManager.getConnectionInfo().getRssi(); //if (signal != null) // disabled because we do want the no-signal to be written to the signals table { values = ContentValuesGenerator.generateFromSignal(signal, telephonyManager.getPhoneType(), telephonyManager.getNetworkType(), serviceState, telephonyManager.getDataState(), stagedEventId, wifiSignal, mPhoneState.mServicemode); Integer valSignal = (Integer) values.get("signal"); if (mPhoneState.getNetworkType() == PhoneState.NETWORK_NEWTYPE_LTE) // && phoneStateListener.previousNetworkState == TelephonyManager.DATA_CONNECTED) valSignal = (Integer) values.get("lteRsrp"); if (valSignal != null && dbmValue != null && valSignal > -130 && valSignal < -30) // && (dbmValue <= -120 || dbmValue >= -1)) dbmValue = valSignal; if ((dbmValue > -120 || mPhoneState.getNetworkType() == PhoneState.NETWORK_NEWTYPE_LTE) && dbmValue < -40) this.validSignal = true; if (this.validSignal) // make sure phone has at least one valid signal before recording owner.getDBProvider(owner).insert(TablesEnum.SIGNAL_STRENGTHS.getContentUri(), values); } //update the signal strength percentometer, chart, and look for low/high signal event if (dbmValue != null) { if (dbmValue < -120) // might be -256 if no service, but want to display as -120 on livestatus chart dbmValue = -120; owner.getIntentDispatcher().updateSignalStrength(dbmValue, mPhoneState.getNetworkType(), owner.bWifiConnected, wifiSignal); // Store signal in a sharedPreference for tools such as Indoor/Transit sample mapper, which dont have reference to service if (isLTE == true) // improve the value of the signal for LTE, so that Indoor samples don't look redder in LTE PreferenceManager.getDefaultSharedPreferences(owner).edit() .putInt(PreferenceKeys.Miscellaneous.SIGNAL_STRENGTH, (dbmValue + 15)).commit(); else PreferenceManager.getDefaultSharedPreferences(owner).edit() .putInt(PreferenceKeys.Miscellaneous.SIGNAL_STRENGTH, dbmValue).commit(); } } catch (Exception e) { LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "processNewMMCSignal", "exception", e); LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "processNewMMCSignal", "values: " + values); } catch (Error err) { LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "processNewMMCSignal", "error" + err.getMessage()); } }
From source file:com.newsrob.EntryManager.java
boolean isOnWiFi() { if (connectivityManager == null) connectivityManager = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager == null) { PL.log("EntryManager. Wasn't able to get CONNECTIVITY_SERVICE.", ctx); WifiManager wifiManager = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) PL.log("WiFi Info=" + wifiInfo + " SSID=" + wifiInfo.getSSID(), ctx); return false; }/*from w w w . j a v a 2 s .c o m*/ final NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo == null) { PL.log("EntryManager. Wasn't able to get Network Info.", ctx); return false; } if (ConnectivityManager.TYPE_WIFI != networkInfo.getType()) { PL.log("EntryManager. Network Info Type was not WiFi, but " + networkInfo.getType() + ".", ctx); return false; } return true; }
From source file:com.grazerss.EntryManager.java
boolean isOnWiFi() { if (connectivityManager == null) { connectivityManager = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); }//from www. j ava2 s.co m if (connectivityManager == null) { PL.log("EntryManager. Wasn't able to get CONNECTIVITY_SERVICE.", ctx); WifiManager wifiManager = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { PL.log("WiFi Info=" + wifiInfo + " SSID=" + wifiInfo.getSSID(), ctx); } return false; } final NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo == null) { PL.log("EntryManager. Wasn't able to get Network Info.", ctx); return false; } if (ConnectivityManager.TYPE_WIFI != networkInfo.getType()) { PL.log("EntryManager. Network Info Type was not WiFi, but " + networkInfo.getType() + ".", ctx); return false; } return true; }
From source file:com.csipsimple.service.SipService.java
/** * Ask to take the control of the wifi and the partial wake lock if * configured/*from w w w .jav a2 s .c o m*/ */ private synchronized void acquireResources() { if (holdResources) { return; } // Add a wake lock for CPU if necessary if (prefsWrapper.getPreferenceBooleanValue(SipConfigManager.USE_PARTIAL_WAKE_LOCK)) { PowerManager pman = (PowerManager) getSystemService(Context.POWER_SERVICE); if (wakeLock == null) { wakeLock = pman.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "com.csipsimple.SipService"); wakeLock.setReferenceCounted(false); } // Extra check if set reference counted is false ??? if (!wakeLock.isHeld()) { wakeLock.acquire(); } } // Add a lock for WIFI if necessary WifiManager wman = (WifiManager) getSystemService(Context.WIFI_SERVICE); if (wifiLock == null) { int mode = WifiManager.WIFI_MODE_FULL; if (Compatibility.isCompatible(9) && prefsWrapper.getPreferenceBooleanValue(SipConfigManager.LOCK_WIFI_PERFS)) { mode = 0x3; // WIFI_MODE_FULL_HIGH_PERF } wifiLock = wman.createWifiLock(mode, "com.csipsimple.SipService"); wifiLock.setReferenceCounted(false); } if (prefsWrapper.getPreferenceBooleanValue(SipConfigManager.LOCK_WIFI) && !wifiLock.isHeld()) { WifiInfo winfo = wman.getConnectionInfo(); if (winfo != null) { DetailedState dstate = WifiInfo.getDetailedStateOf(winfo.getSupplicantState()); // We assume that if obtaining ip addr, we are almost connected // so can keep wifi lock if (dstate == DetailedState.OBTAINING_IPADDR || dstate == DetailedState.CONNECTED) { if (!wifiLock.isHeld()) { wifiLock.acquire(); } } } } holdResources = true; }