android.provider.Settings.System Java Examples

The following examples show how to use android.provider.Settings.System. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: bt.java    From letv with Apache License 2.0 6 votes vote down vote up
private static Locale y(Context context) {
    Locale locale = null;
    try {
        Configuration configuration = new Configuration();
        configuration.setToDefaults();
        System.getConfiguration(context.getContentResolver(), configuration);
        if (configuration != null) {
            locale = configuration.locale;
        }
    } catch (Exception e) {
        bv.c(a, "fail to read user config locale");
    }
    if (locale == null) {
        return Locale.getDefault();
    }
    return locale;
}
 
Example #2
Source File: UIsUtils.java    From letv with Apache License 2.0 6 votes vote down vote up
@Nullable
private static int getMeizuNaviogationBarHeight(Context context) {
    int dimensionPixelSize;
    boolean autoHideSmartBar = true;
    boolean z = false;
    boolean isMeiZu = Build.MANUFACTURER.equals("Meizu");
    if (System.getInt(context.getContentResolver(), "mz_smartbar_auto_hide", z) != 1) {
        autoHideSmartBar = z;
    }
    if (isMeiZu && !autoHideSmartBar) {
        try {
            Class c = Class.forName("com.android.internal.R$dimen");
            dimensionPixelSize = context.getResources().getDimensionPixelSize(
                    Integer.parseInt(c.getField("mz_action_button_min_height")
                            .get(c.newInstance()).toString()));
        } catch (Throwable th) {
        }
    }
    return dimensionPixelSize;
}
 
Example #3
Source File: VolumePreference.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private void initSeekBar(SeekBar seekBar, Uri defaultUri) {
    seekBar.setMax(mAudioManager.getStreamMaxVolume(mStreamType));
    mOriginalStreamVolume = mAudioManager.getStreamVolume(mStreamType);
    seekBar.setProgress(mOriginalStreamVolume);
    seekBar.setOnSeekBarChangeListener(this);
    // TODO: removed in MM, find different approach
    mContext.getContentResolver().registerContentObserver(
            System.getUriFor("volume_ring"),
            false, mVolumeObserver);
    if (defaultUri == null) {
        if (mStreamType == AudioManager.STREAM_RING) {
            defaultUri = Settings.System.DEFAULT_RINGTONE_URI;
        } else if (mStreamType == AudioManager.STREAM_NOTIFICATION) {
            defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
        } else {
            defaultUri = Settings.System.DEFAULT_ALARM_ALERT_URI;
        }
    }
    mRingtone = RingtoneManager.getRingtone(mContext, defaultUri);
    if (mRingtone != null) {
        mRingtone.setStreamType(mStreamType);
    }
}
 
Example #4
Source File: a.java    From letv with Apache License 2.0 5 votes vote down vote up
private static String o(Context context, String str) {
    if (c(context, z[73])) {
        try {
            if (System.putString(context.getContentResolver(), z[72], str)) {
                return str;
            }
        } catch (Exception e) {
            z.e();
        }
    }
    return null;
}
 
Example #5
Source File: LanternActivity.java    From lantern with Apache License 2.0 5 votes vote down vote up
private void setScreenBrightness(int mode, int brightness) {
    System.putInt(getContentResolver(), System.SCREEN_BRIGHTNESS_MODE, mode);
    System.putInt(getContentResolver(), System.SCREEN_BRIGHTNESS, brightness);
    WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
    layoutParams.screenBrightness = brightness / (float) 255;
    getWindow().setAttributes(layoutParams);
}
 
Example #6
Source File: LanternActivity.java    From lantern with Apache License 2.0 5 votes vote down vote up
private void powerScreen(boolean turnOn) {
    if (mIsScreenOn == turnOn) {
        return;
    }

    if (turnOn) {
        mScreenBackground.startTransition(100);
        setScreenBrightness(System.SCREEN_BRIGHTNESS_MODE_MANUAL, 255);
    } else {
        setScreenBrightness(-1, -1);
        mScreenBackground.reverseTransition(100);
    }

    String screenOnText = getResources().getString(R.string.screen_on);
    String screenOffText = getResources().getString(R.string.screen_off);
    mScreenButton.setSelected(turnOn);
    mScreenButton.setText(turnOn ? screenOnText : screenOffText);

    mScreenButton.setKeepScreenOn(turnOn);

    AUTO_HIDE = turnOn;
    if (AUTO_HIDE) {
        delayedHide(AUTO_HIDE_DELAY_MILLIS);
    } else {
        mHideHandler.removeCallbacks(mHideRunnable);
    }

    mIsScreenOn = turnOn;
}
 
Example #7
Source File: LanternActivity.java    From lantern with Apache License 2.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    if (mIsScreenOn) {
        setScreenBrightness(System.SCREEN_BRIGHTNESS_MODE_MANUAL, 255);
    }
}
 
Example #8
Source File: ControlLightness.java    From dttv-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * just this method
 *
 * @param cr
 * @param value
 */
public void setBrightness(Activity cr, int value) {
    if (0 <= value && value <= 255) {
        Settings.System.putInt(cr.getContentResolver(),
                Settings.System.SCREEN_BRIGHTNESS, value); // 0-255
        value = Settings.System.getInt(cr.getContentResolver(),
                Settings.System.SCREEN_BRIGHTNESS, -1);
        // Cupcake way..... sucks
        WindowManager.LayoutParams lp = cr.getWindow().getAttributes();
        lp.screenBrightness = value;
        cr.getWindow().setAttributes(lp);
    }
}
 
Example #9
Source File: ControlLightness.java    From dttv-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param context
 * @param value
 */
public void setLightness(Activity act, int value) {
    System.putInt(act.getContentResolver(), System.SCREEN_BRIGHTNESS, value);
    try {
        WindowManager.LayoutParams lp = act.getWindow().getAttributes();
        lp.screenBrightness = (value < 0 ? 1 : value) / 255f;
        act.getWindow().setAttributes(lp);

        //saveBrightness(act,value);
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
}
 
Example #10
Source File: ControlLightness.java    From dttv-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * judge if auto open brightness
 *
 * @param context
 * @return
 */
public boolean isAutoBrightness(Context context) {
    boolean automicBrightness = false;
    ContentResolver ctr = context.getContentResolver();
    try {
        automicBrightness = Settings.System.getInt(ctr,
                Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
    } catch (SettingNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return automicBrightness;
}
 
Example #11
Source File: ModRotationFix.java    From SwipeBack with GNU General Public License v3.0 5 votes vote down vote up
static void fixOnActivityCreate(Activity activity) {
	boolean isRotationLocked = System.getInt(activity.getContentResolver(), System.ACCELEROMETER_ROTATION, 0) == 0;
	if (!isRotationLocked) {
		activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
	}
	ContentObserver observer = new RotateObserver(activity, new RotateHandler(activity));
	activity.getContentResolver().registerContentObserver(System.getUriFor(System.ACCELEROMETER_ROTATION), false, observer);
	setAdditionalInstanceField(activity, "rotateObserver", observer);
}
 
Example #12
Source File: ProgressIndicator.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/** Returns the animator duration scale from developer options setting. */
private float getSystemAnimatorDurationScale() {
  if (VERSION.SDK_INT >= 17) {
    return Global.getFloat(getContext().getContentResolver(), Global.ANIMATOR_DURATION_SCALE, 1f);
  }
  if (VERSION.SDK_INT == 16) {
    return System.getFloat(getContext().getContentResolver(), System.ANIMATOR_DURATION_SCALE, 1f);
  }
  return 1f;
}
 
Example #13
Source File: MainService.java    From always-on-amoled with GNU General Public License v3.0 5 votes vote down vote up
public void handleUncaughtException(Throwable e) {
    int reportNotificationID = 53;
    Context context = getApplicationContext();
    e.printStackTrace();
    Toast.makeText(context, R.string.error_0_unknown_error + ": " + e.getMessage(), Toast.LENGTH_SHORT).show();
    Intent intent = new Intent(context, ReporterActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    e.printStackTrace();
    intent.putExtra("log", "Message: \n" + e.getMessage() + "\n\n" + "Error: \n" + e + "\n\n" + "Stack trace: \n" + Arrays.toString(e.getStackTrace()) + "\n\n" + "Cause: \n" + e.getCause() + "\n\n" + java.lang.System.err);
    PendingIntent reportIntent = PendingIntent.getActivity(context, 0, intent, 0);
    Utils.showErrorNotification(context, context.getString(R.string.error), context.getString(R.string.error_0_unknown_error_report_prompt), reportNotificationID, reportIntent);
    java.lang.System.exit(0);
    startService(new Intent(getApplicationContext(), StarterService.class));
    setLights(OFF, false, false);
}
 
Example #14
Source File: HostMainPresenter.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public void gotoTeacher(String pattern) {
    if (VERSION.SDK_INT != 23) {
        this.mContext.startActivity((Intent) Router.invoke(this.mContext, pattern));
    } else if (System.canWrite(this.mContext)) {
        this.mContext.startActivity((Intent) Router.invoke(this.mContext, pattern));
    } else {
        Intent intent = new Intent("android.settings.action.MANAGE_WRITE_SETTINGS", Uri.parse("package:" + this.mContext.getPackageName()));
        HostNewMainActivity activity = this.mContext;
        activity.getClass();
        activity.startActivityForResult(intent, 1);
    }
}
 
Example #15
Source File: a.java    From letv with Apache License 2.0 5 votes vote down vote up
private static String n(Context context, String str) {
    if (c(context, z[73])) {
        try {
            str = System.getString(context.getContentResolver(), z[72]);
        } catch (Exception e) {
            z.e();
        }
    }
    return str;
}
 
Example #16
Source File: SettingsActivity.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onChange(boolean selfChange) {
    boolean enabled = Settings.System.getInt(mResolver,
            Settings.System.ACCELEROMETER_ROTATION, 1) == 1;
    mRotationPref.setEnabled(enabled);
    mRotationPref.setSummary(enabled
            ? R.string.allow_rotation_desc : R.string.allow_rotation_blocked_desc);
}
 
Example #17
Source File: TextKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void initPrefs(Context context) {
    final ContentResolver contentResolver = context.getContentResolver();
    mResolver = new WeakReference<ContentResolver>(contentResolver);
    if (mObserver == null) {
        mObserver = new SettingsObserver();
        contentResolver.registerContentObserver(Settings.System.CONTENT_URI, true, mObserver);
    }

    updatePrefs(contentResolver);
    mPrefsInited = true;
}
 
Example #18
Source File: TextKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void updatePrefs(ContentResolver resolver) {
    boolean cap = System.getInt(resolver, System.TEXT_AUTO_CAPS, 1) > 0;
    boolean text = System.getInt(resolver, System.TEXT_AUTO_REPLACE, 1) > 0;
    boolean period = System.getInt(resolver, System.TEXT_AUTO_PUNCTUATE, 1) > 0;
    boolean pw = System.getInt(resolver, System.TEXT_SHOW_PASSWORD, 1) > 0;

    mPrefs = (cap ? AUTO_CAP : 0) |
             (text ? AUTO_TEXT : 0) |
             (period ? AUTO_PERIOD : 0) |
             (pw ? SHOW_PASSWORD : 0);
}
 
Example #19
Source File: SeekBarVolumizer.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public SeekBarVolumizer(Context context, int streamType, Uri defaultUri, Callback callback) {
    mContext = context;
    mAudioManager = context.getSystemService(AudioManager.class);
    mNotificationManager = context.getSystemService(NotificationManager.class);
    mNotificationPolicy = mNotificationManager.getNotificationPolicy();
    mAllowAlarms = (mNotificationPolicy.priorityCategories & NotificationManager.Policy
            .PRIORITY_CATEGORY_ALARMS) != 0;
    mAllowMedia = (mNotificationPolicy.priorityCategories & NotificationManager.Policy
            .PRIORITY_CATEGORY_MEDIA) != 0;
    mAllowRinger = !ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(
            mNotificationPolicy);
    mStreamType = streamType;
    mAffectedByRingerMode = mAudioManager.isStreamAffectedByRingerMode(mStreamType);
    mNotificationOrRing = isNotificationOrRing(mStreamType);
    if (mNotificationOrRing) {
        mRingerMode = mAudioManager.getRingerModeInternal();
    }
    mZenMode = mNotificationManager.getZenMode();
    mMaxStreamVolume = mAudioManager.getStreamMaxVolume(mStreamType);
    mCallback = callback;
    mOriginalStreamVolume = mAudioManager.getStreamVolume(mStreamType);
    mLastAudibleStreamVolume = mAudioManager.getLastAudibleStreamVolume(mStreamType);
    mMuted = mAudioManager.isStreamMute(mStreamType);
    if (mCallback != null) {
        mCallback.onMuted(mMuted, isZenMuted());
    }
    if (defaultUri == null) {
        if (mStreamType == AudioManager.STREAM_RING) {
            defaultUri = Settings.System.DEFAULT_RINGTONE_URI;
        } else if (mStreamType == AudioManager.STREAM_NOTIFICATION) {
            defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
        } else {
            defaultUri = Settings.System.DEFAULT_ALARM_ALERT_URI;
        }
    }
    mDefaultUri = defaultUri;
}
 
Example #20
Source File: a.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void c(Context context, String str, String str2) {
    if (g(context)) {
        Notification notification;
        z.b();
        Intent intent = new Intent(context, PushReceiver.class);
        intent.setAction(z[69]);
        intent.putExtra(z[70], true);
        intent.putExtra(z[71], str2);
        PendingIntent broadcast = PendingIntent.getBroadcast(context, 0, intent, 134217728);
        NotificationManager notificationManager = (NotificationManager) context.getSystemService(z[68]);
        int i = -1;
        try {
            i = context.getPackageManager().getPackageInfo(context.getPackageName(), 256).applicationInfo.icon;
        } catch (NameNotFoundException e) {
        }
        if (i < 0) {
            i = 17301586;
        }
        Object obj = z[67];
        Object obj2 = z[66];
        long currentTimeMillis = System.currentTimeMillis();
        if (VERSION.SDK_INT >= 11) {
            notification = new Builder(context.getApplicationContext()).setContentTitle(obj).setContentText(obj2).setContentIntent(broadcast).setSmallIcon(i).setTicker(str).setWhen(currentTimeMillis).getNotification();
            notification.flags = 34;
        } else {
            Notification notification2 = new Notification(i, str, currentTimeMillis);
            notification2.flags = 34;
            m.a(notification2, context, obj, obj2, broadcast);
            notification = notification2;
        }
        if (notification != null) {
            notificationManager.notify(str.hashCode(), notification);
        }
    }
}
 
Example #21
Source File: AlbumGestureController.java    From letv with Apache License 2.0 5 votes vote down vote up
private int getScreenBrightness() {
    int screenBrightness = 255;
    try {
        screenBrightness = System.getInt(this.mActivity.getContentResolver(), "screen_brightness");
    } catch (Exception exception) {
        exception.printStackTrace();
    }
    return screenBrightness;
}
 
Example #22
Source File: BasePlayController.java    From letv with Apache License 2.0 5 votes vote down vote up
public BasePlayController(Context context, PlayActivityCallback playCallback) {
    if (HotFix.PREVENT_VERIFY) {
        System.out.println(VerifyLoad.class);
    }
    this.mLaunchMode = 0;
    this.mLiveBarrageSentCallback = null;
    this.currentB = 0;
    this.mContext = context;
    this.mPlayCallback = playCallback;
}
 
Example #23
Source File: BasePlayController.java    From letv with Apache License 2.0 5 votes vote down vote up
private int getScreenBrightness() {
    int screenBrightness = 255;
    try {
        screenBrightness = System.getInt(getActivity().getContentResolver(), "screen_brightness");
    } catch (SettingNotFoundException e) {
    }
    return screenBrightness;
}
 
Example #24
Source File: Device.java    From letv with Apache License 2.0 5 votes vote down vote up
public static String getFreeCallDeviceId(Context context) {
    if (!TextUtils.isEmpty(m2)) {
        return m2;
    }
    String imei = getIMEI(context);
    String AndroidID = System.getString(context.getContentResolver(), "android_id");
    String _m2 = getMD5("" + imei + AndroidID + getDeviceSerialForMid2());
    m2 = _m2;
    return _m2;
}
 
Example #25
Source File: a.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void b(Context context, String str, String str2, int i) {
    Notification notification;
    Intent intent = new Intent(context, PushReceiver.class);
    intent.setAction(z[69]);
    intent.putExtra(z[70], true);
    intent.putExtra(z[96], str2);
    intent.putExtra(z[11], i);
    PendingIntent broadcast = PendingIntent.getBroadcast(context, 0, intent, 134217728);
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(z[68]);
    int i2 = -1;
    try {
        i2 = context.getPackageManager().getPackageInfo(context.getPackageName(), 256).applicationInfo.icon;
    } catch (NameNotFoundException e) {
    }
    if (i2 < 0) {
        i2 = 17301586;
    }
    Object obj = z[95];
    Object obj2 = z[94];
    long currentTimeMillis = System.currentTimeMillis();
    if (VERSION.SDK_INT >= 11) {
        notification = new Builder(context.getApplicationContext()).setContentTitle(obj).setContentText(obj2).setContentIntent(broadcast).setSmallIcon(i2).setTicker(str).setWhen(currentTimeMillis).getNotification();
        notification.flags = 34;
    } else {
        Notification notification2 = new Notification(i2, str, currentTimeMillis);
        notification2.flags = 34;
        m.a(notification2, context, obj, obj2, broadcast);
        notification = notification2;
    }
    if (notification != null) {
        notificationManager.notify(str.hashCode(), notification);
    }
}
 
Example #26
Source File: ModRotationFix.java    From SwipeBack with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onChange(boolean selfChange) {
	boolean isRotationLocked = (System.getInt(mActivity.getContentResolver(), System.ACCELEROMETER_ROTATION, 0) == 0);
	mHandler.sendMessage(mHandler.obtainMessage(0, isRotationLocked));
}
 
Example #27
Source File: Device.java    From letv with Apache License 2.0 4 votes vote down vote up
private static boolean putSettingsString(Context context, String deviceId) {
    ContentResolver resolver = context.getContentResolver();
    boolean ok = System.putString(resolver, KEY_DEVICE_ID, deviceId);
    System.putString(resolver, "persit.coolcloud.devid", deviceId);
    return ok;
}
 
Example #28
Source File: SettingsActivity.java    From LaunchEnr with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getPreferenceManager().setSharedPreferencesName(LauncherFiles.SHARED_PREFERENCES_KEY);
    addPreferencesFromResource(R.xml.launcher_preferences);

    ContentResolver resolver = getActivity().getContentResolver();

    // Setup allow rotation preference
    Preference rotationPref = findPreference(PreferenceKeys.ALLOW_ROTATION_PREFERENCE_KEY);

    mRotationLockObserver = new SystemDisplayRotationLockObserver(rotationPref, resolver);

    // Register a content observer to listen for system setting changes while
    // this UI is active.
    resolver.registerContentObserver(
            Settings.System.getUriFor(System.ACCELEROMETER_ROTATION),
            false, mRotationLockObserver);

    // Initialize the UI once
    mRotationLockObserver.onChange(true);
    rotationPref.setDefaultValue(PreferencesState.getAllowRotationDefaultValue(getActivity()));

    Preference iconBadgingPref = findPreference(ICON_BADGING_PREFERENCE_KEY);

    Preference iconShapeOverride = findPreference(IconShapeOverride.KEY_PREFERENCE);

    if (AndroidVersion.isAtLeastOreo()) {

        // Listen to system notification badge settings while this UI is active.
        mIconBadgingObserver = new IconBadgingObserver(iconBadgingPref, resolver);
        resolver.registerContentObserver(
                Settings.Secure.getUriFor(NOTIFICATION_BADGING),
                false, mIconBadgingObserver);
        mIconBadgingObserver.onChange(true);
    }

    if (!AndroidVersion.isAtLeastOreo()) {
        setOreoSupportSum(iconShapeOverride, iconBadgingPref);
    }

    if (iconShapeOverride != null) {

        IconShapeOverride.handlePreferenceUi((ListPreference) iconShapeOverride);
    }

    Preference hideAppPreference = findPreference(HiddenAppUtils.KEY_HIDDEN_APPS);

    hideAppPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            Intent intent = new Intent(getActivity(), MultiSelectRecyclerViewActivity.class);
            startActivity(intent);
            return false;
        }
    });

    disableRoundIcons();

    mListenerOptions = new SharedPreferences.OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {

            switch (key) {
                case PreferenceKeys.THEME_PREFERENCE_KEY:
                    getActivity().recreate();
                    break;

                case PreferenceKeys.CHOOSE_THEME_PREFERENCE_KEY:
                    getActivity().recreate();
                    break;

                case PreferenceKeys.SHOW_BADGE_PREFERENCE_KEY:

                    //remove badge options if notifications are not enabled
                    if (PreferencesState.isShowBadgePrefEnabled(getActivity())) {

                        PermissionUtils.checkNotificationAccess(getActivity());
                    }
                    break;

                case IconsManager.ICON_PACK_PREFERENCE_KEY:

                    disableRoundIcons();

                    IconsManager.switchIconPacks(Utilities.getPrefs(getActivity()).getString(IconsManager.ICON_PACK_PREFERENCE_KEY, ""), getActivity());

                    //reload settings if (wtf)user clicks icons tile from settings ... - . =?
                    if (RandomIconsTile.fromTile) {
                        getActivity().recreate();
                        RandomIconsTile.fromTile = false;
                    }
                    break;

            }
        }
    };
}
 
Example #29
Source File: Device.java    From letv with Apache License 2.0 4 votes vote down vote up
private static String getSettingsString(Context context) {
    ContentResolver resolver = context.getContentResolver();
    String value = System.getString(resolver, KEY_DEVICE_ID);
    return empty(value) ? System.getString(resolver, "persit.coolcloud.devid") : value;
}
 
Example #30
Source File: ControlLightness.java    From dttv-android with GNU General Public License v3.0 2 votes vote down vote up
/**
 * get lightness
 *
 * @param cr
 * @return
 */
public int getLightness(Activity cr) {
    return Settings.System.getInt(cr.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 255);
}