@Override
  public void onResume() {
    super.onResume();

    if (mDpm.getMaximumTimeToLock(null) > 0) {
      // A DeviceAdmin has specified a maximum time until the device
      // will lock...  in this case we can't allow the user to turn
      // on "stay awake when plugged in" because that would defeat the
      // restriction.
      mDisabledPrefs.add(mKeepScreenOn);
    } else {
      mDisabledPrefs.remove(mKeepScreenOn);
    }

    final ContentResolver cr = getActivity().getContentResolver();
    mLastEnabledState =
        Settings.Global.getInt(cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
    mEnabledSwitch.setChecked(mLastEnabledState);
    setPrefsEnabledState(mLastEnabledState);

    if (mHaveDebugSettings && !mLastEnabledState) {
      // Overall debugging is disabled, but there are some debug
      // settings that are enabled.  This is an invalid state.  Switch
      // to debug settings being enabled, so the user knows there is
      // stuff enabled and can turn it all off if they want.
      Settings.Global.putInt(
          getActivity().getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
      mLastEnabledState = true;
      mEnabledSwitch.setChecked(mLastEnabledState);
      setPrefsEnabledState(mLastEnabledState);
    }

    updateKillAppLongpressBackOptions();
  }