@Override
  public void onSnap(EdgeGesturePosition position) {
    if (position == mPosition) {
      return;
    }

    doHapticTriggerFeedback();

    if (DEBUG) {
      Slog.d(TAG, "onSnap from " + position.name());
    }

    int triggerSlots =
        Settings.System.getIntForUser(
            mContext.getContentResolver(),
            Settings.System.PIE_GRAVITY,
            EdgeGesturePosition.LEFT.FLAG,
            UserHandle.USER_CURRENT);

    triggerSlots = triggerSlots & ~mPosition.FLAG | position.FLAG;

    Settings.System.putIntForUser(
        mContext.getContentResolver(),
        Settings.System.PIE_GRAVITY,
        triggerSlots,
        UserHandle.USER_CURRENT);
  }
  private void setupListener() {
    ContentResolver resolver = mContext.getContentResolver();

    mPieTriggerSlots =
        Settings.System.getIntForUser(
            resolver,
            Settings.System.PIE_GRAVITY,
            EdgeGesturePosition.LEFT.FLAG,
            UserHandle.USER_CURRENT);

    int sensitivity = mContext.getResources().getInteger(R.integer.pie_gesture_sensivity);
    if (sensitivity < EdgeServiceConstants.SENSITIVITY_LOWEST
        || sensitivity > EdgeServiceConstants.SENSITIVITY_HIGHEST) {
      sensitivity = EdgeServiceConstants.SENSITIVITY_DEFAULT;
    }

    int flags = mPieTriggerSlots & mPieTriggerMask;

    if (Settings.System.getIntForUser(
            resolver, Settings.System.PIE_IME_CONTROL, 1, UserHandle.USER_CURRENT)
        == 1) {
      flags |= EdgeServiceConstants.IME_CONTROL;
    }

    mPieManager.updateEdgeGestureActivationListener(
        mPieActivationListener, sensitivity << EdgeServiceConstants.SENSITIVITY_SHIFT | flags);
  }
 private Drawable prepareBackIcon(Drawable d, boolean customIcon) {
   int customImageColorize =
       Settings.System.getIntForUser(
           mContext.getContentResolver(),
           Settings.System.PIE_ICON_COLOR_MODE,
           0,
           UserHandle.USER_CURRENT);
   int drawableColor =
       Settings.System.getIntForUser(
           mContext.getContentResolver(),
           Settings.System.PIE_ICON_COLOR,
           -2,
           UserHandle.USER_CURRENT);
   if (drawableColor == -2) {
     drawableColor = mContext.getResources().getColor(R.color.pie_foreground_color);
   }
   if (mIconResize && !customIcon) {
     d = resizeIcon(null, d, false);
   } else if (customIcon) {
     d = resizeIcon(null, d, true);
   }
   if ((customImageColorize != 1 || !customIcon) && customImageColorize != 3) {
     d =
         new BitmapDrawable(
             mContext.getResources(),
             ImageHelper.drawableToBitmap(ImageHelper.getColoredDrawable(d, drawableColor)));
   }
   return d;
 }
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      // Load the preferences from an XML resource
      addPreferencesFromResource(R.xml.prefs_statusbar_toggles);

      mEnabledToggles = findPreference(PREF_ENABLE_TOGGLES);

      mBrightnessLocation = (ListPreference) findPreference(PREF_BRIGHTNESS_LOC);
      mBrightnessLocation.setOnPreferenceChangeListener(this);
      mBrightnessLocation.setValue(
          Integer.toString(
              Settings.System.getInt(
                  getActivity().getContentResolver(),
                  Settings.System.STATUSBAR_TOGGLES_BRIGHTNESS_LOC,
                  1)));

      mToggleStyle = (ListPreference) findPreference(PREF_TOGGLES_STYLE);
      mToggleStyle.setOnPreferenceChangeListener(this);
      mToggleStyle.setValue(
          Integer.toString(
              Settings.System.getInt(
                  getActivity().getContentResolver(), Settings.System.STATUSBAR_TOGGLES_STYLE, 3)));

      mAlternateButtonLayout = (CheckBoxPreference) findPreference(PREF_ALT_BUTTON_LAYOUT);
      mAlternateButtonLayout.setChecked(
          Settings.System.getInt(
                  getContentResolver(), Settings.System.STATUSBAR_TOGGLES_USE_BUTTONS, 0)
              == 1);
    }
Beispiel #5
0
  @Override
  public void onResume() {
    super.onResume();

    updateState(true);
    lookupRingtoneNames();

    IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION);
    getActivity().registerReceiver(mReceiver, filter);

    /*Begin: mzikun add for settings menu*/
    if (mReverseCallMute != null) {
      boolean checked = Settings.System.getInt(getContentResolver(), "reversal_mute", 0) != 0;
      mReverseCallMute.setChecked(checked);
      mReverseCallMute.setSummary(
          checked ? R.string.reversal_call_off_summary : R.string.reversal_call_on_summary);
    }

    if (mReverseMP3Mute != null) {
      boolean checked = Settings.System.getInt(getContentResolver(), "reversal_mp3_mute", 0) != 0;
      mReverseMP3Mute.setChecked(checked);
    }

    if (mReverseMP4Mute != null) {
      boolean checked = Settings.System.getInt(getContentResolver(), "reversal_mp4_mute", 0) != 0;
      mReverseMP4Mute.setChecked(checked);
    }
    /*End: mzikun add for settings menu*/
  }
  private void refreshDefault() {
    ContentResolver resolver = getContentResolver();
    Resources res = getResources();

    if (mLowColorPref != null) {
      int lowColor =
          Settings.System.getInt(
              resolver,
              Settings.System.BATTERY_LIGHT_LOW_COLOR,
              res.getInteger(com.android.internal.R.integer.config_notificationsBatteryLowARGB));
      mLowColorPref.setAllValues(lowColor, 0, 0, false);
    }

    if (mMediumColorPref != null) {
      int mediumColor =
          Settings.System.getInt(
              resolver,
              Settings.System.BATTERY_LIGHT_MEDIUM_COLOR,
              res.getInteger(com.android.internal.R.integer.config_notificationsBatteryMediumARGB));
      mMediumColorPref.setAllValues(mediumColor, 0, 0, false);
    }

    if (mFullColorPref != null) {
      int fullColor =
          Settings.System.getInt(
              resolver,
              Settings.System.BATTERY_LIGHT_FULL_COLOR,
              res.getInteger(com.android.internal.R.integer.config_notificationsBatteryFullARGB));
      mFullColorPref.setAllValues(fullColor, 0, 0, false);
    }
  }
  private void updateState() {
    readFontSizePreference(mFontSizePref);
    updateScreenSaverSummary();

    // Update auto brightness if it is available.
    if (mAutoBrightnessPreference != null) {
      int brightnessMode =
          Settings.System.getInt(
              getContentResolver(), SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_MANUAL);
      mAutoBrightnessPreference.setChecked(brightnessMode != SCREEN_BRIGHTNESS_MODE_MANUAL);
    }

    // Update lift-to-wake if it is available.
    if (mLiftToWakePreference != null) {
      int value = Settings.Secure.getInt(getContentResolver(), WAKE_GESTURE_ENABLED, 0);
      mLiftToWakePreference.setChecked(value != 0);
    }

    // Update proximity wake if it is available.
    if (mProximityWakePreference != null) {
      boolean defaultValue =
          getResources()
              .getBoolean(com.android.internal.R.bool.config_proximityCheckOnWakeEnabledByDefault);
      boolean enabled =
          Settings.System.getInt(
                  getContentResolver(), Settings.System.PROXIMITY_ON_WAKE, defaultValue ? 1 : 0)
              == 1;
      mProximityWakePreference.setChecked(enabled);
    }
  }
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   if (preference == mPositionPref) {
     int position = Integer.valueOf((String) newValue);
     updatePositionSummary(position);
     return true;
   } else if (preference == mEnabledPref) {
     Settings.System.putInt(
         getContentResolver(),
         Settings.System.GESTURE_ANYWHERE_ENABLED,
         ((Boolean) newValue).booleanValue() ? 1 : 0);
     return true;
   } else if (preference == mGestureAnywhereFloatingWindow) {
     Settings.System.putInt(
         getContentResolver(),
         Settings.System.GESTURE_ANYWHERE_FLOATING,
         (Boolean) newValue ? 1 : 0);
     return true;
   } else if (preference == mTriggerWidthPref) {
     int width = ((Integer) newValue).intValue();
     Settings.System.putInt(
         getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_WIDTH, width);
     return true;
   } else if (preference == mTriggerTopPref) {
     int top = ((Integer) newValue).intValue();
     Settings.System.putInt(
         getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_TOP, top);
     return true;
   } else if (preference == mTriggerBottomPref) {
     int bottom = ((Integer) newValue).intValue();
     Settings.System.putInt(
         getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_HEIGHT, bottom);
     return true;
   }
   return false;
 }
  void updateSleep() {
    ContentResolver cr = getContentResolver();
    int get =
        android.provider.Settings.System.getInt(
            cr, android.provider.Settings.System.WIFI_SLEEP_POLICY, -1);
    int set = get;
    boolean wlan = settings.getBoolean(PREF_WLAN, DEFAULT_WLAN);
    boolean g3 =
        settings.getBoolean(PREF_3G, DEFAULT_3G) || settings.getBoolean(PREF_EDGE, DEFAULT_EDGE);
    boolean ownwifi = settings.getBoolean(PREF_OWNWIFI, DEFAULT_OWNWIFI);

    if (g3 && !ownwifi) {
      set = android.provider.Settings.System.WIFI_SLEEP_POLICY_DEFAULT;
      if (set != get) {
        Toast.makeText(this, R.string.settings_policy_default, Toast.LENGTH_LONG).show();
      }
    } else if (wlan || ownwifi) {
      set = android.provider.Settings.System.WIFI_SLEEP_POLICY_NEVER;
      if (set != get) {
        Toast.makeText(this, R.string.settings_policy_never, Toast.LENGTH_LONG).show();
      }
    }
    if (set != get) {
      android.provider.Settings.System.putInt(
          cr, android.provider.Settings.System.WIFI_SLEEP_POLICY, set);
    }
  }
Beispiel #10
0
  @Override
  public boolean getScreenEnableState(long subId, Activity activity) {
    boolean simReady =
        TelephonyManager.SIM_STATE_READY
            == TelephonyManager.getDefault().getSimState(SubscriptionManager.getSlotId(subId));
    boolean airplaneModeEnabled =
        android.provider.Settings.System.getInt(
                activity.getContentResolver(),
                android.provider.Settings.System.AIRPLANE_MODE_ON,
                -1)
            == 1;

    boolean isMMsNoTransac = isMMSNotTransaction(activity);
    boolean isMultiSimMode = true;
    if (FeatureOption.MTK_GEMINI_SUPPORT) {
      int multiMode =
          Settings.System.getInt(
              activity.getContentResolver(), Settings.System.MSIM_MODE_SETTING, -1);
      isMultiSimMode = multiMode != 0;
    }
    Log.d(
        TAG,
        "subId = "
            + subId
            + ",isMMsNoTransac = "
            + isMMsNoTransac
            + " ,airplaneModeEnabled = "
            + airplaneModeEnabled
            + " ,simReady = "
            + simReady
            + " , isMultiSimMode = "
            + isMultiSimMode);
    return isMMsNoTransac && !airplaneModeEnabled && simReady && isMultiSimMode;
  }
 /**
  * On GSM devices, we never use short tones. On CDMA devices, it depends upon the settings. TODO:
  * I don't think this has anything to do with GSM versus CDMA, should we be looking only at the
  * setting?
  */
 /* package */ static boolean useShortDtmfTones(Phone phone, Context context) {
   int toneType;
   int phoneType = phone.getPhoneType();
   if (phoneType == Phone.PHONE_TYPE_GSM) {
     return false;
   } else if (phoneType == Phone.PHONE_TYPE_CDMA) {
     if (TelephonyManager.getDefault().isMultiSimEnabled()) {
       toneType =
           android.provider.Settings.System.getInt(
               context.getContentResolver(),
               Settings.System.DTMF_TONE_TYPE_WHEN_DIALING,
               MSimCallFeaturesSetting.DTMF_TONE_TYPE_NORMAL);
     } else {
       toneType =
           android.provider.Settings.System.getInt(
               context.getContentResolver(),
               Settings.System.DTMF_TONE_TYPE_WHEN_DIALING,
               CallFeaturesSetting.DTMF_TONE_TYPE_NORMAL);
     }
     if (toneType == CallFeaturesSetting.DTMF_TONE_TYPE_NORMAL) {
       return true;
     } else {
       return false;
     }
   } else if (phoneType == Phone.PHONE_TYPE_SIP) {
     return false;
   } else {
     throw new IllegalStateException("Unexpected phone type: " + phoneType);
   }
 }
  public BrightnessTile(Context context, final QuickSettingsController qsc) {
    super(context, qsc);

    mOnClick =
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            qsc.mBar.collapseAllPanels(true);
            Intent intent = new Intent(Intent.ACTION_SHOW_BRIGHTNESS_DIALOG);
            mContext.sendBroadcast(intent);
          }
        };
    mOnLongClick =
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            startSettingsActivity(Settings.ACTION_DISPLAY_SETTINGS);
            return true;
          }
        };

    qsc.registerObservedContent(Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS), this);
    qsc.registerObservedContent(
        Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS_MODE), this);
  }
  private void updateGlowTimesSummary() {
    int resId;
    String combinedTime =
        Settings.System.getString(mContentRes, Settings.System.NAVIGATION_BAR_GLOW_DURATION[1])
            + "|"
            + Settings.System.getString(
                mContentRes, Settings.System.NAVIGATION_BAR_GLOW_DURATION[0]);

    String[] glowArray = getResources().getStringArray(R.array.glow_times_values);

    if (glowArray[0].equals(combinedTime)) {
      resId = R.string.glow_times_off;
      mGlowTimes.setValueIndex(0);
    } else if (glowArray[1].equals(combinedTime)) {
      resId = R.string.glow_times_superquick;
      mGlowTimes.setValueIndex(1);
    } else if (glowArray[2].equals(combinedTime)) {
      resId = R.string.glow_times_quick;
      mGlowTimes.setValueIndex(2);
    } else {
      resId = R.string.glow_times_normal;
      mGlowTimes.setValueIndex(3);
    }
    mGlowTimes.setSummary(getResources().getString(resId));
  }
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference == mShowPowerSaver) {
      Settings.System.putInt(
          getActivity().getContentResolver(),
          Settings.System.POWER_DIALOG_SHOW_POWER_SAVER,
          ((CheckBoxPreference) preference).isChecked() ? 1 : 0);
      return true;
    } else if (preference == mShowScreenShot) {
      Settings.System.putInt(
          getActivity().getContentResolver(),
          Settings.System.POWER_DIALOG_SHOW_SCREENSHOT,
          ((CheckBoxPreference) preference).isChecked() ? 1 : 0);
      return true;
    } else if (preference == mShowTorchToggle) {
      Settings.System.putInt(
          getActivity().getContentResolver(),
          Settings.System.POWER_DIALOG_SHOW_TORCH_TOGGLE,
          ((CheckBoxPreference) preference).isChecked() ? 1 : 0);
      return true;
    } else if (preference == mShowAirplaneToggle) {
      Settings.System.putInt(
          getActivity().getContentResolver(),
          Settings.System.POWER_DIALOG_SHOW_AIRPLANE_TOGGLE,
          ((CheckBoxPreference) preference).isChecked() ? 1 : 0);
      return true;
    }

    return super.onPreferenceTreeClick(preferenceScreen, preference);
  }
 void observe() {
   ContentResolver resolver = mContext.getContentResolver();
   resolver.registerContentObserver(
       Settings.System.getUriFor(Settings.System.STATUS_BAR_AM_PM), false, this);
   resolver.registerContentObserver(
       Settings.System.getUriFor(Settings.System.STATUS_BAR_CLOCK), false, this);
 }
 @Override
 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
   if (preference == mPieMenu) {
     Settings.System.putInt(
         getActivity().getApplicationContext().getContentResolver(),
         Settings.System.PIE_MENU,
         mPieMenu.isChecked() ? 1 : 0);
   } else if (preference == mPieSearch) {
     Settings.System.putInt(
         getActivity().getApplicationContext().getContentResolver(),
         Settings.System.PIE_SEARCH,
         mPieSearch.isChecked() ? 1 : 0);
   } else if (preference == mPieCenter) {
     Settings.System.putInt(
         getActivity().getApplicationContext().getContentResolver(),
         Settings.System.PIE_CENTER,
         mPieCenter.isChecked() ? 1 : 0);
   } else if (preference == mPieStick) {
     Settings.System.putInt(
         getActivity().getApplicationContext().getContentResolver(),
         Settings.System.PIE_STICK,
         mPieStick.isChecked() ? 1 : 0);
   }
   return super.onPreferenceTreeClick(preferenceScreen, preference);
 }
 void observe() {
   ContentResolver resolver = mContext.getContentResolver();
   resolver.registerContentObserver(
       Settings.System.getUriFor(Settings.System.STATUSBAR_BATTERY_ICON), false, this);
   resolver.registerContentObserver(
       Settings.System.getUriFor(Settings.System.STATUSBAR_FONT_SIZE), false, this);
 }
Beispiel #18
0
 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
   if (preference == mFlashRecovery) {
     // 警告弹框
     new AlertDialog.Builder(StockSettings.this)
         .setTitle(R.string.confirm)
         .setMessage("您确定刷入并重启进入刷机模式?")
         .setNegativeButton(
             R.string.yes,
             new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int whichButton) {
                 RootCmd.RunRootCmd("dd if=/sdcard/recovery.img of=/dev/recovery");
                 RootCmd.RunRootCmd("reboot recovery");
               }
             })
         .setPositiveButton(R.string.no, null)
         .show();
   }
   if (preference == mCrtLockscreen) {
     if (mCrtLockscreen.isChecked()) {
       Settings.System.putInt(getContentResolver(), "allow_crt_lockscreen", 1);
     } else {
       Settings.System.putInt(getContentResolver(), "allow_crt_lockscreen", 0);
     }
   }
   return super.onPreferenceTreeClick(preferenceScreen, preference);
 }
    public void observe() {
      ContentResolver resolver = mContext.getContentResolver();

      // watch for display widget
      resolver.registerContentObserver(
          Settings.System.getUriFor(Settings.System.EXPANDED_VIEW_WIDGET), false, this);

      // watch for scrollbar hiding
      resolver.registerContentObserver(
          Settings.System.getUriFor(Settings.System.EXPANDED_HIDE_SCROLLBAR), false, this);

      // watch for haptic feedback
      resolver.registerContentObserver(
          Settings.System.getUriFor(Settings.System.EXPANDED_HAPTIC_FEEDBACK), false, this);

      // watch for changes in buttons
      resolver.registerContentObserver(
          Settings.System.getUriFor(Settings.System.WIDGET_BUTTONS), false, this);

      // watch for changes in color
      resolver.registerContentObserver(
          Settings.System.getUriFor(Settings.System.EXPANDED_VIEW_WIDGET_COLOR), false, this);

      // watch for power-button specifc stuff that has been loaded
      for (Uri uri : PowerButton.getAllObservedUris()) {
        resolver.registerContentObserver(uri, false, this);
      }
    }
  private void playSounds(boolean locked) {
    // User feedback for keyguard.

    if (mSuppressNextLockSound) {
      mSuppressNextLockSound = false;
      return;
    }

    final ContentResolver cr = mContext.getContentResolver();
    if (Settings.System.getInt(cr, Settings.System.LOCKSCREEN_SOUNDS_ENABLED, 1) == 1) {
      final String whichSound = locked ? Settings.System.LOCK_SOUND : Settings.System.UNLOCK_SOUND;
      final String soundPath = Settings.System.getString(cr, whichSound);
      if (soundPath != null) {
        final Uri soundUri = Uri.parse("file://" + soundPath);
        if (soundUri != null) {
          final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri);
          if (sfx != null) {
            sfx.setStreamType(AudioManager.STREAM_SYSTEM);
            sfx.play();
          } else {
            Log.d(TAG, "playSounds: failed to load ringtone from uri: " + soundUri);
          }
        } else {
          Log.d(TAG, "playSounds: could not parse Uri: " + soundPath);
        }
      } else {
        Log.d(TAG, "playSounds: whichSound = " + whichSound + "; soundPath was null");
      }
    }
  }
 @Override
 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
   if (preference == mEnableWeather) {
     // _stop_ alarm or start service
     boolean check = ((CheckBoxPreference) preference).isChecked();
     Intent i = new Intent(getActivity().getApplicationContext(), WeatherRefreshService.class);
     i.setAction(WeatherService.INTENT_REQUEST_WEATHER);
     PendingIntent weatherRefreshIntent = PendingIntent.getService(getActivity(), 0, i, 0);
     if (!check) {
       AlarmManager alarms = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
       alarms.cancel(weatherRefreshIntent);
     } else {
       getActivity().startService(i);
     }
     Settings.System.putInt(
         getActivity().getContentResolver(), Settings.System.USE_WEATHER, check ? 1 : 0);
     return true;
   } else if (preference == mUseCustomLoc) {
     return WeatherPrefs.setUseCustomLocation(
         mContext, ((CheckBoxPreference) preference).isChecked());
   } else if (preference == mShowLoc) {
     Settings.System.putInt(
         getActivity().getContentResolver(),
         Settings.System.WEATHER_SHOW_LOCATION,
         ((CheckBoxPreference) preference).isChecked() ? 1 : 0);
     return true;
   } else if (preference == mUseCelcius) {
     return WeatherPrefs.setUseCelcius(mContext, ((CheckBoxPreference) preference).isChecked());
   }
   return super.onPreferenceTreeClick(preferenceScreen, preference);
 }
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.recents_panel_settings);

    PreferenceScreen prefSet = getPreferenceScreen();
    ContentResolver resolver = getActivity().getContentResolver();
    PackageManager pm = getPackageManager();

    mRecentsClearAll = (SwitchPreference) prefSet.findPreference(SHOW_CLEAR_ALL_RECENTS);
    mRecentsClearAll.setChecked(
        Settings.System.getIntForUser(
                resolver, Settings.System.SHOW_CLEAR_ALL_RECENTS, 1, UserHandle.USER_CURRENT)
            == 1);
    mRecentsClearAll.setOnPreferenceChangeListener(this);

    mRecentsClearAllLocation = (ListPreference) prefSet.findPreference(RECENTS_CLEAR_ALL_LOCATION);
    int location =
        Settings.System.getIntForUser(
            resolver, Settings.System.RECENTS_CLEAR_ALL_LOCATION, 3, UserHandle.USER_CURRENT);
    mRecentsClearAllLocation.setValue(String.valueOf(location));
    mRecentsClearAllLocation.setOnPreferenceChangeListener(this);
    updateRecentsLocation(location);

    mOmniSwitch = (Preference) prefSet.findPreference(KEY_OMNISWITCH);
    if (!Helpers.isPackageInstalled(OMNISWITCH_PACKAGE_NAME, pm)) {
      prefSet.removePreference(mOmniSwitch);
    }
  }
  private void updateExpandedDesktop(int value) {
    Resources res = getResources();
    int summary = -1;

    Settings.System.putInt(getContentResolver(), Settings.System.EXPANDED_DESKTOP_STYLE, value);

    if (value == 0) {
      // Expanded desktop deactivated
      Settings.System.putInt(
          getContentResolver(), Settings.System.POWER_MENU_EXPANDED_DESKTOP_ENABLED, 0);
      summary = R.string.expanded_desktop_disabled;
      // Disable expanded desktop if enabled
      Settings.System.putInt(getContentResolver(), Settings.System.EXPANDED_DESKTOP_STATE, 0);
    } else if (value == 1) {
      Settings.System.putInt(
          getContentResolver(), Settings.System.POWER_MENU_EXPANDED_DESKTOP_ENABLED, 1);
      summary = R.string.expanded_desktop_status_bar;
    } else if (value == 2) {
      Settings.System.putInt(
          getContentResolver(), Settings.System.POWER_MENU_EXPANDED_DESKTOP_ENABLED, 1);
      summary = R.string.expanded_desktop_no_status_bar;
    }

    if (mExpandedDesktopPref != null && summary != -1) {
      mExpandedDesktopPref.setSummary(res.getString(summary));
    }
  }
  @Override
  public boolean onPreferenceChange(Preference preference, Object newValue) {
    if (preference == mLockscreenOption) {
      int val = Integer.parseInt((String) newValue);
      Settings.System.putInt(
          getActivity().getContentResolver(), Settings.System.LOCKSCREEN_LAYOUT, val);
      refreshSettings();
      return true;

    } else if (preference.getKey().startsWith("lockscreen_target")) {
      int index =
          Integer.parseInt(preference.getKey().substring(preference.getKey().lastIndexOf("_") + 1));
      Log.e("ROMAN", "lockscreen target, index: " + index);

      if (newValue.equals("**app**")) {
        mCurrentCustomActivityPreference = preference;
        mCurrentCustomActivityString = Settings.System.LOCKSCREEN_CUSTOM_APP_ACTIVITIES[index];
        mPicker.pickShortcut();
      } else {
        Settings.System.putString(
            getContentResolver(),
            Settings.System.LOCKSCREEN_CUSTOM_APP_ACTIVITIES[index],
            (String) newValue);
        refreshSettings();
      }
      return true;
    }

    return false;
  }
  public void refreshSettings() {

    int lockscreenTargets =
        Settings.System.getInt(getContentResolver(), Settings.System.LOCKSCREEN_LAYOUT, 2);

    PreferenceGroup targetGroup = (PreferenceGroup) findPreference("lockscreen_targets");
    targetGroup.removeAll();

    // quad only uses first 4, but we make the system think there's 6 for the alternate layout
    // so only show 4
    if (lockscreenTargets == 6) {
      Settings.System.putString(
          getContentResolver(), Settings.System.LOCKSCREEN_CUSTOM_APP_ACTIVITIES[4], "**null**");
      Settings.System.putString(
          getContentResolver(), Settings.System.LOCKSCREEN_CUSTOM_APP_ACTIVITIES[5], "**null**");
      lockscreenTargets = 4;
    }

    for (int i = 0; i < lockscreenTargets; i++) {
      ListPreference p = new ListPreference(getActivity());
      String dialogTitle =
          String.format(getResources().getString(R.string.custom_app_n_dialog_title), i + 1);
      ;
      p.setDialogTitle(dialogTitle);
      p.setEntries(R.array.lockscreen_choice_entries);
      p.setEntryValues(R.array.lockscreen_choice_values);
      String title = String.format(getResources().getString(R.string.custom_app_n), i + 1);
      p.setTitle(title);
      p.setKey("lockscreen_target_" + i);
      p.setSummary(getProperSummary(i));
      p.setOnPreferenceChangeListener(this);
      targetGroup.addPreference(p);
    }
  }
  public SearchPanelView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContext = context;
    mPackageManager = mContext.getPackageManager();
    mResources = mContext.getResources();

    mContentResolver = mContext.getContentResolver();
    mTargetObserver = new TargetObserver(new Handler());

    mNavRingAmount =
        Settings.System.getInt(
            mContext.getContentResolver(), Settings.System.SYSTEMUI_NAVRING_AMOUNT, 1);

    targetList =
        Arrays.asList(
            Settings.System.SYSTEMUI_NAVRING_1,
            Settings.System.SYSTEMUI_NAVRING_2,
            Settings.System.SYSTEMUI_NAVRING_3,
            Settings.System.SYSTEMUI_NAVRING_4,
            Settings.System.SYSTEMUI_NAVRING_5);

    for (int i = 0; i < targetList.size(); i++) {
      mContentResolver.registerContentObserver(
          Settings.System.getUriFor(targetList.get(i)), false, mTargetObserver);
    }
  }
  private final class SettingsObserver extends ContentObserver {
    private final Uri DISPLAY_TEMPERATURE_DAY_URI =
        Settings.System.getUriFor(Settings.System.DISPLAY_TEMPERATURE_DAY);
    private final Uri DISPLAY_TEMPERATURE_NIGHT_URI =
        Settings.System.getUriFor(Settings.System.DISPLAY_TEMPERATURE_NIGHT);
    private final Uri DISPLAY_TEMPERATURE_MODE_URI =
        Settings.System.getUriFor(Settings.System.DISPLAY_TEMPERATURE_MODE);

    public SettingsObserver() {
      super(mHandler);
    }

    public void register(boolean register) {
      final ContentResolver cr = getContentResolver();
      if (register) {
        cr.registerContentObserver(DISPLAY_TEMPERATURE_DAY_URI, false, this, UserHandle.USER_ALL);
        cr.registerContentObserver(DISPLAY_TEMPERATURE_NIGHT_URI, false, this, UserHandle.USER_ALL);
        cr.registerContentObserver(DISPLAY_TEMPERATURE_MODE_URI, false, this, UserHandle.USER_ALL);
      } else {
        cr.unregisterContentObserver(this);
      }
    }

    @Override
    public void onChange(boolean selfChange, Uri uri) {
      super.onChange(selfChange, uri);
      updateModeSummary();
      updateTemperatureSummary();
    }
  }
 void observe() {
   ContentResolver resolver = mContext.getContentResolver();
   resolver.registerContentObserver(
       Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS), false, this);
   resolver.registerContentObserver(
       Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS_MODE), false, this);
 }
  public KeyguardViewMediator(
      Context context, PhoneWindowManager callback, LocalPowerManager powerManager) {
    mContext = context;

    mRealPowerManager = powerManager;
    mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    mWakeLock =
        mPM.newWakeLock(
            PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "keyguard");
    mWakeLock.setReferenceCounted(false);
    mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
    mShowKeyguardWakeLock.setReferenceCounted(false);

    mWakeAndHandOff = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "keyguardWakeAndHandOff");
    mWakeAndHandOff.setReferenceCounted(false);

    IntentFilter filter = new IntentFilter();
    filter.addAction(DELAYED_KEYGUARD_ACTION);
    filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    context.registerReceiver(mBroadCastReceiver, filter);
    mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    mCallback = callback;

    mUpdateMonitor = new KeyguardUpdateMonitor(context);

    mUpdateMonitor.registerInfoCallback(this);
    mUpdateMonitor.registerSimStateCallback(this);

    mLockPatternUtils = new LockPatternUtils(mContext);
    mKeyguardViewProperties =
        new LockPatternKeyguardViewProperties(mLockPatternUtils, mUpdateMonitor);

    mKeyguardViewManager =
        new KeyguardViewManager(
            context, WindowManagerImpl.getDefault(), this, mKeyguardViewProperties, mUpdateMonitor);

    mUserPresentIntent = new Intent(Intent.ACTION_USER_PRESENT);
    mUserPresentIntent.addFlags(
        Intent.FLAG_RECEIVER_REPLACE_PENDING | Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);

    final ContentResolver cr = mContext.getContentResolver();
    mShowLockIcon = (Settings.System.getInt(cr, "show_status_bar_lock", 0) == 1);

    mLockSounds = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0);
    String soundPath = Settings.System.getString(cr, Settings.System.LOCK_SOUND);
    if (soundPath != null) {
      mLockSoundId = mLockSounds.load(soundPath, 1);
    }
    if (soundPath == null || mLockSoundId == 0) {
      if (DEBUG) Log.d(TAG, "failed to load sound from " + soundPath);
    }
    soundPath = Settings.System.getString(cr, Settings.System.UNLOCK_SOUND);
    if (soundPath != null) {
      mUnlockSoundId = mLockSounds.load(soundPath, 1);
    }
    if (soundPath == null || mUnlockSoundId == 0) {
      if (DEBUG) Log.d(TAG, "failed to load sound from " + soundPath);
    }
  }
Beispiel #30
0
  /** 发射FM */
  public static void launchFM(int fm, Context context) {
    Settings.System.putInt(context.getContentResolver(), "fm_freg", fm);
    Settings.System.putInt(context.getContentResolver(), "fm_switch", 0);

    Intent intent = new Intent("action.colink.startFM");
    intent.putExtra("fm_fq", (fm * 1.0f / 1000));
    context.sendBroadcast(intent);
  }