Пример #1
0
 /**
  * Sets the radio power on/off state (off is sometimes called "airplane mode"). Current state can
  * be gotten via getServiceState(). getState(). Note: This request is asynchronous.
  * getServiceState().getState() will not change immediately after this call.
  * registerForServiceStateChanged() to find out when the request is complete.
  *
  * @param phone
  * @param isRadioOn
  * @param contentResolver
  */
 public static void setRadioMode(Phone phone, boolean enabled, ContentResolver contentResolver) {
   if (GeminiUtils.isGeminiSupport()) {
     if (enabled) {
       ((GeminiPhone) phone).setRadioMode(GeminiNetworkSubUtil.MODE_FLIGHT_MODE);
     } else {
       int dualSimModeSetting =
           System.getInt(
               contentResolver, System.DUAL_SIM_MODE_SETTING, GeminiNetworkSubUtil.MODE_DUAL_SIM);
       ((GeminiPhone) phone).setRadioMode(dualSimModeSetting);
     }
   } else {
     /// M: consistent UI @{
     // SIM Management for single sim project
     if (!enabled) {
       int simModeSetting =
           System.getInt(
               contentResolver, System.DUAL_SIM_MODE_SETTING, GeminiNetworkSubUtil.MODE_SIM1_ONLY);
       if (simModeSetting == GeminiNetworkSubUtil.MODE_FLIGHT_MODE) {
         PhoneLog.d(
             TAG, "Turn off airplane mode, but Radio still off due to sim mode setting is off");
         enabled = true;
       }
     }
     /// @}
     phone.setRadioPower(!enabled);
   }
 }
Пример #2
0
 private void updateUIFromPreferences() {
   int var1 = System.getInt(this.mContentResolver, "psm_battery_level", 50);
   ListPreference var2 = this.mModeValueSetting;
   Context var3 = this.getApplicationContext();
   Object[] var4 = new Object[1];
   StringBuilder var5 = new StringBuilder();
   String var6 = String.valueOf(var1);
   String var7 = var5.append(var6).append("%").toString();
   var4[0] = var7;
   String var8 = var3.getString(2131232375, var4);
   var2.setSummary(var8);
   int var9 = System.getInt(this.mContentResolver, "psm_brightness_level", 10);
   ListPreference var10 = this.mBrightnessSetting;
   Context var11 = this.getApplicationContext();
   Object[] var12 = new Object[1];
   StringBuilder var13 = new StringBuilder();
   String var14 = String.valueOf(var9);
   String var15 = var13.append(var14).append("%").toString();
   var12[0] = var15;
   String var16 = var11.getString(2131232387, var12);
   var10.setSummary(var16);
   boolean var17 = this.mEnableMode.isChecked();
   this.mModeValueSetting.setEnabled(var17);
   this.mDisableWifi.setEnabled(var17);
   this.mDisableBluetooth.setEnabled(var17);
   this.mDisableGps.setEnabled(var17);
   this.mDisableSync.setEnabled(var17);
   this.mAdjustBrightness.setEnabled(var17);
   this.toggleBrightnessSetting(var17);
   this.mScreentimeout.setEnabled(var17);
 }
Пример #3
0
  public boolean onPreferenceChange(Preference var1, Object var2) {
    ListPreference var3 = this.mModeValueSetting;
    boolean var15;
    if (var1.equals(var3)) {
      int var4 = Log.d("PowerSavingModeSettings", "set battery level is changed");
      int var5 = Integer.parseInt((String) var2);
      System.putInt(this.mContentResolver, "psm_battery_level", var5);
      ListPreference var7 = this.mModeValueSetting;
      Context var8 = this.getApplicationContext();
      Object[] var9 = new Object[1];
      StringBuilder var10 = new StringBuilder();
      String var11 = var2.toString();
      String var12 = var10.append(var11).append("%").toString();
      var9[0] = var12;
      String var13 = var8.getString(2131232375, var9);
      var7.setSummary(var13);
      Intent var14 = new Intent("android.settings.POWERSAVING_CHANGED");
      this.sendBroadcast(var14);
      var15 = true;
    } else {
      ListPreference var16 = this.mBrightnessSetting;
      if (var1.equals(var16)) {
        int var17 = Log.d("PowerSavingModeSettings", "Brightness level is changed");
        int var18 = Integer.parseInt((String) var2);
        System.putInt(this.mContentResolver, "psm_brightness_level", var18);
        ListPreference var20 = this.mBrightnessSetting;
        Context var21 = this.getApplicationContext();
        Object[] var22 = new Object[1];
        StringBuilder var23 = new StringBuilder();
        String var24 = var2.toString();
        String var25 = var23.append(var24).append("%").toString();
        var22[0] = var25;
        String var26 = var21.getString(2131232387, var22);
        var20.setSummary(var26);
        var15 = true;
      } else {
        ListPreference var27 = this.mScreentimeout;
        if (var1.equals(var27)) {
          int var28 = Log.d("PowerSavingModeSettings", "Screentimeout is changed");
          int var29 = Integer.parseInt((String) var2);
          System.putInt(this.mContentResolver, "psm_screen_timeout", var29);
          var15 = true;
        } else {
          var15 = false;
        }
      }
    }

    return var15;
  }
  @Override
  public void onResume() {
    super.onResume();

    mSettingsObserver.resume();
    mIm.registerInputDeviceListener(this, null);

    if (!mIsOnlyImeSettings) {
      if (mLanguagePref != null) {
        Configuration conf = getResources().getConfiguration();
        String language = conf.locale.getLanguage();
        String localeString;
        // TODO: This is not an accurate way to display the locale, as it is
        // just working around the fact that we support limited dialects
        // and want to pretend that the language is valid for all locales.
        // We need a way to support languages that aren't tied to a particular
        // locale instead of hiding the locale qualifier.
        if (hasOnlyOneLanguageInstance(language, Resources.getSystem().getAssets().getLocales())) {
          localeString = conf.locale.getDisplayLanguage(conf.locale);
        } else {
          localeString = conf.locale.getDisplayName(conf.locale);
        }
        if (localeString.length() > 1) {
          localeString = Character.toUpperCase(localeString.charAt(0)) + localeString.substring(1);
          mLanguagePref.setSummary(localeString);
        }
      }

      updateUserDictionaryPreference(findPreference(KEY_USER_DICTIONARY_SETTINGS));
      if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) {
        mShowInputMethodSelectorPref.setOnPreferenceChangeListener(this);
      }
    }

    if (mStatusBarImeSwitcher != null) {
      mStatusBarImeSwitcher.setChecked(
          Settings.System.getInt(
                  getActivity().getContentResolver(), Settings.System.STATUS_BAR_IME_SWITCHER, 1)
              != 0);
    }

    // Hard keyboard
    if (!mHardKeyboardPreferenceList.isEmpty()) {
      for (int i = 0; i < sHardKeyboardKeys.length; ++i) {
        CheckBoxPreference chkPref =
            (CheckBoxPreference) mHardKeyboardCategory.findPreference(sHardKeyboardKeys[i]);
        chkPref.setChecked(System.getInt(getContentResolver(), sSystemSettingNames[i], 1) > 0);
      }
    }

    updateInputDevices();

    // IME
    InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(this, getContentResolver(), mImis, null);
    updateActiveInputMethodsSummary();
  }
 @Override
 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
   // Input Method stuff
   if (Utils.isMonkeyRunning()) {
     return false;
   }
   if (preference == mStatusBarImeSwitcher) {
     Settings.System.putInt(
         getActivity().getContentResolver(),
         Settings.System.STATUS_BAR_IME_SWITCHER,
         mStatusBarImeSwitcher.isChecked() ? 1 : 0);
     return true;
   } else if (preference instanceof PreferenceScreen) {
     if (preference.getFragment() != null) {
       // Fragment will be handled correctly by the super class.
     } else if (KEY_CURRENT_INPUT_METHOD.equals(preference.getKey())) {
       final InputMethodManager imm =
           (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
       imm.showInputMethodPicker();
     }
   } else if (preference instanceof CheckBoxPreference) {
     final CheckBoxPreference chkPref = (CheckBoxPreference) preference;
     if (!mHardKeyboardPreferenceList.isEmpty()) {
       for (int i = 0; i < sHardKeyboardKeys.length; ++i) {
         if (chkPref == mHardKeyboardCategory.findPreference(sHardKeyboardKeys[i])) {
           System.putInt(
               getContentResolver(), sSystemSettingNames[i], chkPref.isChecked() ? 1 : 0);
           return true;
         }
       }
     }
     if (chkPref == mGameControllerCategory.findPreference("vibrate_input_devices")) {
       System.putInt(
           getContentResolver(),
           Settings.System.VIBRATE_INPUT_DEVICES,
           chkPref.isChecked() ? 1 : 0);
       return true;
     }
   }
   return super.onPreferenceTreeClick(preferenceScreen, preference);
 }
  private void updateGameControllers() {
    if (haveInputDeviceWithVibrator()) {
      getPreferenceScreen().addPreference(mGameControllerCategory);

      CheckBoxPreference chkPref =
          (CheckBoxPreference) mGameControllerCategory.findPreference("vibrate_input_devices");
      chkPref.setChecked(
          System.getInt(getContentResolver(), Settings.System.VIBRATE_INPUT_DEVICES, 1) > 0);
    } else {
      getPreferenceScreen().removePreference(mGameControllerCategory);
    }
  }
Пример #7
0
  @Override
  public void onStart() {
    super.onStart();

    final Activity activity = getActivity();

    mMassStorageActive = isUMSEnabled();
    Xlog.d(TAG, "mMassStorageActive = " + mMassStorageActive);
    mTetherChangeReceiver = new TetherChangeReceiver();
    IntentFilter filter = new IntentFilter(ConnectivityManager.ACTION_TETHER_STATE_CHANGED);
    Intent intent = activity.registerReceiver(mTetherChangeReceiver, filter);

    filter = new IntentFilter();
    filter.addAction(UsbManager.ACTION_USB_STATE);
    activity.registerReceiver(mTetherChangeReceiver, filter);

    filter = new IntentFilter();
    filter.addAction(Intent.ACTION_MEDIA_SHARED);
    filter.addAction(Intent.ACTION_MEDIA_UNSHARED);
    filter.addDataScheme("file");
    activity.registerReceiver(mTetherChangeReceiver, filter);

    filter = new IntentFilter();
    filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
    activity.registerReceiver(mTetherChangeReceiver, filter);

    filter = new IntentFilter();
    filter.addAction(USB_DATA_STATE);
    activity.registerReceiver(mTetherChangeReceiver, filter);

    /// M: @{
    filter = new IntentFilter();
    filter.addAction(BluetoothPan.ACTION_CONNECTION_STATE_CHANGED);
    filter.addAction(BluetoothDun.STATE_CHANGED_ACTION);
    activity.registerReceiver(mTetherChangeReceiver, filter);
    /// @}

    if (intent != null) {
      mTetherChangeReceiver.onReceive(activity, intent);
    }
    if (mUsbTetherType != null) {
      mUsbTetherType.setOnPreferenceChangeListener(this);
      int value =
          System.getInt(
              getContentResolver(), System.USB_TETHERING_TYPE, System.USB_TETHERING_TYPE_DEFAULT);
      mUsbTetherType.setValue(String.valueOf(value));
      mUsbTetherType.setSummary(
          getResources().getStringArray(R.array.usb_tether_type_entries)[value]);
    }
    updateState();
  }
  public void createSeekBar(View customView) {
    SeekBar brightbar = (SeekBar) customView.findViewById(R.id.seekBar_light);
    brightbar.setMax(255);
    brightbar.setProgress(200);
    try {
      // get the current system brightness
      brightness = System.getInt(this.getContentResolver(), System.SCREEN_BRIGHTNESS);
      brightbar.setProgress(SettingUtils.getSetting(ComicImageViewActivity.this, "light", 125));
    } catch (SettingNotFoundException e) {
      Toast.makeText(this, "不能获取系统亮度", Toast.LENGTH_SHORT).show();
      return;
    }
    // register OnSeekBarChangeListener, so it can actually change values
    brightbar.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {
          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
            // set the system brightness using the brightness variable value
            // if(Settings.System.getInt(cResolver,
            // Settings.System.SCREEN_BRIGHTNESS_MODE) ==
            // Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC)
            // System.putInt(cResolver, System.SCREEN_BRIGHTNESS,
            // brightness);

            // preview brightness changes at this window
            // get the current window attributes
            LayoutParams layoutpars = getWindow().getAttributes();
            // set the brightness of this window
            layoutpars.screenBrightness = brightness / (float) 255;
            // apply attribute changes to this window
            getWindow().setAttributes(layoutpars);
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // sets the minimal brightness level
            // if seek bar is 20 or any value below
            if (progress <= 10) {
              // set the brightness to 20
              brightness = 10;
            } else // brightness is greater than 20
            {
              // sets brightness variable based on the progress bar
              brightness = progress;
            }
          }
        });
  }
Пример #9
0
  public boolean onPreferenceChange(Preference preference, Object value) {
    String key = preference.getKey();
    Xlog.d(TAG, "onPreferenceChange key=" + key);
    if (TETHERED_IPV6.equals(key)) {
      /// M: save value to provider @{
      ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
      int ipv6Value = Integer.parseInt(String.valueOf(value));
      if (cm != null) {
        cm.setTetheringIpv6Enable(ipv6Value == 1);
      }
      mTetherIpv6.setValueIndex(ipv6Value);
      mTetherIpv6.setSummary(
          getResources().getStringArray(R.array.tethered_ipv6_entries)[ipv6Value]);
      /// @}
    } else if (USB_TETHERING_TYPE.equals(key)) {
      int index = Integer.parseInt(((String) value));
      System.putInt(getContentResolver(), System.USB_TETHERING_TYPE, index);
      mUsbTetherType.setSummary(
          getResources().getStringArray(R.array.usb_tether_type_entries)[index]);

      Xlog.d(TAG, "onPreferenceChange USB_TETHERING_TYPE value = " + index);
    }
    return true;
  }
 private boolean isAirplaneModeOn() {
   return (System.getInt(getContentResolver(), System.AIRPLANE_MODE_ON, 0) != 0);
 }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_brightness);
    String roman = "fonts/Regular.otf";
    String medium = "fonts/Medium.otf";
    String thin = "fonts/Thin.otf";
    String bold = "fonts/Bold.otf";
    typefaceRoman = Typeface.createFromAsset(getAssets(), roman);
    typefaceMedium = Typeface.createFromAsset(getAssets(), medium);
    Typeface typefaceThin = Typeface.createFromAsset(getAssets(), thin);
    typefaceBold = Typeface.createFromAsset(getAssets(), bold);
    textStatus = (TextView) findViewById(R.id.textOk);
    textView1 = (TextView) findViewById(R.id.textView1);
    textView2 = (TextView) findViewById(R.id.textView2);

    btn_back = (Button) findViewById(R.id.buttonBack);
    btn_back.setText(R.string.app_name);
    btn_textSize = (Button) findViewById(R.id.ButtonTextSize);
    btn_textSize.setOnClickListener(this);
    btn_textBold = (Button) findViewById(R.id.ButtonTextBold);
    brtn1 = (Button) findViewById(R.id.brtn1);
    tb_bold = (ToggleButton) findViewById(R.id.ToggleButtonBoldText);
    tb_bold.setOnClickListener(this);
    Button01 = (Button) findViewById(R.id.Button01);
    Button01.setOnClickListener(this);

    mSettings = getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);

    detector = new SimpleGestureFilter(this, this);

    textStatus.setText(R.string.button_brightness);
    textStatus.setTypeface(typefaceBold);
    btn_back.setTypeface(typefaceMedium);
    textView1.setTypeface(typefaceRoman);
    textView2.setTypeface(typefaceRoman);
    brtn1.setTypeface(typefaceRoman);

    Button01.setTypeface(typefaceRoman);
    btn_textSize.setTypeface(typefaceRoman);
    btn_textBold.setTypeface(typefaceRoman);

    tb_brtns = (ToggleButton) findViewById(R.id.brtntoggle);
    tb_brtns.setOnClickListener(this);
    brightbar = (SeekBar) findViewById(R.id.brightbar);
    txtPerc = (TextView) findViewById(R.id.txtPercentage);
    cResolver = getContentResolver();
    window = getWindow();
    brightbar.setMax(255);
    brightbar.setKeyProgressIncrement(1);

    try {
      // Get the current system brightness
      brightness = System.getInt(cResolver, System.SCREEN_BRIGHTNESS);
    } catch (SettingNotFoundException e) {
      // Throw an error case it couldn't be retrieved
      Log.e("Error", "Cannot access system brightness");
      e.printStackTrace();
    }
    brightbar.setProgress(brightness);

    brightbar.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {
          public void onStopTrackingTouch(SeekBar seekBar) {
            // Set the system brightness using the brightness variable value
            System.putInt(cResolver, System.SCREEN_BRIGHTNESS, brightness);
            // Get the current window attributes
            LayoutParams layoutpars = window.getAttributes();
            // Set the brightness of this window
            layoutpars.screenBrightness = brightness / (float) 255;
            // Apply attribute changes to this window
            window.setAttributes(layoutpars);
          }

          public void onStartTrackingTouch(SeekBar seekBar) {
            // Nothing handled here
          }

          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // Set the system brightness using the brightness variable value
            System.putInt(cResolver, System.SCREEN_BRIGHTNESS, brightness);
            // Get the current window attributes
            LayoutParams layoutpars = window.getAttributes();
            // Set the brightness of this window
            layoutpars.screenBrightness = brightness / (float) 255;
            // Apply attribute changes to this window
            window.setAttributes(layoutpars);
            // Set the minimal brightness level
            // if seek bar is 20 or any value below
            if (progress <= 10) {
              // Set the brightness to 20
              brightness = 10;
            } else // brightness is greater than 20
            {
              // Set brightness variable based on the progress bar
              brightness = progress;
            }
            // Calculate the brightness percentage
            /*float perc = (brightness /(float)255)*100;
            //Set the brightness percentage
            txtPerc.setText(" "+(int)perc +" %");*/
          }
        });
  }
Пример #12
0
    @Override
    public void onReceive(Context context, Intent intent) {
      String action = intent.getAction();
      if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
        boolean enabled = System.getInt(getContentResolver(), System.AIRPLANE_MODE_ON, 0) == 0;
        phone.setRadioPower(enabled);
      } else if (action.equals(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION)) {
        mBluetoothHeadsetState =
            intent.getIntExtra(BluetoothIntent.HEADSET_STATE, BluetoothHeadset.STATE_ERROR);
        if (VDBG) Log.d(LOG_TAG, "mReceiver: HEADSET_STATE_CHANGED_ACTION");
        if (VDBG) Log.d(LOG_TAG, "==> new state: " + mBluetoothHeadsetState);
        updateBluetoothIndication(true); // Also update any visible UI if necessary
      } else if (action.equals(BluetoothIntent.HEADSET_AUDIO_STATE_CHANGED_ACTION)) {
        mBluetoothHeadsetAudioState =
            intent.getIntExtra(BluetoothIntent.HEADSET_AUDIO_STATE, BluetoothHeadset.STATE_ERROR);
        if (VDBG) Log.d(LOG_TAG, "mReceiver: HEADSET_AUDIO_STATE_CHANGED_ACTION");
        if (VDBG) Log.d(LOG_TAG, "==> new state: " + mBluetoothHeadsetAudioState);
        updateBluetoothIndication(true); // Also update any visible UI if necessary
      } else if (action.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
        if (VDBG) Log.d(LOG_TAG, "mReceiver: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED");
        if (VDBG) Log.d(LOG_TAG, "- state: " + intent.getStringExtra(Phone.STATE_KEY));
        if (VDBG)
          Log.d(LOG_TAG, "- reason: " + intent.getStringExtra(Phone.STATE_CHANGE_REASON_KEY));

        // The "data disconnected due to roaming" notification is
        // visible if you've lost data connectivity because you're
        // roaming and you have the "data roaming" feature turned off.
        boolean disconnectedDueToRoaming = false;
        if ("DISCONNECTED".equals(intent.getStringExtra(Phone.STATE_KEY))) {
          String reason = intent.getStringExtra(Phone.STATE_CHANGE_REASON_KEY);
          if (Phone.REASON_ROAMING_ON.equals(reason)) {
            // We just lost our data connection, and the reason
            // is that we started roaming.  This implies that
            // the user has data roaming turned off.
            disconnectedDueToRoaming = true;
          }
        }
        mHandler.sendEmptyMessage(
            disconnectedDueToRoaming ? EVENT_DATA_ROAMING_DISCONNECTED : EVENT_DATA_ROAMING_OK);
      } else if (action.equals(Intent.ACTION_HEADSET_PLUG)) {
        if (VDBG) Log.d(LOG_TAG, "mReceiver: ACTION_HEADSET_PLUG");
        if (VDBG) Log.d(LOG_TAG, "    state: " + intent.getIntExtra("state", 0));
        if (VDBG) Log.d(LOG_TAG, "    name: " + intent.getStringExtra("name"));
        mIsHeadsetPlugged = (intent.getIntExtra("state", 0) == 1);
        mHandler.sendMessage(mHandler.obtainMessage(EVENT_WIRED_HEADSET_PLUG, 0));
      } else if (action.equals(Intent.ACTION_BATTERY_LOW)) {
        if (VDBG) Log.d(LOG_TAG, "mReceiver: ACTION_BATTERY_LOW");
        notifier.sendBatteryLow(); // Play a warning tone if in-call
      } else if ((action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED))
          && (mPUKEntryActivity != null)) {
        // if an attempt to un-PUK-lock the device was made, while we're
        // receiving this state change notification, notify the handler.
        // NOTE: This is ONLY triggered if an attempt to un-PUK-lock has
        // been attempted.
        mHandler.sendMessage(
            mHandler.obtainMessage(
                EVENT_SIM_STATE_CHANGED, intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE)));
      } else if (action.equals(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED)) {
        String newPhone = intent.getStringExtra(Phone.PHONE_NAME_KEY);
        Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " is active.");
        initForNewRadioTechnology();
      } else if (action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)) {
        handleServiceStateChanged(intent);
      } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
        Log.d(LOG_TAG, "Emergency Callback Mode arrived in PhoneApp.");
        // Send Intend to start ECBM application
        Intent EcbmAlarm = new Intent(Intent.ACTION_MAIN, null);
        EcbmAlarm.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        EcbmAlarm.setClassName("com.android.phone", EmergencyCallbackMode.class.getName());
        startActivity(EcbmAlarm);
        // Vibrate 45 sec receiver add by cytown
      } else if (action.equals(ACTION_VIBRATE_45)) {
        if (VDBG) Log.d(LOG_TAG, "mReceiver: ACTION_VIBRATE_45");
        mAM.set(
            AlarmManager.ELAPSED_REALTIME_WAKEUP,
            SystemClock.elapsedRealtime() + 60000,
            mVibrateIntent);
        if (DBG) Log.i(LOG_TAG, "vibrate on 45 sec");
        mVibrator.vibrate(70);
        SystemClock.sleep(70);
        mVibrator.cancel();
        if (VDBG) Log.d(LOG_TAG, "mReceiver: force vib cancel");
        // vibrate(70, 70, -1);
      }
    }
Пример #13
0
  public void onCreate(Bundle var1) {
    super.onCreate(var1);
    this.addPreferencesFromResource(2130968601);
    ContentResolver var2 = this.getContentResolver();
    this.mContentResolver = var2;
    CheckBoxPreference var3 = (CheckBoxPreference) this.findPreference("use_power_saving_mode");
    this.mEnableMode = var3;
    ListPreference var4 = (ListPreference) this.findPreference("on_battery_level");
    this.mModeValueSetting = var4;
    this.mModeValueSetting.setOnPreferenceChangeListener(this);
    CheckBoxPreference var5 = (CheckBoxPreference) this.findPreference("disable_wifi");
    this.mDisableWifi = var5;
    CheckBoxPreference var6 = (CheckBoxPreference) this.findPreference("disable_bluetooth");
    this.mDisableBluetooth = var6;
    CheckBoxPreference var7 = (CheckBoxPreference) this.findPreference("disable_gps");
    this.mDisableGps = var7;
    CheckBoxPreference var8 = (CheckBoxPreference) this.findPreference("disable_sync");
    this.mDisableSync = var8;
    CheckBoxPreference var9 = (CheckBoxPreference) this.findPreference("disable_brightness");
    this.mAdjustBrightness = var9;
    ListPreference var10 = (ListPreference) this.findPreference("brightness_setting");
    this.mBrightnessSetting = var10;
    this.mBrightnessSetting.setOnPreferenceChangeListener(this);
    ListPreference var11 = (ListPreference) this.findPreference("screentimeout_setting");
    this.mScreentimeout = var11;
    CheckBoxPreference var12 = this.mEnableMode;
    byte var13;
    if (System.getInt(this.mContentResolver, "new_power_saving_mode", 0) == 1) {
      var13 = 1;
    } else {
      var13 = 0;
    }

    var12.setChecked((boolean) var13);
    CheckBoxPreference var14 = this.mDisableWifi;
    byte var15;
    if (System.getInt(this.mContentResolver, "psm_wifi", 0) == 1) {
      var15 = 1;
    } else {
      var15 = 0;
    }

    var14.setChecked((boolean) var15);
    CheckBoxPreference var16 = this.mDisableBluetooth;
    byte var17;
    if (System.getInt(this.mContentResolver, "psm_bluetooth", 0) == 1) {
      var17 = 1;
    } else {
      var17 = 0;
    }

    var16.setChecked((boolean) var17);
    CheckBoxPreference var18 = this.mDisableGps;
    byte var19;
    if (System.getInt(this.mContentResolver, "psm_gps", 0) == 1) {
      var19 = 1;
    } else {
      var19 = 0;
    }

    var18.setChecked((boolean) var19);
    CheckBoxPreference var20 = this.mDisableSync;
    byte var21;
    if (System.getInt(this.mContentResolver, "psm_sync", 0) == 1) {
      var21 = 1;
    } else {
      var21 = 0;
    }

    var20.setChecked((boolean) var21);
    CheckBoxPreference var22 = this.mAdjustBrightness;
    byte var23;
    if (System.getInt(this.mContentResolver, "psm_brightness", 0) == 1) {
      var23 = 1;
    } else {
      var23 = 0;
    }

    var22.setChecked((boolean) var23);
    this.mModeValueSetting.setOnPreferenceChangeListener(this);
    this.mBrightnessSetting.setOnPreferenceChangeListener(this);
    this.mScreentimeout.setOnPreferenceChangeListener(this);
  }
Пример #14
0
  public boolean onPreferenceTreeClick(PreferenceScreen var1, Preference var2) {
    String var3 = "PowerSavingModeSettings";
    if (PowerSavingModeLog.LOGV) {
      PowerSavingModeLog.v("onPreferenceTreeClick");
    }

    CheckBoxPreference var4 = this.mEnableMode;
    String var11;
    boolean var14;
    byte var31;
    if (var2.equals(var4)) {
      int var5 = Log.d("PowerSavingModeSettings", "mEnableMode is selected");
      StringBuilder var6 = (new StringBuilder()).append("mEnableMode : ");
      boolean var7 = this.mEnableMode.isChecked();
      String var8 = var6.append(var7).toString();
      int var9 = Log.d("PowerSavingModeSettings", var8);
      this.updateUIFromPreferences();
      ContentResolver var10 = this.mContentResolver;
      var11 = "new_power_saving_mode";
      if (this.mEnableMode.isChecked()) {
        var31 = 1;
      } else {
        var31 = 0;
      }

      System.putInt(var10, var11, var31);
      Intent var13 = new Intent("android.settings.POWERSAVING_CHANGED");
      this.sendBroadcast(var13);
      var14 = true;
    } else {
      CheckBoxPreference var15 = this.mDisableWifi;
      if (var2.equals(var15)) {
        ContentResolver var16 = this.mContentResolver;
        var11 = "psm_wifi";
        if (this.mDisableWifi.isChecked()) {
          var31 = 1;
        } else {
          var31 = 0;
        }

        System.putInt(var16, var11, var31);
        var14 = true;
      } else {
        CheckBoxPreference var18 = this.mDisableBluetooth;
        if (var2.equals(var18)) {
          ContentResolver var19 = this.mContentResolver;
          var11 = "psm_bluetooth";
          if (this.mDisableBluetooth.isChecked()) {
            var31 = 1;
          } else {
            var31 = 0;
          }

          System.putInt(var19, var11, var31);
          var14 = true;
        } else {
          CheckBoxPreference var21 = this.mDisableGps;
          if (var2.equals(var21)) {
            ContentResolver var22 = this.mContentResolver;
            var11 = "psm_gps";
            if (this.mDisableGps.isChecked()) {
              var31 = 1;
            } else {
              var31 = 0;
            }

            System.putInt(var22, var11, var31);
            var14 = true;
          } else {
            CheckBoxPreference var24 = this.mDisableSync;
            if (var2.equals(var24)) {
              ContentResolver var25 = this.mContentResolver;
              var11 = "psm_sync";
              if (this.mDisableSync.isChecked()) {
                var31 = 1;
              } else {
                var31 = 0;
              }

              System.putInt(var25, var11, var31);
              var14 = true;
            } else {
              CheckBoxPreference var27 = this.mAdjustBrightness;
              if (var2.equals(var27)) {
                ContentResolver var28 = this.mContentResolver;
                var11 = "psm_brightness";
                if (this.mAdjustBrightness.isChecked()) {
                  var31 = 1;
                } else {
                  var31 = 0;
                }

                System.putInt(var28, var11, var31);
                boolean var30 = this.mEnableMode.isChecked();
                this.toggleBrightnessSetting(var30);
                var14 = true;
              } else {
                var14 = false;
              }
            }
          }
        }
      }
    }

    return var14;
  }