Java 类android.provider.Settings.Global 实例源码

项目:lineagex86    文件:OtherSoundSettings.java   
private void setPowerNotificationRingtone(Intent intent) {
    final Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);

    final String toneName;
    final String toneUriPath;

    if ( uri != null ) {
        final Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), uri);
        toneName = ringtone.getTitle(getActivity());
        toneUriPath = uri.toString();
    } else {
        // silent
        toneName = getString(R.string.power_notifications_ringtone_silent);
        toneUriPath = POWER_NOTIFICATIONS_SILENT_URI;
    }

    mPowerSoundsRingtone.setSummary(toneName);
    CMSettings.Global.putString(getContentResolver(),
            CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE, toneUriPath);
}
项目:lineagex86    文件:ZenModeAutomationSettings.java   
private void showAddRuleDialog() {
    new ZenRuleNameDialog(mContext, mServiceListing, null, mConfig.getAutomaticRuleNames()) {
        @Override
        public void onOk(String ruleName, RuleInfo ri) {
            MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_ADD_RULE_OK);
            final ZenRule rule = new ZenRule();
            rule.name = ruleName;
            rule.enabled = true;
            rule.zenMode = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
            rule.conditionId = ri.defaultConditionId;
            rule.component = ri.serviceComponent;
            final ZenModeConfig newConfig = mConfig.copy();
            final String ruleId = newConfig.newRuleId();
            newConfig.automaticRules.put(ruleId, rule);
            if (setZenModeConfig(newConfig)) {
                showRule(ri.settingsAction, ri.configurationActivity, ruleId, rule.name);
            }
        }
    }.show();
}
项目:lineagex86    文件:OtherSoundSettings.java   
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference == mPowerSoundsVibrate) {
        CMSettings.Global.putInt(getContentResolver(),
                CMSettings.Global.POWER_NOTIFICATIONS_VIBRATE,
                mPowerSoundsVibrate.isChecked() ? 1 : 0);

    } else if (preference == mPowerSoundsRingtone) {
        launchNotificationSoundPicker(REQUEST_CODE_POWER_NOTIFICATIONS_RINGTONE,
                CMSettings.Global.getString(getContentResolver(),
                        CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE));
    } else {
        // If we didn't handle it, let preferences handle it.
        return super.onPreferenceTreeClick(preferenceScreen, preference);
    }

    return true;
}
项目:PhoneProfiles    文件:ActivateProfileHelper.java   
private void setHeadsUpNotifications(int value) {
    if (Profile.isProfilePreferenceAllowed(Profile.PREF_PROFILE_HEADS_UP_NOTIFICATIONS, context)
            == PPApplication.PREFERENCE_ALLOWED) {
        if (android.os.Build.VERSION.SDK_INT >= 21) {
            if (Permissions.hasPermission(context, Manifest.permission.WRITE_SECURE_SETTINGS)) {
                Settings.Global.putInt(context.getContentResolver(), "heads_up_notifications_enabled", value);
            }
            else
            if (PPApplication.isRooted() && PPApplication.settingsBinaryExists()) {
                synchronized (PPApplication.startRootCommandMutex) {
                    String command1 = "settings put global " + "heads_up_notifications_enabled" + " " + value;
                    //if (PPApplication.isSELinuxEnforcing())
                    //  command1 = PPApplication.getSELinuxEnforceCommand(command1, Shell.ShellContext.SYSTEM_APP);
                    Command command = new Command(0, false, command1); //, command2);
                    try {
                        //RootTools.closeAllShells();
                        RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP).add(command);
                        commandWait(command);
                    } catch (Exception e) {
                        Log.e("ActivateProfileHelper.setHeadsUpNotifications", "Error on run su: " + e.toString());
                    }
                }
            }
        }
    }
}
项目:lineagex86    文件:ZenModeRuleSettingsBase.java   
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    mContext = getActivity();

    final Intent intent = getActivity().getIntent();
    if (DEBUG) Log.d(TAG, "onCreate getIntent()=" + intent);
    if (intent == null) {
        Log.w(TAG, "No intent");
        toastAndFinish();
        return;
    }

    mRuleId = intent.getStringExtra(EXTRA_RULE_ID);
    if (DEBUG) Log.d(TAG, "mRuleId=" + mRuleId);
    if (refreshRuleOrFinish()) {
        return;
    }

    setHasOptionsMenu(true);

    onCreateInternal();

    final PreferenceScreen root = getPreferenceScreen();
    mRuleName = root.findPreference(KEY_RULE_NAME);
    mRuleName.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            showRuleNameDialog();
            return true;
        }
    });

    mZenMode = (DropDownPreference) root.findPreference(KEY_ZEN_MODE);
    mZenMode.addItem(R.string.zen_mode_option_important_interruptions,
            Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
    mZenMode.addItem(R.string.zen_mode_option_alarms, Global.ZEN_MODE_ALARMS);
    mZenMode.addItem(R.string.zen_mode_option_no_interruptions,
            Global.ZEN_MODE_NO_INTERRUPTIONS);
    mZenMode.setCallback(new DropDownPreference.Callback() {
        @Override
        public boolean onItemSelected(int pos, Object value) {
            if (mDisableListeners) return true;
            final int zenMode = (Integer) value;
            if (zenMode == mRule.zenMode) return true;
            if (DEBUG) Log.d(TAG, "onPrefChange zenMode=" + zenMode);
            mRule.zenMode = zenMode;
            setZenModeConfig(mConfig);
            return true;
        }
    });
    mZenMode.setOrder(10);  // sort at the bottom of the category
    mZenMode.setDependency(getZenModeDependency());
}
项目:lineagex86    文件:ZenModeAutomationSettings.java   
private static String computeZenModeCaption(Resources res, int zenMode) {
    switch (zenMode) {
        case Global.ZEN_MODE_ALARMS:
            return res.getString(R.string.zen_mode_option_alarms);
        case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
            return res.getString(R.string.zen_mode_option_important_interruptions);
        case Global.ZEN_MODE_NO_INTERRUPTIONS:
            return res.getString(R.string.zen_mode_option_no_interruptions);
        default:
            return null;
    }
}
项目:lineagex86    文件:SettingPref.java   
private static Uri getUriFor(int type, String setting) {
    switch(type) {
        case TYPE_GLOBAL:
            return Global.getUriFor(setting);
        case TYPE_SYSTEM:
            return System.getUriFor(setting);
    }
    throw new IllegalArgumentException();
}
项目:lineagex86    文件:SettingPref.java   
protected static boolean putInt(int type, ContentResolver cr, String setting, int value) {
    switch(type) {
        case TYPE_GLOBAL:
            return Global.putInt(cr, setting, value);
        case TYPE_SYSTEM:
            return System.putInt(cr, setting, value);
    }
    throw new IllegalArgumentException();
}
项目:lineagex86    文件:SettingPref.java   
protected static int getInt(int type, ContentResolver cr, String setting, int def) {
    switch(type) {
        case TYPE_GLOBAL:
            return Global.getInt(cr, setting, def);
        case TYPE_SYSTEM:
            return System.getInt(cr, setting, def);
    }
    throw new IllegalArgumentException();
}
项目:lineagex86    文件:ZenModeSettingsBase.java   
private void updateZenMode(boolean fireChanged) {
    final int zenMode = Settings.Global.getInt(getContentResolver(), Global.ZEN_MODE, mZenMode);
    if (zenMode == mZenMode) return;
    mZenMode = zenMode;
    if (DEBUG) Log.d(TAG, "updateZenMode mZenMode=" + mZenMode);
    if (fireChanged) {
        onZenModeChanged();
    }
}
项目:lineagex86    文件:ZenModeVoiceActivity.java   
@Override
protected boolean onVoiceSettingInteraction(Intent intent) {
    if (intent.hasExtra(EXTRA_DO_NOT_DISTURB_MODE_ENABLED)) {
        int minutes = intent.getIntExtra(EXTRA_DO_NOT_DISTURB_MODE_MINUTES, -1);
        Condition condition = null;
        int mode = Global.ZEN_MODE_OFF;

        if (intent.getBooleanExtra(EXTRA_DO_NOT_DISTURB_MODE_ENABLED, false)) {
            if (minutes > 0) {
                condition = ZenModeConfig.toTimeCondition(this, minutes, UserHandle.myUserId());
            }
            mode = Global.ZEN_MODE_ALARMS;
        }
        setZenModeConfig(mode, condition);

        AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        if (audioManager != null) {
            // Show the current Zen Mode setting.
            audioManager.adjustStreamVolume(AudioManager.STREAM_NOTIFICATION,
                     AudioManager.ADJUST_SAME,
                     AudioManager.FLAG_SHOW_UI);
        }
        notifySuccess(getChangeSummary(mode, minutes));
    } else {
        Log.v(TAG, "Missing extra android.provider.Settings.EXTRA_DO_NOT_DISTURB_MODE_ENABLED");
        finish();
    }
    return false;
}
项目:lineagex86    文件:ZenModeVoiceActivity.java   
/**
 * Produce a summary of the Zen mode change to be read aloud as TTS.
 */
private CharSequence getChangeSummary(int mode, int minutes) {
    int indefinite = -1;
    int byMinute = -1;
    int byHour = -1;
    int byTime = -1;

    switch (mode) {
        case Global.ZEN_MODE_ALARMS:
            indefinite = R.string.zen_mode_summary_alarms_only_indefinite;
            byMinute = R.plurals.zen_mode_summary_alarms_only_by_minute;
            byHour = R.plurals.zen_mode_summary_alarms_only_by_hour;
            byTime = R.string.zen_mode_summary_alarms_only_by_time;
            break;
        case Global.ZEN_MODE_OFF:
            indefinite = R.string.zen_mode_summary_always;
            break;
    };

    if (minutes < 0 || mode == Global.ZEN_MODE_OFF) {
        return getString(indefinite);
    }

    long time = System.currentTimeMillis() + minutes * MINUTES_MS;
    String skeleton = DateFormat.is24HourFormat(this, UserHandle.myUserId()) ? "Hm" : "hma";
    String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
    CharSequence formattedTime = DateFormat.format(pattern, time);
    Resources res = getResources();

    if (minutes < 60) {
        return res.getQuantityString(byMinute, minutes, minutes, formattedTime);
    } else if (minutes % 60 != 0) {
        return res.getString(byTime, formattedTime);
    } else {
        int hours = minutes / 60;
        return res.getQuantityString(byHour, hours, hours, formattedTime);
    }
}
项目:boohee_v5.6    文件:aa.java   
@SuppressLint({"NewApi"})
public int b() {
    if (this.c != 0) {
        return this.c;
    }
    if (VERSION.SDK_INT >= 17) {
        this.c = Global.getInt(this.b.getContentResolver(), "device_provisioned", 0);
        return this.c;
    }
    this.c = Secure.getInt(this.b.getContentResolver(), "device_provisioned", 0);
    return this.c;
}
项目:FMTech    文件:InstallPolicies.java   
@TargetApi(18)
public static boolean isFreeSpaceSufficient(long paramLong, File paramFile, ContentResolver paramContentResolver)
{
  StatFs localStatFs = new StatFs(paramFile.getAbsolutePath());
  long l2;
  if (Build.VERSION.SDK_INT >= 18) {
    l2 = localStatFs.getAvailableBytes();
  }
  long l4;
  long l1;
  for (long l3 = localStatFs.getTotalBytes();; l3 = l1 * localStatFs.getBlockCount())
  {
    l4 = ((Long)G.downloadFreeSpaceThresholdBytes.get()).longValue();
    if (l4 <= 0L) {
      break;
    }
    if (l2 - paramLong * ((Integer)G.downloadFreeSpaceApkSizeFactor.get()).intValue() / 100L < l4) {
      break label196;
    }
    return true;
    l1 = localStatFs.getBlockSize();
    l2 = l1 * localStatFs.getAvailableBlocks();
  }
  int i;
  if (Build.VERSION.SDK_INT >= 17) {
    i = Settings.Global.getInt(paramContentResolver, "sys_storage_threshold_percentage", 10);
  }
  for (long l5 = Settings.Global.getLong(paramContentResolver, "sys_storage_threshold_max_bytes", 524288000L);; l5 = Settings.Secure.getLong(paramContentResolver, "sys_storage_threshold_max_bytes", 524288000L))
  {
    l4 = Math.min(l5, l3 * i / 100L);
    break;
    i = Settings.Secure.getInt(paramContentResolver, "sys_storage_threshold_percentage", 10);
  }
  label196:
  return false;
}
项目:FMTech    文件:DailyHygiene.java   
@TargetApi(17)
public static boolean isProvisioned()
{
  ContentResolver localContentResolver = FinskyApp.get().getContentResolver();
  if (Build.VERSION.SDK_INT >= 17) {}
  for (int i = Settings.Global.getInt(localContentResolver, "device_provisioned", 0);; i = Settings.Secure.getInt(localContentResolver, "device_provisioned", 0))
  {
    boolean bool = false;
    if (i != 0) {
      bool = true;
    }
    return bool;
  }
}
项目:tinytimetracker    文件:TinyTimeTracker.java   
@SuppressLint("NewApi")
public static boolean isAirplaneModeOn(Context context) {
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
        return Global.getInt(context.getContentResolver(), Global.AIRPLANE_MODE_ON, 0) != 0;
    } else {
        return System.getInt(context.getContentResolver(), System.AIRPLANE_MODE_ON, 0) != 0;
    }
}
项目:Noyze    文件:GlobalSetting.java   
public void setListening(boolean listening) {
    if (listening) {
        mContext.getContentResolver().registerContentObserver(
                Global.getUriFor(mSettingName), false, this);
    } else {
        mContext.getContentResolver().unregisterContentObserver(this);
    }
}
项目:PhoneProfiles    文件:ActivateProfileHelper.java   
@SuppressLint("NewApi")
private boolean isAirplaneMode(Context context)
{
    //if (android.os.Build.VERSION.SDK_INT >= 17)
        return Settings.Global.getInt(context.getContentResolver(), Global.AIRPLANE_MODE_ON, 0) != 0;
    /*else
        //noinspection deprecation
        return Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0;*/
}
项目:PhoneProfilesPlus    文件:ActivateProfileHelper.java   
static boolean isAirplaneMode(Context context)
{
    //if (android.os.Build.VERSION.SDK_INT >= 17)
        return Settings.Global.getInt(context.getContentResolver(), Global.AIRPLANE_MODE_ON, 0) != 0;
    //else
    //    return Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0;
}
项目:Noyze    文件:GlobalSetting.java   
public void setListening(boolean listening) {
    if (listening) {
        mContext.getContentResolver().registerContentObserver(
                Global.getUriFor(mSettingName), false, this);
    } else {
        mContext.getContentResolver().unregisterContentObserver(this);
    }
}
项目:lineagex86    文件:OtherSoundSettings.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.other_sound_settings);

    mContext = getActivity();

    // power state change notification sounds
    mPowerSoundsVibrate = (SwitchPreference) findPreference(KEY_POWER_NOTIFICATIONS_VIBRATE);
    mPowerSoundsVibrate.setChecked(CMSettings.Global.getInt(getContentResolver(),
            CMSettings.Global.POWER_NOTIFICATIONS_VIBRATE, 0) != 0);
    Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    if (vibrator == null || !vibrator.hasVibrator()) {
        removePreference(KEY_POWER_NOTIFICATIONS_VIBRATE);
    }

    mPowerSoundsRingtone = findPreference(KEY_POWER_NOTIFICATIONS_RINGTONE);
    String currentPowerRingtonePath = CMSettings.Global.getString(getContentResolver(),
            CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE);

    // set to default notification if we don't yet have one
    if (currentPowerRingtonePath == null) {
            currentPowerRingtonePath = System.DEFAULT_NOTIFICATION_URI.toString();
        CMSettings.Global.putString(getContentResolver(),
                CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE, currentPowerRingtonePath);
    }
    // is it silent ?
    if (currentPowerRingtonePath.equals(POWER_NOTIFICATIONS_SILENT_URI)) {
        mPowerSoundsRingtone.setSummary(
                getString(R.string.power_notifications_ringtone_silent));
    } else {
        final Ringtone ringtone =
                RingtoneManager.getRingtone(getActivity(), Uri.parse(currentPowerRingtonePath));
        if (ringtone != null) {
            mPowerSoundsRingtone.setSummary(ringtone.getTitle(getActivity()));
        }
    }

    for (SettingPref pref : PREFS) {
        pref.init(this);
    }
}
项目:boohee_v5.6    文件:aa.java   
@SuppressLint({"NewApi"})
public Uri c() {
    return VERSION.SDK_INT >= 17 ? Global.getUriFor("device_provisioned") : Secure.getUriFor
            ("device_provisioned");
}
项目:FMTech    文件:VerifyInstalledPackagesReceiver.java   
public void onReceive(Context paramContext, Intent paramIntent)
{
  String str = paramIntent.getAction();
  if ("com.google.android.vending.verifier.intent.action.VERIFY_INSTALLED_PACKAGES".equals(str))
  {
    int k;
    if (!((Boolean)G.platformAntiMalwareEnabled.get()).booleanValue())
    {
      FinskyLog.d("Skipping verification because disabled", new Object[0]);
      k = 0;
    }
    for (;;)
    {
      if (k != 0)
      {
        FinskyLog.d("Verify installed apps requested", new Object[0]);
        PackageVerificationService.start(paramContext, paramIntent);
      }
      return;
      if (!FinskyApp.get().mInstallPolicies.hasNetwork())
      {
        FinskyLog.d("Skipping verification because network inactive", new Object[0]);
        k = 0;
      }
      else
      {
        ContentResolver localContentResolver = paramContext.getContentResolver();
        int i;
        if (Build.VERSION.SDK_INT >= 17)
        {
          i = Settings.Global.getInt(localContentResolver, "package_verifier_enable", 1);
          label112:
          if (i == 0) {
            break label153;
          }
        }
        label153:
        for (int j = 1;; j = 0)
        {
          if (j != 0) {
            break label159;
          }
          FinskyLog.d("Skipping verification because verify apps is not enabled", new Object[0]);
          k = 0;
          break;
          i = Settings.Secure.getInt(localContentResolver, "package_verifier_enable", 1);
          break label112;
        }
        label159:
        k = 1;
      }
    }
  }
  if ("com.google.android.vending.verifier.intent.action.REMOVAL_REQUEST_RESPONSE".equals(str))
  {
    FinskyLog.d("Handle removal request responses requested", new Object[0]);
    PackageVerificationService.start(paramContext, paramIntent);
    return;
  }
  FinskyLog.w("Unexpected action %s", new Object[] { str });
}
项目:Noyze    文件:GlobalSetting.java   
public int getValue() {
    return Global.getInt(mContext.getContentResolver(), mSettingName, 0);
}
项目:Noyze    文件:GlobalSetting.java   
public void setValue(int value) {
    Global.putInt(mContext.getContentResolver(), mSettingName, value);
}
项目:PhoneProfiles    文件:ActivateProfileHelper.java   
private void setPowerSaveMode(final Profile profile) {
    if (profile._devicePowerSaveMode != 0) {
        final Context appContext = context.getApplicationContext();
        PPApplication.startHandlerThread();
        final Handler handler = new Handler(PPApplication.handlerThread.getLooper());
        handler.post(new Runnable() {
            @Override
            public void run() {
                if (Profile.isProfilePreferenceAllowed(Profile.PREF_PROFILE_DEVICE_POWER_SAVE_MODE, appContext) == PPApplication.PREFERENCE_ALLOWED) {

                    PowerManager powerManager = (PowerManager) appContext.getSystemService(POWER_SERVICE);
                    PowerManager.WakeLock wakeLock = null;
                    if (powerManager != null) {
                        wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ActivateProfileHelper.setPowerSaveMode");
                        wakeLock.acquire(10 * 60 * 1000);
                    }

                    if (powerManager != null) {
                        if (Profile.isProfilePreferenceAllowed(Profile.PREF_PROFILE_DEVICE_POWER_SAVE_MODE, appContext) == PPApplication.PREFERENCE_ALLOWED) {
                            boolean _isPowerSaveMode = false;
                            if (Build.VERSION.SDK_INT >= 21)
                                _isPowerSaveMode = powerManager.isPowerSaveMode();
                            boolean _setPowerSaveMode = false;
                            switch (profile._devicePowerSaveMode) {
                                case 1:
                                    if (!_isPowerSaveMode) {
                                        _isPowerSaveMode = true;
                                        _setPowerSaveMode = true;
                                    }
                                    break;
                                case 2:
                                    if (_isPowerSaveMode) {
                                        _isPowerSaveMode = false;
                                        _setPowerSaveMode = true;
                                    }
                                    break;
                                case 3:
                                    _isPowerSaveMode = !_isPowerSaveMode;
                                    _setPowerSaveMode = true;
                                    break;
                            }
                            if (_setPowerSaveMode) {
                                if (Permissions.hasPermission(appContext, Manifest.permission.WRITE_SECURE_SETTINGS)) {
                                    if (android.os.Build.VERSION.SDK_INT >= 21)
                                        Settings.Global.putInt(appContext.getContentResolver(), "low_power", ((_isPowerSaveMode) ? 1 : 0));
                                } else if (PPApplication.isRooted() && PPApplication.settingsBinaryExists()) {
                                    synchronized (PPApplication.startRootCommandMutex) {
                                        String command1 = "settings put global low_power " + ((_isPowerSaveMode) ? 1 : 0);
                                        Command command = new Command(0, false, command1);
                                        try {
                                            //RootTools.closeAllShells();
                                            RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP).add(command);
                                            commandWait(command);
                                        } catch (Exception e) {
                                            Log.e("ActivateProfileHelper.setPowerSaveMode", "Error on run su: " + e.toString());
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if ((wakeLock != null) && wakeLock.isHeld())
                        wakeLock.release();
                }
            }
        });
    }
}
项目:PhoneProfilesPlus    文件:ActivateProfileHelper.java   
private void setPowerSaveMode(final Profile profile, final Context context) {
    if (profile._devicePowerSaveMode != 0) {
        if (Profile.isProfilePreferenceAllowed(Profile.PREF_PROFILE_DEVICE_POWER_SAVE_MODE, context) == PPApplication.PREFERENCE_ALLOWED) {

            PowerManager powerManager = (PowerManager) context.getSystemService(POWER_SERVICE);

            if (powerManager != null) {
                //PowerManager powerManager = (PowerManager) appContext.getSystemService(POWER_SERVICE);
                boolean _isPowerSaveMode = false;
                if (Build.VERSION.SDK_INT >= 21)
                    _isPowerSaveMode = powerManager.isPowerSaveMode();
                boolean _setPowerSaveMode = false;
                switch (profile._devicePowerSaveMode) {
                    case 1:
                        if (!_isPowerSaveMode) {
                            _isPowerSaveMode = true;
                            _setPowerSaveMode = true;
                        }
                        break;
                    case 2:
                        if (_isPowerSaveMode) {
                            _isPowerSaveMode = false;
                            _setPowerSaveMode = true;
                        }
                        break;
                    case 3:
                        _isPowerSaveMode = !_isPowerSaveMode;
                        _setPowerSaveMode = true;
                        break;
                }
                if (_setPowerSaveMode) {
                    if (Permissions.hasPermission(context, Manifest.permission.WRITE_SECURE_SETTINGS)) {
                        if (android.os.Build.VERSION.SDK_INT >= 21)
                            Settings.Global.putInt(context.getContentResolver(), "low_power", ((_isPowerSaveMode) ? 1 : 0));
                    } else if (PPApplication.isRooted() && PPApplication.settingsBinaryExists()) {
                        synchronized (PPApplication.startRootCommandMutex) {
                            String command1 = "settings put global low_power " + ((_isPowerSaveMode) ? 1 : 0);
                            Command command = new Command(0, false, command1);
                            try {
                                //RootTools.closeAllShells();
                                RootTools.getShell(true, Shell.ShellContext.SYSTEM_APP).add(command);
                                commandWait(command);
                            } catch (Exception e) {
                                Log.e("ActivateProfileHelper.setPowerSaveMode", "Error on run su: " + e.toString());
                            }
                        }
                    }
                }
            }
        }
    }
}
项目:Noyze    文件:GlobalSetting.java   
public int getValue() {
    return Global.getInt(mContext.getContentResolver(), mSettingName, 0);
}
项目:Noyze    文件:GlobalSetting.java   
public void setValue(int value) {
    Global.putInt(mContext.getContentResolver(), mSettingName, value);
}