public static void restoreSettings() {
   if (PreferenceManager.getDefaultSharedPreferences(Receiver.mContext)
       .getBoolean(
           org.sipdroid.sipua.ui.Settings.PREF_OLDVALID,
           org.sipdroid.sipua.ui.Settings.DEFAULT_OLDVALID)) {
     AudioManager am = (AudioManager) Receiver.mContext.getSystemService(Context.AUDIO_SERVICE);
     ContentResolver cr = Receiver.mContext.getContentResolver();
     int oldvibrate =
         PreferenceManager.getDefaultSharedPreferences(Receiver.mContext)
             .getInt(
                 org.sipdroid.sipua.ui.Settings.PREF_OLDVIBRATE,
                 org.sipdroid.sipua.ui.Settings.DEFAULT_OLDVIBRATE);
     int oldvibrate2 =
         PreferenceManager.getDefaultSharedPreferences(Receiver.mContext)
             .getInt(
                 org.sipdroid.sipua.ui.Settings.PREF_OLDVIBRATE2,
                 org.sipdroid.sipua.ui.Settings.DEFAULT_OLDVIBRATE2);
     int oldpolicy =
         PreferenceManager.getDefaultSharedPreferences(Receiver.mContext)
             .getInt(
                 org.sipdroid.sipua.ui.Settings.PREF_OLDPOLICY,
                 org.sipdroid.sipua.ui.Settings.DEFAULT_OLDPOLICY);
     am.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, oldvibrate);
     am.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, oldvibrate2);
     Settings.System.putInt(cr, Settings.System.WIFI_SLEEP_POLICY, oldpolicy);
     int oldring =
         PreferenceManager.getDefaultSharedPreferences(Receiver.mContext).getInt("oldring", 0);
     if (oldring > 0) am.setStreamVolume(AudioManager.STREAM_RING, oldring, 0);
     Editor edit = PreferenceManager.getDefaultSharedPreferences(Receiver.mContext).edit();
     edit.putBoolean(org.sipdroid.sipua.ui.Settings.PREF_OLDVALID, false);
     edit.commit();
     PowerManager pm = (PowerManager) Receiver.mContext.getSystemService(Context.POWER_SERVICE);
     PowerManager.WakeLock wl =
         pm.newWakeLock(
             PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,
             "Sipdroid.RtpStreamReceiver");
     wl.acquire(1000);
   }
   restoreMode();
 }
 public static synchronized void ringback(boolean ringback) {
   if (ringback && ringbackPlayer == null) {
     AudioManager am = (AudioManager) Receiver.mContext.getSystemService(Context.AUDIO_SERVICE);
     oldvol = am.getStreamVolume(AudioManager.STREAM_MUSIC);
     setMode(speakermode);
     enableBluetooth(
         PreferenceManager.getDefaultSharedPreferences(Receiver.mContext)
             .getBoolean(
                 org.sipdroid.sipua.ui.Settings.PREF_BLUETOOTH,
                 org.sipdroid.sipua.ui.Settings.DEFAULT_BLUETOOTH));
     am.setStreamVolume(
         stream(),
         PreferenceManager.getDefaultSharedPreferences(Receiver.mContext)
             .getInt(
                 "volume" + speakermode,
                 am.getStreamMaxVolume(stream())
                     * (speakermode == AudioManager.MODE_NORMAL ? 4 : 3)
                     / 4),
         0);
     ringbackPlayer =
         new ToneGenerator(
             stream(),
             (int) (ToneGenerator.MAX_VOLUME * 2 * org.sipdroid.sipua.ui.Settings.getEarGain()));
     ringbackPlayer.startTone(ToneGenerator.TONE_SUP_RINGTONE);
   } else if (!ringback && ringbackPlayer != null) {
     ringbackPlayer.stopTone();
     ringbackPlayer.release();
     ringbackPlayer = null;
     if (Receiver.call_state == UserAgent.UA_STATE_IDLE) {
       AudioManager am = (AudioManager) Receiver.mContext.getSystemService(Context.AUDIO_SERVICE);
       restoreMode();
       enableBluetooth(false);
       am.setStreamVolume(AudioManager.STREAM_MUSIC, oldvol, 0);
       oldvol = -1;
     }
   }
 }