List of usage examples for android.hardware SensorManager getSensorList
public List<Sensor> getSensorList(int type)
From source file:de.da_sense.moses.client.abstraction.HardwareAbstraction.java
/** * This method reads the sensors currently chosen by the user * @return the actual Hardwareinfo/* ww w . j av a2 s .com*/ */ private HardwareInfo retrieveHardwareParameters() { // *** SENDING SET_HARDWARE_PARAMETERS REQUEST TO SERVER ***// LinkedList<Integer> sensors = new LinkedList<Integer>(); SensorManager s = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE); for (Sensor sen : s.getSensorList(Sensor.TYPE_ALL)) { sensors.add(sen.getType()); } return new HardwareInfo(extractDeviceIdFromSharedPreferences(), extractDeviceNameFromSharedPreferences(), Build.MANUFACTURER, Build.MODEL, Build.VERSION.SDK_INT, sensors); }
From source file:com.mrchandler.disableprox.ui.SensorSettingsActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sensor_setting_activity_layout); SensorManager manager = (SensorManager) getSystemService(SENSOR_SERVICE); //getSensorList returns an unmodifiable list fullSensorList = new ArrayList<>(manager.getSensorList(Sensor.TYPE_ALL)); Collections.sort(fullSensorList, new Comparator<Sensor>() { @Override/*from w ww . j ava2 s. c om*/ public int compare(Sensor lhs, Sensor rhs) { String lhsName = SensorUtil.getHumanStringType(lhs); String rhsName = SensorUtil.getHumanStringType(rhs); if (lhsName == null) { lhsName = lhs.getName(); } if (rhsName == null) { rhsName = rhs.getName(); } return lhsName.compareTo(rhsName); } }); //Set sorted sensor list for the SensorListFragment ((SensorListFragment) getSupportFragmentManager().findFragmentById(R.id.sensor_list_fragment)) .setSensors(fullSensorList); if (findViewById(R.id.drawer_layout) != null) { drawer = (DrawerLayout) findViewById(R.id.drawer_layout); toggle = new ActionBarDrawerToggle(this, (DrawerLayout) findViewById(R.id.drawer_layout), android.R.string.yes, android.R.string.no); drawer.setDrawerListener(toggle); drawer.setScrimColor(getResources().getColor(android.R.color.background_dark)); if (getActionBar() != null) { getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayShowHomeEnabled(false); } toggle.syncState(); } fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (currentFragment != null) { currentFragment.saveSettings(); } } }); ObservableScrollView scrollView = (ObservableScrollView) findViewById(R.id.scrollView); fab.attachToScrollView(scrollView); fab.hide(false); if (savedInstanceState != null) { SensorSettingsFragment fragment = (SensorSettingsFragment) getSupportFragmentManager() .getFragment(savedInstanceState, CURRENT_FRAGMENT); if (fragment != null) { getSupportFragmentManager().beginTransaction() .replace(R.id.fragment_container, fragment, CURRENT_FRAGMENT).commit(); String sensorTitle = SensorUtil.getHumanStringType(fragment.sensor); if (sensorTitle == null) { sensorTitle = fragment.sensor.getName(); } setTitle(sensorTitle); } } //Has to be done to access with XSharedPreferences. prefs = getSharedPreferences(Constants.PREFS_FILE_NAME, MODE_WORLD_READABLE); helper = new IabHelper(this, getString(R.string.google_billing_public_key)); //Has the user purchased the Pro IAP? if (!ProUtil.isPro(this)) { helper.startSetup(new IabHelper.OnIabSetupFinishedListener() { @Override public void onIabSetupFinished(IabResult result) { if (!result.isSuccess()) { Log.d(TAG, "Unable to get up In-App Billing. Oh well."); ProUtil.setFreeloadStatus(SensorSettingsActivity.this, true); return; } helper.queryInventoryAsync(new IabHelper.QueryInventoryFinishedListener() { @Override public void onQueryInventoryFinished(IabResult result, Inventory inv) { if (result.isFailure()) { ProUtil.setProStatus(SensorSettingsActivity.this, false); return; } if (inv.hasPurchase(Constants.SKU_TASKER)) { ProUtil.setProStatus(SensorSettingsActivity.this, true); } else { ProUtil.setProStatus(SensorSettingsActivity.this, false); } } }); } }); } }
From source file:org.namelessrom.devicecontrol.device.DeviceInformationSensorFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); addPreferencesFromResource(R.xml.device_information_sensor); final SensorManager sensorManager = (SensorManager) Application.get() .getSystemService(Context.SENSOR_SERVICE); // Sensors// ww w .ja v a 2 s.c om PreferenceCategory category = (PreferenceCategory) findPreference("sensors"); // we need an array list to be able to sort it, a normal list throws // java.lang.UnsupportedOperationException when sorting final ArrayList<Sensor> sensorList = new ArrayList<>(sensorManager.getSensorList(Sensor.TYPE_ALL)); Collections.sort(sensorList, new SortIgnoreCase()); for (final Sensor s : sensorList) { addPreference(category, "", s.getName(), s.getVendor()); } if (category.getPreferenceCount() == 0) { getPreferenceScreen().removePreference(category); } }
From source file:com.example.android.wearable.runtimepermissions.MainWearActivity.java
public void onClickWearBodySensors(View view) { if (mWearBodySensorsPermissionApproved) { // To keep the sample simple, we are only displaying the number of sensors. SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); List<Sensor> sensorList = sensorManager.getSensorList(Sensor.TYPE_ALL); int numberOfSensorsOnDevice = sensorList.size(); logToUi(numberOfSensorsOnDevice + " sensors on device(s)!"); } else {//from w w w . j av a2 s. c o m logToUi("Requested local permission."); // On 23+ (M+) devices, GPS permission not granted. Request permission. ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.BODY_SENSORS }, PERMISSION_REQUEST_READ_BODY_SENSORS); } }
From source file:org.jitsi.android.gui.call.ProximitySensorFragment.java
/** * {@inheritDoc}/* ww w .j av a2 s. com*/ */ @Override public void onResume() { super.onResume(); SensorManager manager = JitsiApplication.getSensorManager(); // Skips if the sensor has been already attached if (proximitySensor != null) { // Re-registers the listener as it might have been // unregistered in onPause() manager.registerListener(this, proximitySensor, SensorManager.SENSOR_DELAY_UI); return; } List<Sensor> sensors = manager.getSensorList(Sensor.TYPE_ALL); logger.trace("Device has " + sensors.size() + " sensors"); for (Sensor s : sensors) { logger.trace("Sensor " + s.getName() + " type: " + s.getType()); } this.proximitySensor = manager.getDefaultSensor(Sensor.TYPE_PROXIMITY); if (proximitySensor == null) { return; } logger.info("Using proximity sensor: " + proximitySensor.getName()); sensorDisabled = false; manager.registerListener(this, proximitySensor, SensorManager.SENSOR_DELAY_UI); }
From source file:com.example.android.wearable.runtimepermissions.MainWearActivity.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { String permissionResult = "Request code: " + requestCode + ", Permissions: " + permissions + ", Results: " + grantResults;/*from w w w . java 2s.c o m*/ Log.d(TAG, "onRequestPermissionsResult(): " + permissionResult); if (requestCode == PERMISSION_REQUEST_READ_BODY_SENSORS) { if ((grantResults.length == 1) && (grantResults[0] == PackageManager.PERMISSION_GRANTED)) { mWearBodySensorsPermissionApproved = true; mWearBodySensorsPermissionButton .setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_permission_approved, 0, 0, 0); // To keep the sample simple, we are only displaying the number of sensors. SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); List<Sensor> sensorList = sensorManager.getSensorList(Sensor.TYPE_ALL); int numberOfSensorsOnDevice = sensorList.size(); String sensorSummary = numberOfSensorsOnDevice + " sensors on this device!"; logToUi(sensorSummary); if (mPhoneRequestingWearSensorPermission) { // Resets so this isn't triggered every time permission is changed in app. mPhoneRequestingWearSensorPermission = false; // Send 'approved' message to remote phone since it started Activity. DataMap dataMap = new DataMap(); dataMap.putInt(Constants.KEY_COMM_TYPE, Constants.COMM_TYPE_RESPONSE_USER_APPROVED_PERMISSION); sendMessage(dataMap); } } else { mWearBodySensorsPermissionApproved = false; mWearBodySensorsPermissionButton .setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_permission_denied, 0, 0, 0); if (mPhoneRequestingWearSensorPermission) { // Resets so this isn't triggered every time permission is changed in app. mPhoneRequestingWearSensorPermission = false; // Send 'denied' message to remote phone since it started Activity. DataMap dataMap = new DataMap(); dataMap.putInt(Constants.KEY_COMM_TYPE, Constants.COMM_TYPE_RESPONSE_USER_DENIED_PERMISSION); sendMessage(dataMap); } } } }
From source file:org.opendatakit.sensors.manager.ODKSensorManager.java
public void initializeRegisteredSensors() { // discover built in sensors android.hardware.SensorManager builtInSensorManager = (android.hardware.SensorManager) svcContext .getSystemService(Context.SENSOR_SERVICE); if (builtInSensorManager != null) { List<android.hardware.Sensor> deviceSensors = builtInSensorManager .getSensorList(android.hardware.Sensor.TYPE_ALL); for (android.hardware.Sensor hwSensor : deviceSensors) { BuiltInSensorType sensorType = BuiltInSensorType.convertToBuiltInSensor(hwSensor.getType()); if (sensorType != null) { try { String id = sensorType.name(); //Log.d(TAG,"Found sensor "+ id); ODKSensor sensor = new ODKBuiltInSensor(sensorType, builtInSensorManager, id); sensors.put(id, sensor); } catch (Exception e) { e.printStackTrace(); }//from www .j a va 2 s . com } } } // load sensors from the database for (ChannelManager channelManager : channelManagers.values()) { CommunicationChannelType type = channelManager.getCommChannelType(); Log.d(TAG, "Load from DB:" + type.name()); List<SensorData> savedSensorList = databaseManager.sensorList(type); for (SensorData sensorData : savedSensorList) { Log.d(TAG, "Sensor in DB:" + sensorData.id + " Type:" + sensorData.type); DriverType driverType = getDriverType(sensorData.type); if (driverType != null) { Log.d(TAG, "initing sensor from DB: id: " + sensorData.id + " driverType: " + sensorData.type + " state " + sensorData.state); if (connectToDriver(sensorData.id, driverType)) { Log.d(TAG, sensorData.id + " connected to driver " + sensorData.type); if (sensorData.state == DetailedSensorState.CONNECTED) { try { channelManager.sensorConnect(sensorData.id); // updateSensorState(sensorData.id, DetailedSensorState.CONNECTED); Log.d(TAG, "connected to sensor " + sensorData.id + " over " + channelManager.getCommChannelType()); } catch (SensorNotFoundException snfe) { updateSensorState(sensorData.id, DetailedSensorState.DISCONNECTED); Log.d(TAG, "SensorNotFoundException. unable to connect to sensor " + sensorData.id + " over " + channelManager.getCommChannelType()); } } } } else { Log.e(TAG, "driver NOT FOUND for type : " + sensorData.type); } } } }
From source file:uk.ac.horizon.ubihelper.service.Service.java
@Override public void onCreate() { // One-time set-up... Log.d(TAG, "onCreate()"); // TODO//w ww . j ava 2 s.c om super.onCreate(); // handler for requests mHandler = new Handler(); // create taskbar notification int icon = R.drawable.service_notification_icon; CharSequence tickerText = getText(R.string.notification_start_message); long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); Context context = this; CharSequence contentTitle = getText(R.string.notification_title); CharSequence contentText = getText(R.string.notification_description); Intent notificationIntent = new Intent(this, MainPreferences.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); startForeground(RUNNING_ID, notification); channelManager = new ChannelManager(peerChannelFactory); // sensors if (!isEmulator()) { Log.d(TAG, "Create sensor channels..."); SensorChannel magnetic = new SensorChannel("magnetic", this, Sensor.TYPE_MAGNETIC_FIELD); channelManager.addChannel(magnetic); SensorChannel accelerometer = new SensorChannel("accelerometer", this, Sensor.TYPE_ACCELEROMETER); channelManager.addChannel(accelerometer); SensorChannel gyro = new SensorChannel("gyro", this, Sensor.TYPE_GYROSCOPE); channelManager.addChannel(gyro); SensorChannel light = new SensorChannel("light", this, Sensor.TYPE_LIGHT); channelManager.addChannel(light); SensorChannel pressure = new SensorChannel("pressure", this, Sensor.TYPE_PRESSURE); channelManager.addChannel(pressure); SensorChannel proximity = new SensorChannel("proximity", this, Sensor.TYPE_PROXIMITY); channelManager.addChannel(proximity); SensorChannel temperature = new SensorChannel("temperature", this, Sensor.TYPE_TEMPERATURE); channelManager.addChannel(temperature); try { Field f = Sensor.class.getField("TYPE_AMBIENT_TEMPERATURE"); SensorChannel sc = new SensorChannel("ambientTemperature", this, f.getInt(null)); channelManager.addChannel(sc); } catch (Exception e) { Log.d(TAG, "Could not get field Sensor.TYPE_AMBIENT_TEMPERATURE"); } try { Field f = Sensor.class.getField("TYPE_RELATIVE_HUMIDITY"); SensorChannel sc = new SensorChannel("relativeHumidity", this, f.getInt(null)); channelManager.addChannel(sc); } catch (Exception e) { Log.d(TAG, "Could not get field Sensor.TYPE_AMBIENT_TEMPERATURE"); } // all sensors by full name SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); if (sensorManager != null) { List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_ALL); for (Sensor sensor : sensors) { SensorChannel sc = new SensorChannel("sensor." + sensor.getName(), this, sensor); channelManager.addChannel(sc); } } BluetoothDiscoveryChannel btchannel = new BluetoothDiscoveryChannel(this, mHandler, "bluetooth"); channelManager.addChannel(btchannel); WifiScannerChannel wifichannel = new WifiScannerChannel(this, mHandler, "wifi"); channelManager.addChannel(wifichannel); GpsStatusChannel gpsstatus = new GpsStatusChannel("gpsstatus", this); channelManager.addChannel(gpsstatus); CellLocationChannel cellchannel = new CellLocationChannel(mHandler, this, "cell.location", false); channelManager.addChannel(cellchannel); CellLocationChannel cellchannel2 = new CellLocationChannel(mHandler, this, "cell.neighbors", true); channelManager.addChannel(cellchannel2); CellStrengthChannel cellchannel3 = new CellStrengthChannel(this, "cell.strength"); channelManager.addChannel(cellchannel3); } channelManager.addChannel(new TimeChannel(mHandler, "time")); List<String> locationProviders = LocationChannel.getAllProviders(this); for (String provider : locationProviders) { LocationChannel locchannel = new LocationChannel("location." + provider, this, provider); channelManager.addChannel(locchannel); } channelManager.addChannel(new MicChannel(mHandler, "mic")); Log.d(TAG, "Create http server..."); // http server httpPort = getPort(); httpListener = new HttpListener(this, httpPort); httpListener.start(); // peer communication peerManager = new PeerManager(this); int serverPort = peerManager.getServerPort(); channelManager.addChannel(new EnabledPeersChannel(this, peerManager, "peers")); // wifi discovery wifiDiscoveryManager = new WifiDiscoveryManager(this); wifiDiscoverable = getWifiDiscoverable(); wifiDiscoveryManager.setServerPort(serverPort); wifiDiscoveryManager.setEnabled(wifiDiscoverable); bluetooth = BluetoothAdapter.getDefaultAdapter(); if (bluetooth != null) btmac = bluetooth.getAddress(); telephony = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); if (telephony != null) imei = telephony.getDeviceId(); logManager = new LogManager(this, channelManager); logManager.checkPreferences(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.registerOnSharedPreferenceChangeListener(onRunChangeListener); Log.d(TAG, "onCreate() finished"); }
From source file:tv.piratemedia.flightcontroller.BluetoothComputerFragment.java
public void setupAtimiter() { SensorManager mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_PRESSURE); SensorEventListener sensorListener = new SensorEventListener() { @Override//from w w w. j av a2 s. com public void onSensorChanged(SensorEvent event) { if (currentPreasure > event.values[0] - 0.5 || currentPreasure < event.values[0] + 0.5) { currentPreasure = event.values[0]; currentAltitude = SensorManager.getAltitude(SensorManager.PRESSURE_STANDARD_ATMOSPHERE, currentPreasure); JSONObject msg = new JSONObject(); try { msg.put("action", "altitude_update"); msg.put("value", currentAltitude); } catch (JSONException e) { e.printStackTrace(); } sendTextMessage(msg.toString()); } } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { } }; if (sensors.size() > 0) { sensor = sensors.get(0); mSensorManager.registerListener(sensorListener, sensor, SensorManager.SENSOR_DELAY_NORMAL); } else { } }
From source file:com.landenlabs.all_devtool.SystemFragment.java
public void updateList() { // Time today = new Time(Time.getCurrentTimezone()); // today.setToNow(); // today.format(" %H:%M:%S") Date dt = new Date(); m_titleTime.setText(m_timeFormat.format(dt)); boolean expandAll = m_list.isEmpty(); m_list.clear();//from ww w . j av a 2s . com // Swap colors int color = m_rowColor1; m_rowColor1 = m_rowColor2; m_rowColor2 = color; ActivityManager actMgr = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE); try { String androidIDStr = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID); addBuild("Android ID", androidIDStr); try { AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(getContext()); final String adIdStr = adInfo.getId(); final boolean isLAT = adInfo.isLimitAdTrackingEnabled(); addBuild("Ad ID", adIdStr); } catch (IOException e) { // Unrecoverable error connecting to Google Play services (e.g., // the old version of the service doesn't support getting AdvertisingId). } catch (GooglePlayServicesNotAvailableException e) { // Google Play services is not available entirely. } /* try { InstanceID instanceID = InstanceID.getInstance(getContext()); if (instanceID != null) { // Requires a Google Developer project ID. String authorizedEntity = "<need to make this on google developer site>"; instanceID.getToken(authorizedEntity, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); addBuild("Instance ID", instanceID.getId()); } } catch (Exception ex) { } */ ConfigurationInfo info = actMgr.getDeviceConfigurationInfo(); addBuild("OpenGL", info.getGlEsVersion()); } catch (Exception ex) { m_log.e(ex.getMessage()); } try { long heapSize = Debug.getNativeHeapSize(); // long maxHeap = Runtime.getRuntime().maxMemory(); // ConfigurationInfo cfgInfo = actMgr.getDeviceConfigurationInfo(); int largHeapMb = actMgr.getLargeMemoryClass(); int heapMb = actMgr.getMemoryClass(); MemoryInfo memInfo = new MemoryInfo(); actMgr.getMemoryInfo(memInfo); final String sFmtMB = "%.2f MB"; Map<String, String> listStr = new TreeMap<String, String>(); listStr.put("Mem Available (now)", String.format(sFmtMB, (double) memInfo.availMem / MB)); listStr.put("Mem LowWhenOnlyAvail", String.format(sFmtMB, (double) memInfo.threshold / MB)); if (Build.VERSION.SDK_INT >= 16) { listStr.put("Mem Installed", String.format(sFmtMB, (double) memInfo.totalMem / MB)); } listStr.put("Heap (this app)", String.format(sFmtMB, (double) heapSize / MB)); listStr.put("HeapMax (default)", String.format(sFmtMB, (double) heapMb)); listStr.put("HeapMax (large)", String.format(sFmtMB, (double) largHeapMb)); addBuild("Memory...", listStr); } catch (Exception ex) { m_log.e(ex.getMessage()); } try { List<ProcessErrorStateInfo> procErrList = actMgr.getProcessesInErrorState(); int errCnt = (procErrList == null ? 0 : procErrList.size()); procErrList = null; // List<RunningAppProcessInfo> procList = actMgr.getRunningAppProcesses(); int procCnt = actMgr.getRunningAppProcesses().size(); int srvCnt = actMgr.getRunningServices(100).size(); Map<String, String> listStr = new TreeMap<String, String>(); listStr.put("#Processes", String.valueOf(procCnt)); listStr.put("#Proc With Err", String.valueOf(errCnt)); listStr.put("#Services", String.valueOf(srvCnt)); // Requires special permission // int taskCnt = actMgr.getRunningTasks(100).size(); // listStr.put("#Tasks", String.valueOf(taskCnt)); addBuild("Processes...", listStr); } catch (Exception ex) { m_log.e("System-Processes %s", ex.getMessage()); } try { Map<String, String> listStr = new LinkedHashMap<String, String>(); listStr.put("LargeIconDensity", String.valueOf(actMgr.getLauncherLargeIconDensity())); listStr.put("LargeIconSize", String.valueOf(actMgr.getLauncherLargeIconSize())); putIf(listStr, "isRunningInTestHarness", "Yes", ActivityManager.isRunningInTestHarness()); putIf(listStr, "isUserAMonkey", "Yes", ActivityManager.isUserAMonkey()); addBuild("Misc...", listStr); } catch (Exception ex) { m_log.e("System-Misc %s", ex.getMessage()); } // --------------- Locale / Timezone ------------- try { Locale ourLocale = Locale.getDefault(); Date m_date = new Date(); TimeZone tz = TimeZone.getDefault(); Map<String, String> localeListStr = new LinkedHashMap<String, String>(); localeListStr.put("Locale Name", ourLocale.getDisplayName()); localeListStr.put(" Variant", ourLocale.getVariant()); localeListStr.put(" Country", ourLocale.getCountry()); localeListStr.put(" Country ISO", ourLocale.getISO3Country()); localeListStr.put(" Language", ourLocale.getLanguage()); localeListStr.put(" Language ISO", ourLocale.getISO3Language()); localeListStr.put(" Language Dsp", ourLocale.getDisplayLanguage()); localeListStr.put("TimeZoneID", tz.getID()); localeListStr.put(" DayLightSavings", tz.useDaylightTime() ? "Yes" : "No"); localeListStr.put(" In DLS", tz.inDaylightTime(m_date) ? "Yes" : "No"); localeListStr.put(" Short Name", tz.getDisplayName(false, TimeZone.SHORT, ourLocale)); localeListStr.put(" Long Name", tz.getDisplayName(false, TimeZone.LONG, ourLocale)); addBuild("Locale TZ...", localeListStr); } catch (Exception ex) { m_log.e("Locale/TZ %s", ex.getMessage()); } // --------------- Location Services ------------- try { Map<String, String> listStr = new LinkedHashMap<String, String>(); final LocationManager locMgr = (LocationManager) getActivity() .getSystemService(Context.LOCATION_SERVICE); GpsStatus gpsStatus = locMgr.getGpsStatus(null); if (gpsStatus != null) { listStr.put("Sec ToGetGPS", String.valueOf(gpsStatus.getTimeToFirstFix())); Iterable<GpsSatellite> satellites = gpsStatus.getSatellites(); Iterator<GpsSatellite> sat = satellites.iterator(); while (sat.hasNext()) { GpsSatellite satellite = sat.next(); putIf(listStr, String.format("Azm:%.0f, Elev:%.0f", satellite.getAzimuth(), satellite.getElevation()), String.format("%.2f Snr", satellite.getSnr()), satellite.usedInFix()); } } Location location = null; if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { location = locMgr.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (null == location) location = locMgr.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (null == location) location = locMgr.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER); } if (null != location) { listStr.put(location.getProvider() + " lat,lng", String.format("%.3f, %.3f", location.getLatitude(), location.getLongitude())); } if (listStr.size() != 0) { List<String> gpsProviders = locMgr.getAllProviders(); int idx = 1; for (String providerName : gpsProviders) { LocationProvider provider = locMgr.getProvider(providerName); if (null != provider) { listStr.put(providerName, (locMgr.isProviderEnabled(providerName) ? "On " : "Off ") + String.format("Accuracy:%d Pwr:%d", provider.getAccuracy(), provider.getPowerRequirement())); } } addBuild("GPS...", listStr); } else addBuild("GPS", "Off"); } catch (Exception ex) { m_log.e(ex.getMessage()); } // --------------- Application Info ------------- ApplicationInfo appInfo = getActivity().getApplicationInfo(); if (null != appInfo) { Map<String, String> appList = new LinkedHashMap<String, String>(); try { appList.put("ProcName", appInfo.processName); appList.put("PkgName", appInfo.packageName); appList.put("DataDir", appInfo.dataDir); appList.put("SrcDir", appInfo.sourceDir); // appList.put("PkgResDir", getActivity().getPackageResourcePath()); // appList.put("PkgCodeDir", getActivity().getPackageCodePath()); String[] dbList = getActivity().databaseList(); if (dbList != null && dbList.length != 0) appList.put("DataBase", dbList[0]); // getActivity().getComponentName(). } catch (Exception ex) { } addBuild("AppInfo...", appList); } // --------------- Account Services ------------- final AccountManager accMgr = (AccountManager) getActivity().getSystemService(Context.ACCOUNT_SERVICE); if (null != accMgr) { Map<String, String> strList = new LinkedHashMap<String, String>(); try { for (Account account : accMgr.getAccounts()) { strList.put(account.name, account.type); } } catch (Exception ex) { m_log.e(ex.getMessage()); } addBuild("Accounts...", strList); } // --------------- Package Features ------------- PackageManager pm = getActivity().getPackageManager(); FeatureInfo[] features = pm.getSystemAvailableFeatures(); if (features != null) { Map<String, String> strList = new LinkedHashMap<String, String>(); for (FeatureInfo featureInfo : features) { strList.put(featureInfo.name, ""); } addBuild("Features...", strList); } // --------------- Sensor Services ------------- final SensorManager senMgr = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); if (null != senMgr) { Map<String, String> strList = new LinkedHashMap<String, String>(); // Sensor accelerometer = senMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); // senMgr.registerListener(foo, accelerometer, SensorManager.SENSOR_DELAY_NORMAL); List<Sensor> listSensor = senMgr.getSensorList(Sensor.TYPE_ALL); try { for (Sensor sensor : listSensor) { strList.put(sensor.getName(), sensor.getVendor()); } } catch (Exception ex) { m_log.e(ex.getMessage()); } addBuild("Sensors...", strList); } try { if (Build.VERSION.SDK_INT >= 17) { final UserManager userMgr = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); if (null != userMgr) { try { addBuild("UserName", userMgr.getUserName()); } catch (Exception ex) { m_log.e(ex.getMessage()); } } } } catch (Exception ex) { } try { Map<String, String> strList = new LinkedHashMap<String, String>(); int screenTimeout = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT); strList.put("ScreenTimeOut", String.valueOf(screenTimeout / 1000)); int rotate = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.ACCELEROMETER_ROTATION); strList.put("RotateEnabled", String.valueOf(rotate)); if (Build.VERSION.SDK_INT >= 17) { // Global added in API 17 int adb = Settings.Global.getInt(getActivity().getContentResolver(), Settings.Global.ADB_ENABLED); strList.put("AdbEnabled", String.valueOf(adb)); } addBuild("Settings...", strList); } catch (Exception ex) { } if (expandAll) { // updateList(); int count = m_list.size(); for (int position = 0; position < count; position++) m_listView.expandGroup(position); } m_adapter.notifyDataSetChanged(); }