Ejemplo n.º 1
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    boolean result = super.onPrepareOptionsMenu(menu);

    if (Receiver.mSipdroidEngine != null
        && Receiver.mSipdroidEngine.ua != null
        && Receiver.mSipdroidEngine.ua.audio_app != null) {
      menu.findItem(HOLD_MENU_ITEM).setVisible(true);
      menu.findItem(MUTE_MENU_ITEM).setVisible(true);
      menu.findItem(VIDEO_MENU_ITEM)
          .setVisible(
              VideoCamera.videoValid()
                  && Receiver.call_state == UserAgent.UA_STATE_INCALL
                  && Receiver.engine(this).getRemoteVideo() != 0);
      menu.findItem(TRANSFER_MENU_ITEM).setVisible(true);
      menu.findItem(BLUETOOTH_MENU_ITEM).setVisible(RtpStreamReceiver.isBluetoothAvailable());
    } else {
      menu.findItem(HOLD_MENU_ITEM).setVisible(false);
      menu.findItem(MUTE_MENU_ITEM).setVisible(false);
      menu.findItem(VIDEO_MENU_ITEM).setVisible(false);
      menu.findItem(TRANSFER_MENU_ITEM).setVisible(false);
      menu.findItem(BLUETOOTH_MENU_ITEM).setVisible(false);
    }
    menu.findItem(SPEAKER_MENU_ITEM)
        .setVisible(!(Receiver.headset > 0 || Receiver.docked > 0 || Receiver.bluetooth > 0));
    menu.findItem(ANSWER_MENU_ITEM)
        .setVisible(Receiver.call_state == UserAgent.UA_STATE_INCOMING_CALL);

    return result;
  }
Ejemplo n.º 2
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
      case KeyEvent.KEYCODE_MENU:
        if (Receiver.call_state == UserAgent.UA_STATE_INCOMING_CALL
            && mSlidingCardManager == null) {
          answer();
          return true;
        }
        break;

      case KeyEvent.KEYCODE_CALL:
        switch (Receiver.call_state) {
          case UserAgent.UA_STATE_INCOMING_CALL:
            answer();
            break;
          case UserAgent.UA_STATE_INCALL:
          case UserAgent.UA_STATE_HOLD:
            Receiver.engine(this).togglehold();
            break;
        }
        // consume KEYCODE_CALL so PhoneWindow doesn't do anything with it
        return true;

      case KeyEvent.KEYCODE_BACK:
        if (mDialerDrawer.isOpened()) mDialerDrawer.animateClose();
        else if (Receiver.call_state == UserAgent.UA_STATE_INCOMING_CALL) reject();
        return true;

      case KeyEvent.KEYCODE_CAMERA:
        // Disable the CAMERA button while in-call since it's too
        // easy to press accidentally.
        return true;

      case KeyEvent.KEYCODE_VOLUME_DOWN:
      case KeyEvent.KEYCODE_VOLUME_UP:
        if (Receiver.call_state == UserAgent.UA_STATE_INCOMING_CALL) {
          Receiver.stopRingtone();
          return true;
        }
        RtpStreamReceiver.adjust(keyCode, true);
        return true;
    }
    if (Receiver.call_state == UserAgent.UA_STATE_INCALL) {
      char number = event.getNumber();
      if (Character.isDigit(number) || number == '*' || number == '#') {
        appendDigit(number);
        return true;
      }
    }
    return super.onKeyDown(keyCode, event);
  }
Ejemplo n.º 3
0
  /** Starts media application */
  public boolean startMedia() {
    printLog("starting java audio..", LogLevel.HIGH);

    if (sender != null) {
      printLog("start sending", LogLevel.LOW);
      sender.start();
    }
    if (receiver != null) {
      printLog("start receiving", LogLevel.LOW);
      receiver.start();
    }

    return true;
  }
Ejemplo n.º 4
0
 /** Stops media application */
 public boolean stopMedia() {
   printLog("halting java audio..", LogLevel.HIGH);
   if (sender != null) {
     sender.halt();
     sender = null;
     printLog("sender halted", LogLevel.LOW);
   }
   if (receiver != null) {
     receiver.halt();
     receiver = null;
     printLog("receiver halted", LogLevel.LOW);
   }
   if (socket != null) socket.close();
   return true;
 }
Ejemplo n.º 5
0
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case MSG_ANSWER:
       if (Receiver.call_state == UserAgent.UA_STATE_INCOMING_CALL) answer();
       break;
     case MSG_ANSWER_SPEAKER:
       if (Receiver.call_state == UserAgent.UA_STATE_INCOMING_CALL) {
         answer();
         Receiver.engine(mContext).speaker(AudioManager.MODE_NORMAL);
       }
       break;
     case MSG_BACK:
       moveBack();
       break;
     case MSG_TICK:
       mCodec.setText(RtpStreamReceiver.getCodec());
       if (RtpStreamReceiver.good != 0) {
         if (RtpStreamReceiver.timeout != 0) mStats.setText("no data");
         else if (RtpStreamSender.m == 2)
           mStats.setText(
               Math.round(RtpStreamReceiver.loss / RtpStreamReceiver.good * 100)
                   + "%loss, "
                   + Math.round(RtpStreamReceiver.lost / RtpStreamReceiver.good * 100)
                   + "%lost, "
                   + Math.round(RtpStreamReceiver.late / RtpStreamReceiver.good * 100)
                   + "%late (>"
                   + (RtpStreamReceiver.jitter - 250 * RtpStreamReceiver.mu)
                       / 8
                       / RtpStreamReceiver.mu
                   + "ms)");
         else
           mStats.setText(
               Math.round(RtpStreamReceiver.lost / RtpStreamReceiver.good * 100)
                   + "%lost, "
                   + Math.round(RtpStreamReceiver.late / RtpStreamReceiver.good * 100)
                   + "%late (>"
                   + (RtpStreamReceiver.jitter - 250 * RtpStreamReceiver.mu)
                       / 8
                       / RtpStreamReceiver.mu
                   + "ms)");
         mStats.setVisibility(View.VISIBLE);
       } else mStats.setVisibility(View.GONE);
       break;
   }
 }
Ejemplo n.º 6
0
 @Override
 public boolean onKeyUp(int keyCode, KeyEvent event) {
   switch (keyCode) {
     case KeyEvent.KEYCODE_VOLUME_DOWN:
     case KeyEvent.KEYCODE_VOLUME_UP:
       RtpStreamReceiver.adjust(keyCode, false);
       return true;
     case KeyEvent.KEYCODE_ENDCALL:
       if (Receiver.pstn_state == null
           || (Receiver.pstn_state.equals("IDLE")
               && (SystemClock.elapsedRealtime() - Receiver.pstn_time) > 3000)) {
         reject();
         return true;
       }
       break;
   }
   Receiver.pstn_time = 0;
   return false;
 }
Ejemplo n.º 7
0
 @Override
 public void onPause() {
   super.onPause();
   if (!Sipdroid.release) Log.i("SipUA:", "on pause");
   switch (Receiver.call_state) {
     case UserAgent.UA_STATE_INCOMING_CALL:
       if (!RtpStreamReceiver.isBluetoothAvailable()) Receiver.moveTop();
       break;
     case UserAgent.UA_STATE_IDLE:
       if (Receiver.ccCall != null) mCallCard.displayMainCallStatus(ccPhone, Receiver.ccCall);
       mHandler.sendEmptyMessageDelayed(MSG_BACK, Receiver.call_end_reason == -1 ? 2000 : 5000);
       break;
   }
   if (t != null) {
     running = false;
     t.interrupt();
   }
   screenOff(false);
   if (mCallCard.mElapsedTime != null) mCallCard.mElapsedTime.stop();
 }
Ejemplo n.º 8
0
 public void bluetoothMedia() {
   if (receiver != null) receiver.bluetooth();
 }
Ejemplo n.º 9
0
 public int speakerMedia(int mode) {
   if (receiver != null) return receiver.speaker(mode);
   return 0;
 }
Ejemplo n.º 10
0
  public void updateSummaries() {
    getPreferenceScreen()
        .findPreference(PREF_STUN_SERVER)
        .setSummary(settings.getString(PREF_STUN_SERVER, DEFAULT_STUN_SERVER));
    getPreferenceScreen()
        .findPreference(PREF_STUN_SERVER_PORT)
        .setSummary(settings.getString(PREF_STUN_SERVER_PORT, DEFAULT_STUN_SERVER_PORT));

    // MMTel settings (added by mandrajg)
    getPreferenceScreen()
        .findPreference(PREF_MMTEL_QVALUE)
        .setSummary(settings.getString(PREF_MMTEL_QVALUE, DEFAULT_MMTEL_QVALUE));

    for (int i = 0; i < SipdroidEngine.LINES; i++) {
      String j = (i != 0 ? "" + i : "");
      String username = settings.getString(PREF_USERNAME + j, DEFAULT_USERNAME),
          server = settings.getString(PREF_SERVER + j, DEFAULT_SERVER);
      getPreferenceScreen().findPreference(PREF_USERNAME + j).setSummary(username);
      getPreferenceScreen().findPreference(PREF_SERVER + j).setSummary(server);
      if (settings.getString(PREF_DOMAIN + j, DEFAULT_DOMAIN).length() == 0) {
        getPreferenceScreen()
            .findPreference(PREF_DOMAIN + j)
            .setSummary(getString(R.string.settings_domain2));
      } else {
        getPreferenceScreen()
            .findPreference(PREF_DOMAIN + j)
            .setSummary(settings.getString(PREF_DOMAIN + j, DEFAULT_DOMAIN));
      }
      if (settings.getString(PREF_FROMUSER + j, DEFAULT_FROMUSER).length() == 0) {
        getPreferenceScreen()
            .findPreference(PREF_FROMUSER + j)
            .setSummary(getString(R.string.settings_callerid2));
      } else {
        getPreferenceScreen()
            .findPreference(PREF_FROMUSER + j)
            .setSummary(settings.getString(PREF_FROMUSER + j, DEFAULT_FROMUSER));
      }
      getPreferenceScreen()
          .findPreference(PREF_PORT + j)
          .setSummary(settings.getString(PREF_PORT + j, DEFAULT_PORT));
      getPreferenceScreen()
          .findPreference(PREF_PROTOCOL + j)
          .setSummary(
              settings
                  .getString(
                      PREF_PROTOCOL + j,
                      settings.getString(PREF_SERVER + j, DEFAULT_SERVER).equals(DEFAULT_SERVER)
                          ? "tcp"
                          : "udp")
                  .toUpperCase());
      getPreferenceScreen()
          .findPreference(PREF_ACCOUNT + j)
          .setSummary(
              username.equals("") || server.equals("")
                  ? getResources().getString(R.string.settings_line) + " " + (i + 1)
                  : username + "@" + server);
    }

    getPreferenceScreen()
        .findPreference(PREF_SEARCH)
        .setSummary(settings.getString(PREF_SEARCH, DEFAULT_SEARCH));
    getPreferenceScreen()
        .findPreference(PREF_EXCLUDEPAT)
        .setSummary(settings.getString(PREF_EXCLUDEPAT, DEFAULT_EXCLUDEPAT));
    getPreferenceScreen()
        .findPreference(PREF_POSURL)
        .setSummary(settings.getString(PREF_POSURL, DEFAULT_POSURL));
    getPreferenceScreen()
        .findPreference(PREF_CALLTHRU2)
        .setSummary(settings.getString(PREF_CALLTHRU2, DEFAULT_CALLTHRU2));
    if (!settings.getString(PREF_PREF, DEFAULT_PREF).equals(VAL_PREF_PSTN)) {
      getPreferenceScreen().findPreference(PREF_PAR).setEnabled(true);
    } else {
      getPreferenceScreen().findPreference(PREF_PAR).setEnabled(false);
    }
    fill(
        PREF_EARGAIN, "" + DEFAULT_EARGAIN, R.array.eargain_values, R.array.eargain_display_values);
    fill(
        PREF_MICGAIN, "" + DEFAULT_MICGAIN, R.array.eargain_values, R.array.eargain_display_values);
    fill(
        PREF_HEARGAIN,
        "" + DEFAULT_HEARGAIN,
        R.array.eargain_values,
        R.array.eargain_display_values);
    fill(
        PREF_HMICGAIN,
        "" + DEFAULT_HMICGAIN,
        R.array.eargain_values,
        R.array.eargain_display_values);
    fill(PREF_VQUALITY, DEFAULT_VQUALITY, R.array.vquality_values, R.array.vquality_display_values);
    if (settings.getBoolean(PREF_STUN, DEFAULT_STUN)) {
      getPreferenceScreen().findPreference(PREF_STUN_SERVER).setEnabled(true);
      getPreferenceScreen().findPreference(PREF_STUN_SERVER_PORT).setEnabled(true);
    } else {
      getPreferenceScreen().findPreference(PREF_STUN_SERVER).setEnabled(false);
      getPreferenceScreen().findPreference(PREF_STUN_SERVER_PORT).setEnabled(false);
    }

    // MMTel configuration (added by mandrajg)
    if (settings.getBoolean(PREF_MMTEL, DEFAULT_MMTEL)) {
      getPreferenceScreen().findPreference(PREF_MMTEL_QVALUE).setEnabled(true);
    } else {
      getPreferenceScreen().findPreference(PREF_MMTEL_QVALUE).setEnabled(false);
    }

    if (settings.getBoolean(PREF_CALLTHRU, DEFAULT_CALLTHRU)) {
      getPreferenceScreen().findPreference(PREF_CALLTHRU2).setEnabled(true);
    } else {
      getPreferenceScreen().findPreference(PREF_CALLTHRU2).setEnabled(false);
    }
    if (!settings.getString(PREF_POSURL, DEFAULT_POSURL).equals(DEFAULT_POSURL)) {
      getPreferenceScreen().findPreference(PREF_POS).setEnabled(!DEFAULT_POS);
      getPreferenceScreen().findPreference(PREF_CALLBACK).setEnabled(!DEFAULT_CALLBACK);
    } else {
      getPreferenceScreen().findPreference(PREF_POS).setEnabled(DEFAULT_POS);
      getPreferenceScreen().findPreference(PREF_CALLBACK).setEnabled(DEFAULT_CALLBACK);
    }
    getPreferenceScreen()
        .findPreference(PREF_BLUETOOTH)
        .setEnabled(RtpStreamReceiver.isBluetoothSupported());
  }