public static boolean isAccessibilitySettingsOn(Context context, String serviceName) { int accessibilityEnabled = 0; boolean accessibilityFound = false; try { accessibilityEnabled = Settings.Secure.getInt(context.getApplicationContext().getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED); } catch (SettingNotFoundException e) { } TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':'); if (accessibilityEnabled == 1) { String settingValue = Settings.Secure.getString(context.getApplicationContext().getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES); if (settingValue != null) { TextUtils.SimpleStringSplitter splitter = mStringColonSplitter; splitter.setString(settingValue); while (splitter.hasNext()) { String accessabilityService = splitter.next(); if (accessabilityService.equalsIgnoreCase(serviceName)) { return true; } } } } else { // Log.v(TAG, "***ACCESSIBILIY IS DISABLED***"); } return accessibilityFound; }
@Override public void onChange(boolean selfChange) { // Retrieve the current system brightness value int currentBrightness; try { currentBrightness = (int) (((PlayerActivity)mContext).getWindow().getAttributes().screenBrightness*255f); if(currentBrightness<=0) //read global brightness setting when not set on window currentBrightness = Settings.System.getInt(mContentResolver, Settings.System.SCREEN_BRIGHTNESS); } catch (SettingNotFoundException e) { currentBrightness = DEFAULT_BACKLIGHT; } // The brightness has already been applied by the system, we just need to update the slider mSeekBar.setProgress(currentBrightness - MINIMUM_BACKLIGHT); }
/** * Check if the GPS location is enabled on this device. * * @return <code>true</code> if the GPS location is enabled, <code>false</code> if it's disabled */ @SuppressWarnings("deprecation") @SuppressLint("InlinedApi") private boolean isGpsLocationEnabled() { int locationMode = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { try { locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE); } catch (SettingNotFoundException e) { Log.e(LOG_TAG, "LocationMode option is not set.", e); } return locationMode != Settings.Secure.LOCATION_MODE_OFF; } else { String locationProviders; locationProviders = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); return !TextUtils.isEmpty(locationProviders); } }
public int GetCurrentBrightness() { _logger.Debug("GetCurrentBrightness"); ContentResolver contentResolver = _context.getContentResolver(); int brightness = -1; try { Settings.System.putInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); brightness = Settings.System.getInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS); } catch (SettingNotFoundException e) { _logger.Error(e.toString()); } return brightness; }
public boolean isLocationEnabled() { int locationMode = 0; String locationProviders; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ try { locationMode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE); } catch (SettingNotFoundException e) { } return locationMode != Settings.Secure.LOCATION_MODE_OFF; } else{ locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); return !TextUtils.isEmpty(locationProviders); } }
@Override public int getActualState(Context context) { try { current = Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT); current = current < mModes[mLastIndex] ? (current <= mModes[0] ? mModes[0] : current) : mModes[mLastIndex]; } catch (final SettingNotFoundException e) { } if (current == mModes[mLastIndex]) { return STATE_ENABLED; } else if (current == mModes[0]) { return STATE_DISABLED; } else { return STATE_INTERMEDIATE; } }
@Override public int getActualState(Context context) { try { auto = android.provider.Settings.System.getInt( context.getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE); current = android.provider.Settings.System.getInt( context.getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS); current = current < mModes[mLastIndex] ? (current <= mModes[0] ? mModes[0] : current) : mModes[mLastIndex]; } catch (final SettingNotFoundException e) { } if (current == mModes[mLastIndex]) { return STATE_ENABLED; } else if (current == mModes[0]) { return STATE_DISABLED; } else { return STATE_INTERMEDIATE; } }
public static boolean D(Context paramContext) { int i1 = Build.VERSION.SDK_INT; boolean bool = false; ContentResolver localContentResolver; if (i1 >= 21) { localContentResolver = paramContext.getContentResolver(); } try { int i2 = Settings.Secure.getInt(localContentResolver, "high_text_contrast_enabled"); bool = false; if (i2 != 0) { bool = true; } return bool; } catch (Settings.SettingNotFoundException localSettingNotFoundException) {} return false; }
@TargetApi(android.os.Build.VERSION_CODES.FROYO) private void initBrightnessTouch() { float brightnesstemp = 0.6f; // Initialize the layoutParams screen brightness try { if (AndroidUtil.isFroyoOrLater() && Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) { Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); mRestoreAutoBrightness = android.provider.Settings.System.getInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS) / 255.0f; } else { brightnesstemp = android.provider.Settings.System.getInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS) / 255.0f; } } catch (SettingNotFoundException e) { e.printStackTrace(); } WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.screenBrightness = brightnesstemp; getWindow().setAttributes(lp); mIsFirstBrightnessGesture = false; }
public int backLightStatus() { int backLight=0; try { backLight = Settings.System.getInt(QtApplication.mainActivity().getContentResolver(),Settings.System.SCREEN_BRIGHTNESS); } catch (SettingNotFoundException e) { e.printStackTrace(); } if((backLight<=BRIGHTNESS_ON) && (backLight>=BRIGHTNESS_DIM)) { return 2; } else if((backLight>=BRIGHTNESS_OFF) && (backLight<=BRIGHTNESS_DIM)) { return 1; } else if(backLight==BRIGHTNESS_OFF) { return 0; } else { return -1; } }
private boolean isLocationEnabled() { int locationMode = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ try { locationMode = Secure.getInt(mContext.getContentResolver(), Secure.LOCATION_MODE); } catch (SettingNotFoundException e) { e.printStackTrace(); } return locationMode != Secure.LOCATION_MODE_OFF; } else { return isLocationEnabled_Deprecated(); } }
@SuppressLint("InlinedApi") private int getLocationMode() throws SettingNotFoundException { int apiLevel = Integer.valueOf(android.os.Build.VERSION.SDK_INT); if (apiLevel < 19) { LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); boolean isGpsEnabled = manager .isProviderEnabled(LocationManager.GPS_PROVIDER); if (isGpsEnabled) { return 3; } else { return 0; } } else { return Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE); } }
public static boolean isLocationEnabled(Context context) { int locationMode = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { try { locationMode = Secure.getInt(context.getContentResolver(), Secure.LOCATION_MODE); } catch (SettingNotFoundException e) { e.printStackTrace(); } return locationMode != Secure.LOCATION_MODE_OFF; } else { String locationProviders = Secure.getString(context.getContentResolver(), Secure.LOCATION_PROVIDERS_ALLOWED); return !locationProviders.isEmpty(); } }
private static Estimate estimateEnergyLocal(Context context, String methodName, float weight, boolean screenOn) throws NoHistoryException { // start with the local execution time Estimate result = estimateExecutionTimeLocal(context, methodName, weight); // assume that we use Max Power (Homer to the Max ;-)) for the CPU // during the execution time double power = ContextState.maxOf(context, "cpu.active"); if (screenOn) { double screen = ContextState.valueOf(context, "screen.on"); double screenFull = ContextState.valueOf(context, "screen.full"); try { power += screen + (Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS) / 255.0f) * (screenFull - screen); } catch (SettingNotFoundException e) { // assume half brightness power += screen + 0.5 * (screenFull - screen); } } result.average *= power; result.variance *= (power * power); return result; }
/** * Gets the status of the location service. * * @param context * @return */ @SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.KITKAT) public static boolean isLocationEnabled(Context context) { int locationMode = 0; String locationProviders; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ locationMode = Settings.Secure.LOCATION_MODE_OFF; try { locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE); } catch (SettingNotFoundException e) {} return locationMode != Settings.Secure.LOCATION_MODE_OFF; }else{ locationProviders = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); return !TextUtils.isEmpty(locationProviders); } }
private void initBrightnessSettings() { conRes = getContentResolver(); if(isBrightness) { try { brightnessModePref = Settings.System.getInt(conRes, Settings.System.SCREEN_BRIGHTNESS_MODE); if(brightnessModePref == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) { Settings.System.putInt(conRes, Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); } else { brightnessLevelPref = Settings.System.getInt(conRes, Settings.System.SCREEN_BRIGHTNESS); } Settings.System.putInt(conRes, Settings.System.SCREEN_BRIGHTNESS, 255); } catch(SettingNotFoundException e) { Log.e(TAG, "Cannot access system brightness settings."); e.printStackTrace(); } } }
public void playDtmf(ContentResolver r, char dtmf) { try { if (Settings.System.getInt(r, Settings.System.DTMF_TONE_WHEN_DIALING) == 0) { // audible touch disabled: don't play on speaker, only send in outgoing stream return; } } catch (SettingNotFoundException e) {} getLc().playDtmf(dtmf, -1); }
public int getBrightness() { int mOldBrightness = 0; ContentResolver cr = mcontext.getContentResolver(); try { mOldBrightness = Settings.System.getInt(cr, Settings.System.SCREEN_BRIGHTNESS); } catch (SettingNotFoundException snfe) { mOldBrightness = 255; } return mOldBrightness; }
public int getBacklightTime() { int Time = 0; ContentResolver cr = mcontext.getContentResolver(); try { Time = Settings.System.getInt(cr, Settings.System.SCREEN_OFF_TIMEOUT); } catch (SettingNotFoundException snfe) { //Log.d(tag,"error()"); } return Time; }
public int getBluetoothStatus() { int iStatus = 0; ContentResolver cr = mcontext.getContentResolver(); try { iStatus = Settings.Secure.getInt(cr, Settings.Secure.BLUETOOTH_ON); } catch (SettingNotFoundException snfe) { iStatus = 0; } return iStatus; }
public int getWiFiStatus() { int iStatus = 0; ContentResolver cr = mcontext.getContentResolver(); try { iStatus = Settings.Secure.getInt(cr, Settings.Secure.WIFI_ON); } catch (SettingNotFoundException snfe) { iStatus = 0; } return iStatus; }
private void initBrightnessTouch() { float brightnesstemp = 0.01f; try { brightnesstemp = android.provider.Settings.System.getInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS) / 255.0f; } catch (SettingNotFoundException e) { e.printStackTrace(); } WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.screenBrightness = brightnesstemp; getWindow().setAttributes(lp); mIsFirstBrightnessGesture = false; }
public int GetCurrentBrightness() { ContentResolver contentResolver = _context.getContentResolver(); int brightness = -1; try { Settings.System.putInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); brightness = Settings.System.getInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS); } catch (SettingNotFoundException e) { Logger.getInstance().Error(TAG, e.toString()); } return brightness; }
private int getScreenBrightness() { int screenBrightness = 255; try { screenBrightness = System.getInt(getActivity().getContentResolver(), "screen_brightness"); } catch (SettingNotFoundException e) { } return screenBrightness; }
/** * Finds the phone's system brightness setting. Returns 0 if there is an error * getting this setting. * * @param resolver * The ContentResolver. * @return A value between 0 and 255. */ static int getSystemBrightness(ContentResolver resolver) { // Lookup the initial system brightness. int systemBrightness = 0; try { systemBrightness = Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS); } catch (SettingNotFoundException e) { // TODO Log an error message. } return systemBrightness; }
static boolean supportsAutoBrightness(ContentResolver resolver) { // This is probably not the best way to do this. The actual capability // is stored in // com.android.internal.R.bool.config_automatic_brightness_available // which is not available through the API. try { Settings.System.getInt(resolver, SCREEN_BRIGHTNESS_MODE); return true; } catch (SettingNotFoundException e) { return false; } }
static boolean getAutoBrightnessEnabled(ContentResolver resolver) { try { int autobright = Settings.System.getInt(resolver, SCREEN_BRIGHTNESS_MODE); return autobright == SCREEN_BRIGHTNESS_MODE_AUTOMATIC; } catch (SettingNotFoundException e) { return false; } }
public void activate(MainSettingsActivity activity) { mActivity = activity; try { super.activate(activity); } catch (SettingNotFoundException e) { // this means unlock pattern was not set Log.d(TAG, "set unlock pattern first"); updateSetting(false, false, R.string.txt_set_unlock_pattern); } }
public void onStart() { // Update the current brightness value int currentBrightness; mSeekBar.setEnabled(true); try { currentBrightness = (int) (((PlayerActivity)mContext).getWindow().getAttributes().screenBrightness*255f); if(currentBrightness<=0) {//read global brightness setting when not set on window currentBrightness = Settings.System.getInt(mContentResolver, Settings.System.SCREEN_BRIGHTNESS); mSystemMode.setChecked(true); mSeekBar.setEnabled(false); if(Settings.System.getInt(mContentResolver, Settings.System.SCREEN_BRIGHTNESS_MODE)== Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) currentBrightness = MINIMUM_BACKLIGHT; } else{ mSystemMode.setChecked(false); } } catch (SettingNotFoundException e) { currentBrightness = DEFAULT_BACKLIGHT; } mSeekBar.setProgress(currentBrightness - MINIMUM_BACKLIGHT); // Start listening to system brightness changes in order to be notified in case the user // has the possibility to change the system brightness while the video is beeing played // (with the slider in the notifications panel/settings view on some devices for instance) mContentResolver.registerContentObserver(Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS), true, mBrightnessObserver); }
private void setLockRotation(boolean avpLock) { Display display = getWindowManager().getDefaultDisplay(); int rotation = display.getRotation(); if (DBG) Log.d(TAG, "rotation status: " + rotation); boolean systemLock; try { systemLock = 1 != Settings.System.getInt(getContentResolver(), Settings.System.ACCELEROMETER_ROTATION); } catch (SettingNotFoundException e) { systemLock = false; } if (DBG) Log.d(TAG, "avpLock: " + avpLock + " systemLock: " + systemLock); if (avpLock || systemLock) { int tmpOrientation = getResources().getConfiguration().orientation; int wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; if (tmpOrientation == Configuration.ORIENTATION_LANDSCAPE) { if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; else wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; setRequestedOrientation(wantedOrientation); } else if (tmpOrientation == Configuration.ORIENTATION_PORTRAIT || tmpOrientation == Configuration.ORIENTATION_UNDEFINED) { if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; else wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; setRequestedOrientation(wantedOrientation); } } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } }
private boolean isAutoBrightness() { try { return System.getInt(this.mContext.getContentResolver(), "screen_brightness_mode") == 1; } catch (SettingNotFoundException e) { e.printStackTrace(); return false; } }
private int getBrightnessLevel() { try { return System.getInt(this.mContext.getContentResolver(), "screen_brightness"); } catch (SettingNotFoundException e) { return 0; } }
@UsedForTesting static boolean isInSystemSetupWizard(final Context context) { try { final int userSetupComplete = Settings.Secure.getInt( context.getContentResolver(), Settings_Secure_USER_SETUP_COMPLETE); return userSetupComplete == USER_SETUP_IS_NOT_COMPLETE; } catch (final SettingNotFoundException e) { Log.w(TAG, "Can't find settings in Settings.Secure: key=" + Settings_Secure_USER_SETUP_COMPLETE); return false; } }
public boolean canSideLoad(){ try { int installNonMarketApps = Secure.getInt(context.getContentResolver(), Secure.INSTALL_NON_MARKET_APPS); Logger.logd( "installNonMarketApps: " + installNonMarketApps, verbose, System.out); return 1== installNonMarketApps; } catch (SettingNotFoundException e) { e.printStackTrace(); } return true; }
/** * 获取当前屏幕亮度,范围0-255 * * @param context * @return 屏幕当前亮度值 */ public static int getScreenBrightness(Context context) { int rightnessValue = 0; try { rightnessValue = Settings.System.getInt( context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS); } catch (SettingNotFoundException e) { e.printStackTrace(); } return rightnessValue; }
/** * 判断是否开启了自动亮度调节 * * @param context * @return */ public static boolean isAutomicBrightness(Context context) { boolean automicBrightness = false; try { automicBrightness = Settings.System.getInt( context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; } catch (SettingNotFoundException e) { e.printStackTrace(); } return automicBrightness; }
@Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "Received MODE_CHANGED_ACTION action"); if (locationModeChangeCallbackContext != null) { PluginResult result; try { int isLocationEnabled = BackgroundGeolocationPlugin.isLocationEnabled(context) ? 1 : 0; result = new PluginResult(PluginResult.Status.OK, isLocationEnabled); result.setKeepCallback(true); } catch (SettingNotFoundException e) { result = new PluginResult(PluginResult.Status.ERROR, "Location setting error occured"); } locationModeChangeCallbackContext.sendPluginResult(result); } }
public static boolean isLocationEnabled(Context context) throws SettingNotFoundException { int locationMode = 0; String locationProviders; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE); return locationMode != Settings.Secure.LOCATION_MODE_OFF; } else { locationProviders = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); return !TextUtils.isEmpty(locationProviders); } }