List of usage examples for android.telephony PhoneStateListener LISTEN_SIGNAL_STRENGTHS
int LISTEN_SIGNAL_STRENGTHS
To view the source code for android.telephony PhoneStateListener LISTEN_SIGNAL_STRENGTHS.
Click Source Link
From source file:com.karpenstein.signalmon.NetServerService.java
@Override public void onCreate() { super.onCreate(); try {/* w ww. j av a 2 s .c o m*/ jsonState = new JSONObject(); jsonState.put("dataActivity", TelephonyManager.DATA_ACTIVITY_NONE); } catch (JSONException ex) { Log.d("NetServerService", "Failed to put data activity in the JSONObject"); } // Get the telephony manager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); if (telephonyManager == null) Log.d("NetServerService", "TelephonyManager was null."); Log.d("NetServerService", "about to create PhoneStateListener"); // Create a new PhoneStateListener psListener = new PhoneStateListener() { @Override public void onDataActivity(int direction) { Log.d("NetServerService", "received onDataActivity message"); try { jsonState.put("dataActivity", direction); } catch (JSONException ex) { } notifyListeners(); } @Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { Log.d("NetServerService", "received onSignalStrength message"); try { jsonState.put("cdmaDbm", signalStrength.getCdmaDbm()); jsonState.put("cdmaEcio", signalStrength.getCdmaEcio()); jsonState.put("evdoDbm", signalStrength.getEvdoDbm()); jsonState.put("evdoEcio", signalStrength.getEvdoEcio()); jsonState.put("evdoSnr", signalStrength.getEvdoSnr()); jsonState.put("gsmBitErrorRate", signalStrength.getGsmBitErrorRate()); jsonState.put("gsmSignalStrength", signalStrength.getGsmSignalStrength()); jsonState.put("isGsm", signalStrength.isGsm()); } catch (JSONException ex) { } notifyListeners(); } @Override public void onDataConnectionStateChanged(int state, int networkType) { Log.d("NetServerService", "received onDataConnectionStateChanged message"); try { jsonState.put("connState", state); jsonState.put("netType", networkType); } catch (JSONException ex) { } notifyListeners(); } }; Log.d("NetServerService", "about to call telephonyManager.listen"); // Register the listener with the telephony manager telephonyManager.listen(psListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_DATA_ACTIVITY); Log.d("NetServerService", "done calling telephonyManager.listen -- exiting onCreate"); }
From source file:com.tvs.signaltracker.STService.java
private void InitBase() { Tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); MyListener = new MyPhoneStateListener(); mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); NetLocListener = new NETLocationListener(); mlocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 10, NetLocListener); Tel.listen(MyListener,//w w w .j a v a 2 s .com PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_CELL_LOCATION); //CommonHandler.Operator = Utils.DoOperator(Tel.getNetworkOperatorName()); Operator x = CommonHandler.dbman.getOperator(CommonHandler.MCC, CommonHandler.MNC); if (x != null) CommonHandler.Operator = x.name; else CommonHandler.Operator = CommonHandler.MCC + "" + CommonHandler.MNC; }
From source file:com.karpenstein.signalmon.SignalMonitorActivity.java
/** Called when the activity is first created. */ @Override// w ww . j ava2 s .com public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Get the UI textOut = (TextView) findViewById(R.id.textOut); // Get the telephony manager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); // Create a new PhoneStateListener listener = new PhoneStateListener() { @Override public void onDataActivity(int direction) { String dirString = "N/A"; switch (direction) { case TelephonyManager.DATA_ACTIVITY_NONE: dirString = "DATA_ACTIVITY_NONE"; break; case TelephonyManager.DATA_ACTIVITY_IN: dirString = "DATA_ACTIVITY_IN"; break; case TelephonyManager.DATA_ACTIVITY_OUT: dirString = "DATA_ACTIVITY_OUT"; break; case TelephonyManager.DATA_ACTIVITY_INOUT: dirString = "DATA_ACTIVITY_INOUT"; break; case TelephonyManager.DATA_ACTIVITY_DORMANT: dirString = "DATA_ACTIVITY_DORMANT"; break; } textOut.append(dirString + "\n"); } @Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { textOut.append(signalStrength.toString() + "\n"); } @Override public void onDataConnectionStateChanged(int state, int networkType) { String stateString = "N/A"; String netTypString = "N/A"; switch (state) { case TelephonyManager.DATA_CONNECTED: stateString = "DATA_CONNECTED"; break; case TelephonyManager.DATA_CONNECTING: stateString = "DATA_CONNECTING"; break; case TelephonyManager.DATA_DISCONNECTED: stateString = "DATA_DISCONNECTED"; break; case TelephonyManager.DATA_SUSPENDED: stateString = "DATA_SUSPENDED"; break; } switch (networkType) { case TelephonyManager.NETWORK_TYPE_1xRTT: netTypString = "NETWORK_TYPE_1xRTT"; break; case TelephonyManager.NETWORK_TYPE_CDMA: netTypString = "NETWORK_TYPE_CDMA"; break; case TelephonyManager.NETWORK_TYPE_EDGE: netTypString = "NETWORK_TYPE_EDGE"; break; case TelephonyManager.NETWORK_TYPE_EVDO_0: netTypString = "NETWORK_TYPE_EVDO_0"; break; case TelephonyManager.NETWORK_TYPE_EVDO_A: netTypString = "NETWORK_TYPE_EVDO_A"; break; case TelephonyManager.NETWORK_TYPE_GPRS: netTypString = "NETWORK_TYPE_GPRS"; break; case TelephonyManager.NETWORK_TYPE_HSDPA: netTypString = "NETWORK_TYPE_HSDPA"; break; case TelephonyManager.NETWORK_TYPE_HSPA: netTypString = "NETWORK_TYPE_HSPA"; break; case TelephonyManager.NETWORK_TYPE_HSUPA: netTypString = "NETWORK_TYPE_HSUPA"; break; case TelephonyManager.NETWORK_TYPE_IDEN: netTypString = "NETWORK_TYPE_IDE"; break; case TelephonyManager.NETWORK_TYPE_UMTS: netTypString = "NETWORK_TYPE_UMTS"; break; case TelephonyManager.NETWORK_TYPE_UNKNOWN: netTypString = "NETWORK_TYPE_UNKNOWN"; break; } textOut.append(String.format("onDataConnectionStateChanged: %s; %s\n", stateString, netTypString)); } }; // Register the listener with the telephony manager telephonyManager.listen(listener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_DATA_ACTIVITY); // start the NetServerService startService(new Intent(this, NetServerService.class)); }
From source file:com.cc.signalinfo.activities.MainActivity.java
@Override public void onResume() { super.onResume(); if (preferences != null) { setPreferences(preferences);//from w ww. j a v a2 s . co m if (filteredSignals != null) { displaySignalInfo(filteredSignals); } } tm.listen(listener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); }
From source file:com.ti.sensortag.gui.services.ServicesActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakelockk = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Lock"); setContentView(R.layout.services_browser); //for checking signal strength.. MyListener = new MyPhoneStateListener(); Tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); Tel.listen(MyListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); //ends../*from www. ja va2s . com*/ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); test_1 = getIntent().getStringExtra("TEST"); Toast.makeText(getBaseContext(), "ARV in services SA :" + test_1, Toast.LENGTH_SHORT).show(); /* sendbutton = (Button) findViewById(R.id.button1); sendbutton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String sensorid = test_1; String sensortype = "temperature"; BufferedReader br = null; try { String sCurrentLine; File ext = Environment.getExternalStorageDirectory(); File myFile = new File(ext, "mysdfile_25.txt"); br = new BufferedReader(new FileReader(myFile)); while ((sCurrentLine = br.readLine()) != null) { String[] numberSplit = sCurrentLine.split(":") ; String time = numberSplit[ (numberSplit.length-2) ] ; String val = numberSplit[ (numberSplit.length-1) ] ; //System.out.println(sCurrentLine); HttpResponse httpresponse; //int responsecode; StatusLine responsecode; String strresp; HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("https://rnicu-cloud.appspot.com/sensor/update"); try{ List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("sensorid", sensorid)); nameValuePairs.add(new BasicNameValuePair("sensortype", sensortype)); nameValuePairs.add(new BasicNameValuePair("time", time)); nameValuePairs.add(new BasicNameValuePair("val", val)); // try { httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // try { httpresponse = httpclient.execute(httppost); //responsecode = httpresponse.getStatusLine().getStatusCode(); responsecode = httpresponse.getStatusLine(); strresp = responsecode.toString(); Log.d("ARV Response msg from post", httpresponse.toString()); Log.d("ARV status of post", strresp); HttpEntity httpentity = httpresponse.getEntity(); Log.d("ARV entity string", EntityUtils.toString(httpentity)); // Log.d("ARV oly entity", httpentity.toString()); // Log.d("ARV Entity response", httpentity.getContent().toString()); //httpclient.execute(httppost); Toast.makeText(getApplicationContext(), "Posted data and returned value:"+ strresp, Toast.LENGTH_LONG).show(); // } catch (ClientProtocolException e) { // TODO Auto-generated catch block // e.printStackTrace(); // } catch (IOException e) { // TODO Auto-generated catch block // e.printStackTrace(); // } // } }catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); }catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } catch (IOException e) { e.printStackTrace(); } finally { try { if (br != null)br.close(); } catch (IOException ex) { ex.printStackTrace(); } } // Toast.makeText(getApplicationContext(), "Entered on click", Toast.LENGTH_SHORT).show(); /*catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } });*/ getActionBar().setDisplayHomeAsUpEnabled(true); }
From source file:ua.mkh.weather.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_main); String roman = "fonts/Regular.otf"; String medium = "fonts/Medium.otf"; String bold = "fonts/Bold.otf"; String thin = "fonts/Thin.otf"; String ultra = "fonts/Ultralight.otf"; typefaceRoman = Typeface.createFromAsset(getAssets(), roman); typefaceMedium = Typeface.createFromAsset(getAssets(), medium); typefaceBold = Typeface.createFromAsset(getAssets(), bold); typefaceThin = Typeface.createFromAsset(getAssets(), thin); typefaceUltra = Typeface.createFromAsset(getAssets(), ultra); mSettings = getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE); psListener = new myPhoneStateListener(); telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(psListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); //check_int(); Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.cloudy_cloud); battery_green = (MyProgressBarGreen) findViewById(R.id.progressBarGreen); battery_white = (MyProgressBarWhite) findViewById(R.id.progressBarWhite); battery_yellow = (MyProgressBarYellow) findViewById(R.id.progressBarYellow); battery_green.setVisibility(View.INVISIBLE); battery_white.setVisibility(View.VISIBLE); battery_yellow.setVisibility(View.INVISIBLE); listView1 = (ListView) findViewById(R.id.listView1); listview = (HorizontalListView) findViewById(R.id.listview); button2 = (Button) findViewById(R.id.button2); button2.setOnClickListener(this); prog1 = (ProgressBar) findViewById(R.id.progressBar1); button1 = (Button) findViewById(R.id.button1); button1.setOnClickListener(this); cityText = (TextView) findViewById(R.id.cityText); condDescr = (TextView) findViewById(R.id.condDescr); temp = (TextView) findViewById(R.id.temp); hum = (TextView) findViewById(R.id.hum); press = (TextView) findViewById(R.id.press); windSpeed = (TextView) findViewById(R.id.windSpeed); tempDay = (TextView) findViewById(R.id.textView5); tempNight = (TextView) findViewById(R.id.textView6); TextView03 = (TextView) findViewById(R.id.TextView03); TextView01 = (TextView) findViewById(R.id.TextView01); textView1 = (TextView) findViewById(R.id.textView1); textView2 = (TextView) findViewById(R.id.textView2); textView3 = (TextView) findViewById(R.id.textView3); textView7 = (TextView) findViewById(R.id.textView7); textView8 = (TextView) findViewById(R.id.textView8); textView9 = (TextView) findViewById(R.id.textView9); textView10 = (TextView) findViewById(R.id.textView10); textView11 = (TextView) findViewById(R.id.textView11); textView12 = (TextView) findViewById(R.id.textView12); textView14 = (TextView) findViewById(R.id.textView14); textView15 = (TextView) findViewById(R.id.textView15); //imgView = (ImageView) findViewById(R.id.condIcon); img1 = (ImageView) findViewById(R.id.imageView1); main = (LinearLayout) findViewById(R.id.mainLayout); scrollView1 = (ScrollView) findViewById(R.id.scrollView1); scrollView1.setVisibility(View.GONE); main.setVisibility(View.GONE); //Intent intent = new Intent(this, AllCityActivity.class); //startActivity(intent); //JSONWeatherTask task = new JSONWeatherTask(); //task.execute(new String[]{city,lang}); //JSONForecastWeatherTask task1 = new JSONForecastWeatherTask(); //task1.execute(new String[]{city,lang, forecastDaysNum}); //mDbHelper = new CustomersDbAdapter(this); //mDbHelper.open(); //new CopyDataBase().execute(); //GetBaseWeather task3 = new GetBaseWeather(); //task3.execute(); SimpleDateFormat sdf = new SimpleDateFormat("EEEE"); String currentDateandTime = sdf.format(new Date()); String upperString = currentDateandTime.substring(0, 1).toUpperCase() + currentDateandTime.substring(1); textView1.setText(upperString);// w ww. j ava2s . com temp.setTypeface(typefaceUltra); cityText.setTypeface(typefaceThin); condDescr.setTypeface(typefaceThin); hum.setTypeface(typefaceRoman); press.setTypeface(typefaceRoman); windSpeed.setTypeface(typefaceRoman); textView1.setTypeface(typefaceRoman); textView2.setTypeface(typefaceThin); textView3.setTypeface(typefaceRoman); textView7.setTypeface(typefaceRoman); TextView03.setTypeface(typefaceRoman); TextView01.setTypeface(typefaceRoman); textView8.setTypeface(typefaceRoman); textView9.setTypeface(typefaceRoman); textView10.setTypeface(typefaceRoman); textView11.setTypeface(typefaceRoman); textView12.setTypeface(typefaceRoman); textView14.setTypeface(typefaceRoman); textView15.setTypeface(typefaceRoman); //textView4.setTypeface(typefaceThin); tempDay.setTypeface(typefaceRoman); tempNight.setTypeface(typefaceThin); }
From source file:org.metawatch.manager.Monitors.java
public static void start(Context context, TelephonyManager telephonyManager) { // start weather updater if (Preferences.logging) Log.d(MetaWatch.TAG, "Monitors.start()"); createBatteryLevelReciever(context); createWifiReceiver(context);/*from w ww . j a v a 2 s. co m*/ if (Preferences.weatherGeolocation) { if (Preferences.logging) Log.d(MetaWatch.TAG, "Initialising Geolocation"); try { locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); locationProvider = LocationManager.NETWORK_PROVIDER; networkLocationListener = new NetworkLocationListener(context); locationManager.requestLocationUpdates(locationProvider, 30 * 60 * 1000, 500, networkLocationListener); RefreshLocation(); } catch (IllegalArgumentException e) { if (Preferences.logging) Log.d(MetaWatch.TAG, "Failed to initialise Geolocation " + e.getMessage()); } } else { if (Preferences.logging) Log.d(MetaWatch.TAG, "Geolocation disabled"); } CallStateListener phoneListener = new CallStateListener(context); telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); int phoneEvents = PhoneStateListener.LISTEN_CALL_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE; telephonyManager.listen(phoneListener, phoneEvents); if (Utils.isGmailAccessSupported(context)) { gmailMonitor = new GmailMonitor(context); gmailMonitor.startMonitor(); } try { contentObserverMessages = new ContentObserverMessages(context); Uri uri = Uri.parse("content://mms-sms/conversations/"); contentResolverMessages = context.getContentResolver(); contentResolverMessages.registerContentObserver(uri, true, contentObserverMessages); } catch (Exception x) { } try { contentObserverCalls = new ContentObserverCalls(context); //Uri uri = Uri.parse("content://mms-sms/conversations/"); contentResolverCalls = context.getContentResolver(); contentResolverCalls.registerContentObserver(android.provider.CallLog.Calls.CONTENT_URI, true, contentObserverCalls); } catch (Exception x) { } try { contentObserverAppointments = new ContentObserverAppointments(context); Uri uri = Uri.parse("content://com.android.calendar/calendars/"); contentResolverAppointments = context.getContentResolver(); contentResolverAppointments.registerContentObserver(uri, true, contentObserverAppointments); } catch (Exception x) { } // temporary one time update updateWeatherData(context); startAlarmTicker(context); }
From source file:org.wso2.emm.agent.services.DeviceInfoPayload.java
/** * Fetch all device runtime information. * @throws AndroidAgentException/*from www . j a va 2 s.c om*/ */ private void getInfo() throws AndroidAgentException { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); Location deviceLocation = locationService.getLastKnownLocation(); if (device == null) { device = new Device(); } deviceInfo = new DeviceInfo(context); Power power = phoneState.getBatteryDetails(); device.setDeviceIdentifier(deviceInfo.getDeviceId()); device.setDescription(deviceInfo.getDeviceName()); device.setName(deviceInfo.getDeviceName()); List<Device.Property> properties = new ArrayList<>(); Device.Property property = new Device.Property(); property.setName(Constants.Device.SERIAL); property.setValue(deviceInfo.getDeviceSerialNumber()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.IMEI); property.setValue(telephonyManager.getDeviceId()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.IMSI); property.setValue(deviceInfo.getIMSINumber()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.MAC); property.setValue(deviceInfo.getMACAddress()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.MODEL); property.setValue(deviceInfo.getDeviceModel()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.VENDOR); property.setValue(deviceInfo.getDeviceManufacturer()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.OS); property.setValue(deviceInfo.getOsVersion()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.OS_BUILD_DATE); property.setValue(deviceInfo.getOSBuildDate()); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.NAME); property.setValue(deviceInfo.getDeviceName()); properties.add(property); if (deviceLocation != null) { double latitude = deviceLocation.getLatitude(); double longitude = deviceLocation.getLongitude(); if (latitude != 0 && longitude != 0) { property = new Device.Property(); property.setName(Constants.Device.MOBILE_DEVICE_LATITUDE); property.setValue(String.valueOf(latitude)); properties.add(property); property = new Device.Property(); property.setName(Constants.Device.MOBILE_DEVICE_LONGITUDE); property.setValue(String.valueOf(longitude)); properties.add(property); } } if (registrationId != null) { property = new Device.Property(); property.setName(Constants.Device.GCM_TOKEN); property.setValue(registrationId); properties.add(property); } List<Device.Property> deviceInfoProperties = new ArrayList<>(); property = new Device.Property(); property.setName(Constants.Device.ENCRYPTION_STATUS); property.setValue(String.valueOf(deviceInfo.isEncryptionEnabled())); deviceInfoProperties.add(property); if ((deviceInfo.getSdkVersion() >= Build.VERSION_CODES.LOLLIPOP)) { property = new Device.Property(); property.setName(Constants.Device.PASSCODE_STATUS); property.setValue(String.valueOf(deviceInfo.isPasscodeEnabled())); deviceInfoProperties.add(property); } property = new Device.Property(); property.setName(Constants.Device.BATTERY_LEVEL); int batteryLevel = Math.round(power.getLevel()); property.setValue(String.valueOf(batteryLevel)); deviceInfoProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.MEMORY_INFO_INTERNAL_TOTAL); property.setValue(String.valueOf(phoneState.getTotalInternalMemorySize())); deviceInfoProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.MEMORY_INFO_INTERNAL_AVAILABLE); property.setValue(String.valueOf(phoneState.getAvailableInternalMemorySize())); deviceInfoProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.MEMORY_INFO_EXTERNAL_TOTAL); property.setValue(String.valueOf(phoneState.getTotalExternalMemorySize())); deviceInfoProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.MEMORY_INFO_EXTERNAL_AVAILABLE); property.setValue(String.valueOf(phoneState.getAvailableExternalMemorySize())); deviceInfoProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.NETWORK_OPERATOR); property.setValue(String.valueOf(deviceInfo.getNetworkOperatorName())); deviceInfoProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.PHONE_NUMBER); String mPhoneNumber = telephonyManager.getLine1Number(); property.setValue(mPhoneNumber); deviceInfoProperties.add(property); DeviceNetworkStatus deviceNetworkStatus = DeviceNetworkStatus.getInstance(context); if (deviceNetworkStatus.isConnectedMobile()) { telephonyManager.listen(deviceNetworkStatus, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); } String network = deviceNetworkStatus.getNetworkStatus(); if (network != null) { property = new Device.Property(); property.setName(Constants.Device.NETWORK_INFO); property.setValue(network); properties.add(property); } // adding wifi scan results.. property = new Device.Property(); property.setName(Constants.Device.WIFI_SCAN_RESULT); property.setValue(deviceNetworkStatus.getWifiScanResult()); properties.add(property); RuntimeInfo runtimeInfo = new RuntimeInfo(context); String cpuInfoPayload; try { cpuInfoPayload = mapper.writeValueAsString(runtimeInfo.getCPUInfo()); } catch (JsonProcessingException e) { String errorMsg = "Error occurred while parsing property CPU info object to json."; Log.e(TAG, errorMsg, e); throw new AndroidAgentException(errorMsg, e); } property = new Device.Property(); property.setName(Constants.Device.CPU_INFO); property.setValue(cpuInfoPayload); properties.add(property); String ramInfoPayload; try { ramInfoPayload = mapper.writeValueAsString(runtimeInfo.getRAMInfo()); } catch (JsonProcessingException e) { String errorMsg = "Error occurred while parsing property RAM info object to json."; Log.e(TAG, errorMsg, e); throw new AndroidAgentException(errorMsg, e); } property = new Device.Property(); property.setName(Constants.Device.RAM_INFO); property.setValue(ramInfoPayload); properties.add(property); List<Device.Property> batteryProperties = new ArrayList<>(); property = new Device.Property(); property.setName(Constants.Device.BATTERY_LEVEL); property.setValue(String.valueOf(power.getLevel())); batteryProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.SCALE); property.setValue(String.valueOf(power.getScale())); batteryProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.BATTERY_VOLTAGE); property.setValue(String.valueOf(power.getVoltage())); batteryProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.HEALTH); property.setValue(String.valueOf(power.getHealth())); batteryProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.STATUS); property.setValue(String.valueOf(power.getStatus())); batteryProperties.add(property); property = new Device.Property(); property.setName(Constants.Device.PLUGGED); property.setValue(String.valueOf(power.getPlugged())); batteryProperties.add(property); String batteryInfoPayload; try { batteryInfoPayload = mapper.writeValueAsString(batteryProperties); } catch (JsonProcessingException e) { String errorMsg = "Error occurred while parsing property battery info object to json."; Log.e(TAG, errorMsg, e); throw new AndroidAgentException(errorMsg, e); } property = new Device.Property(); property.setName(Constants.Device.BATTERY_INFO); property.setValue(batteryInfoPayload); properties.add(property); // building device info json payload String deviceInfoPayload; try { deviceInfoPayload = mapper.writeValueAsString(deviceInfoProperties); } catch (JsonProcessingException e) { String errorMsg = "Error occurred while parsing property object to json."; Log.e(TAG, errorMsg, e); throw new AndroidAgentException(errorMsg, e); } property = new Device.Property(); property.setName(Constants.Device.INFO); property.setValue(deviceInfoPayload); properties.add(property); device.setProperties(properties); }
From source file:com.secupwn.aimsicd.service.CellTracker.java
/** * Description: Cell Information Tracking and database logging * * TODO: update this!!/*from w w w. jav a 2s .c o m*/ * * If the "tracking" option is enabled (as it is by default) then we are keeping * a record (tracking) of the device location "gpsd_lat/lon", the connection * signal strength (rx_signal) and data activity (?) and data connection state (?). * * The items included in these are stored in the "DBi_measure" table. * * DATA_ACTIVITY: * DATA_CONNECTION_STATE: * * * UI/function: Drawer: "Toggle Cell Tracking" * * Issues: * * Notes: TODO: We also need to listen and log for: * * [ ] LISTEN_CALL_STATE: * CALL_STATE_IDLE * CALL_STATE_OFFHOOK * CALL_STATE_RINGING * * [ ] LISTEN_SERVICE_STATE: * STATE_EMERGENCY_ONLY * STATE_IN_SERVICE * STATE_OUT_OF_SERVICE * STATE_POWER_OFF * * @param track Enable/Disable tracking */ public void setCellTracking(boolean track) { if (track) { tm.listen(cellSignalListener, PhoneStateListener.LISTEN_CELL_LOCATION | // gpsd_lat/lon ? PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | // rx_signal PhoneStateListener.LISTEN_DATA_ACTIVITY | // No,In,Ou,IO,Do PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | // Di,Ct,Cd,Su PhoneStateListener.LISTEN_CELL_INFO // !? (Need API 17) ); trackingCell = true; Helpers.msgShort(context, context.getString(R.string.tracking_cell_information)); } else { tm.listen(cellSignalListener, PhoneStateListener.LISTEN_NONE); device.cell.setLon(0.0); device.cell.setLat(0.0); device.setCellInfo("[0,0]|nn|nn|"); //default entries into "locationinfo"::Connection trackingCell = false; Helpers.msgShort(context, context.getString(R.string.stopped_tracking_cell_information)); } setNotification(); }
From source file:com.wirelessmoves.cl.MainActivity.java
@Override protected void onResume() { super.onResume(); if (isListenerActive == false) { Tel.listen(MyListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); isListenerActive = true;//from w w w . j a va 2 s .c om /* start getting GPS information again */ locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gpsListener); } /* prevent the screen lock after a timeout again */ wl.acquire(); }