@Override
  public void onBackPressed() {
    Log.i(this, "onBackPressed");

    // BACK is also used to exit out of any "special modes" of the
    // in-call UI:

    if (!mConferenceManagerFragment.isVisible() && !mCallCardFragment.isVisible()) {
      return;
    }

    if (mDialpadFragment != null && mDialpadFragment.isVisible()) {
      mCallButtonFragment.displayDialpad(false /* show */, true /* animate */);
      return;
    } else if (mConferenceManagerFragment.isVisible()) {
      showConferenceCallManager(false);
      return;
    }

    // Always disable the Back key while an incoming call is ringing
    final Call call = CallList.getInstance().getIncomingCall();
    if (call != null) {
      Log.d(this, "Consume Back press for an incoming call");
      return;
    }

    // Nothing special to do.  Fall back to the default behavior.
    super.onBackPressed();
  }
  /**
   * Hides or shows the conference manager fragment.
   *
   * @param show {@code true} if the conference manager should be shown, {@code false} if it should
   *     be hidden.
   */
  public void showConferenceCallManager(boolean show) {
    mConferenceManagerFragment.setVisible(show);

    // Need to hide the call card fragment to ensure that accessibility service does not try to
    // give focus to the call card when the conference manager is visible.
    mCallCardFragment.getView().setVisibility(show ? View.GONE : View.VISIBLE);
  }
  private void initializeInCall() {
    if (mCallCardFragment == null) {
      mCallCardFragment =
          (CallCardFragment) getFragmentManager().findFragmentById(R.id.callCardFragment);
    }

    mChildFragmentManager = mCallCardFragment.getChildFragmentManager();

    if (mCallButtonFragment == null) {
      mCallButtonFragment =
          (CallButtonFragment) mChildFragmentManager.findFragmentById(R.id.callButtonFragment);
      mCallButtonFragment.getView().setVisibility(View.INVISIBLE);
    }

    if (mAnswerFragment == null) {
      mAnswerFragment =
          (AnswerFragment) mChildFragmentManager.findFragmentById(R.id.answerFragment);
    }

    if (mConferenceManagerFragment == null) {
      mConferenceManagerFragment =
          (ConferenceManagerFragment)
              getFragmentManager().findFragmentById(R.id.conferenceManagerFragment);
      mConferenceManagerFragment.getView().setVisibility(View.INVISIBLE);
    }
  }