Example #1
0
 /**
  * Add call number info to call history database for international dialing feature !!!! need to
  * check okToLogThisCall is suitable for international dialing feature
  *
  * @param number The number for the call being logged.
  * @param start The start time of the call being logged.
  * @param duration The duration of the call being logged.
  * @param isSipCall whether sip call
  * @param slotId The slot id for the call being logged.
  */
 private void addCallHistoryAsync(
     String number, long start, long duration, boolean isSipCall, int slotId) {
   final boolean isEmergencyNumber = PhoneNumberUtils.isLocalEmergencyNumber(number, mApplication);
   if (!isEmergencyNumber
       && !mIsComing
       && mVtCall != CALL_TYPE_VIDEO
       && !isSipCall
       && duration >= CallNotifier.CALL_DURATION_THRESHOLD_FOR_CALL_HISTORY
       && slotId > -1) {
     String countryISO = CallOptionUtils.getCurrentCountryISO(PhoneGlobals.getInstance());
     try {
       new CallHistoryAsync()
           .addCall(
               new CallHistoryAsync.AddCallArgs(
                   PhoneGlobals.getInstance(),
                   number,
                   countryISO,
                   start,
                   slotId,
                   GeminiUtils.isGeminiSupport()));
     } catch (SQLiteDiskIOException e) {
       // TODO Auto-generated catch block
       Log.e(LOG_TAG, "Error!! - onDisconnect() Disk Full!");
       e.printStackTrace();
     }
   }
 }
Example #2
0
  /* package */ Call onNewRingingConnection(Connection conn) {
    Log.i(TAG, "onNewRingingConnection");
    final Call call = getCallFromMap(mCallMap, conn, true);

    if (call != null) {
      Phone phone = conn.getCall().getPhone();
      if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM && mNextGsmCallIsForwarded) {
        call.setForwarded(true);
        mNextGsmCallIsForwarded = false;
      }

      updateCallFromConnection(call, conn, false);
      for (int i = 0; i < mListeners.size(); ++i) {
        mListeners.get(i).onIncoming(call);
      }
      if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
        int subscription = conn.getCall().getPhone().getSubscription();
        Log.i(TAG, "Setting Active sub : '" + subscription + "'");
        PhoneUtils.setActiveSubscription(subscription);
        // if any local hold tones are playing then they need to be stoped.
        final MSimCallNotifier notifier = (MSimCallNotifier) PhoneGlobals.getInstance().notifier;
        notifier.manageLocalCallWaitingTone();
      }
    }

    PhoneGlobals.getInstance().updateWakeState();
    return call;
  }
Example #3
0
  /*
   * New Feature by Mediatek Begin.
   *   CR ID: ALPS00114062
   */
  private String formatDuration(long elapsedSeconds) {
    long minutes = 0;
    long seconds = 0;

    if (elapsedSeconds >= 60) {
      minutes = elapsedSeconds / 60;
      elapsedSeconds -= minutes * 60;
    }
    seconds = elapsedSeconds;

    return (mApplication.getString(R.string.card_title_call_ended)
        + "("
        + mApplication.getString(R.string.callDurationFormat, minutes, seconds)
        + ")");
  }
Example #4
0
  private void onDisconnect(Connection conn) {
    Log.i(TAG, "onDisconnect");

    mVoicePrivacyState = false;
    final Call call = getCallFromMap(mCallMap, conn, false);

    if (call != null) {
      final boolean wasConferenced = call.getState() == State.CONFERENCED;

      updateCallFromConnection(call, conn, false);

      for (int i = 0; i < mListeners.size(); ++i) {
        mListeners.get(i).onDisconnect(call);
      }

      // If it was a conferenced call, we need to run the entire update
      // to make the proper changes to parent conference calls.
      if (wasConferenced) {
        onPhoneStateChanged(null);
      }

      mCallMap.remove(conn);
    }

    if (MSimTelephonyManager.getDefault().isMultiSimEnabled() && (call != null)) {
      mCallManager.clearDisconnected(call.getSubscription());
    } else {
      mCallManager.clearDisconnected();
    }
    PhoneGlobals.getInstance().updateWakeState();
  }
Example #5
0
 /**
  * Get the call arguments when CallWaiting reject for CDMA.
  *
  * @param ci The caller information for the call being logged.
  * @param number The number for the call being logged.
  * @param presentation The presentation to use in the logs.
  * @param callType The type of call log entry.
  * @param start The start time of call being logged.
  * @param duration The duration for call being logged.
  * @param slotId The slot id for the call being logged.
  * @return CallLogAsync.AddCallArgs related args for the call being logged.
  */
 private CallLogAsync.AddCallArgs getCallArgsForCdmaCallWaitingReject(
     CallerInfo ci,
     String number,
     int presentation,
     int callType,
     long start,
     long duration,
     int slotId) {
   if (DBG) {
     log("getCallArgsForCdmaCallWaitingReject");
   }
   CallLogAsync.AddCallArgs cdmaArgs;
   if (GeminiUtils.isGeminiSupport()) {
     if (DBG) {
       log("getCallArgsForCdmaCallWaitingReject, support gemini.");
     }
     int cdmaSimId = 0;
     if (ITelephonyWrapper.hasIccCard(slotId)) {
       SimInfoRecord si = SimInfoManager.getSimInfoBySlot(PhoneGlobals.getInstance(), slotId);
       if (si != null) {
         cdmaSimId = (int) si.mSimInfoId;
       }
     }
     cdmaArgs =
         new CallLogAsync.AddCallArgs(
             mApplication, ci, number, presentation, callType, start, duration, cdmaSimId);
   } else {
     cdmaArgs =
         new CallLogAsync.AddCallArgs(
             mApplication, ci, number, presentation, callType, start, duration);
   }
   return cdmaArgs;
 }
Example #6
0
  @Override
  protected void onDialogClosed(boolean positiveResult) {
    super.onDialogClosed(positiveResult);

    if (!positiveResult) {
      // The button was dismissed - no need to set new value
      return;
    }

    int buttonCdmaSubscriptionMode = Integer.valueOf(getValue()).intValue();
    Log.d(LOG_TAG, "Setting new value " + buttonCdmaSubscriptionMode);
    int statusCdmaSubscriptionMode;
    switch (buttonCdmaSubscriptionMode) {
      case CDMA_SUBSCRIPTION_NV:
        statusCdmaSubscriptionMode = Phone.CDMA_SUBSCRIPTION_NV;
        break;
      case CDMA_SUBSCRIPTION_RUIM_SIM:
        statusCdmaSubscriptionMode = Phone.CDMA_SUBSCRIPTION_RUIM_SIM;
        break;
      default:
        statusCdmaSubscriptionMode = Phone.PREFERRED_CDMA_SUBSCRIPTION;
    }

    // Set the CDMA subscription mode, when mode has been successfully changed
    // handleSetCdmaSubscriptionMode will be invoked and the value saved.
    mPhone.setCdmaSubscription(
        statusCdmaSubscriptionMode,
        mHandler.obtainMessage(
            CdmaSubscriptionButtonHandler.MESSAGE_SET_CDMA_SUBSCRIPTION, getValue()));

    PhoneGlobals.getInstance().removeSubInfoUpdateListener(this);
  }
Example #7
0
  @Override
  protected void showDialog(Bundle state) {
    setCurrentCdmaSubscriptionModeValue();

    super.showDialog(state);
    PhoneGlobals.getInstance().addSubInfoUpdateListener(this);
  }
 private static boolean handlePinEntryGemini(Context context, String s, Activity activity, int i) {
   if ((s.startsWith("**04") || s.startsWith("**05")) && s.endsWith("#")) {
     PhoneGlobals phoneglobals = PhoneGlobals.getInstance();
     boolean flag = GeminiUtils.handlePinMmi(phoneglobals.phone, s, i);
     log(
         (new StringBuilder())
             .append("SpecialCharSequenceMgr , handlePinEntryGemini(), simId:")
             .append(i)
             .append(", isMMIHandled:")
             .append(flag)
             .toString());
     if (flag && s.startsWith("**05*")) phoneglobals.setPukEntryActivity(activity);
     return flag;
   } else {
     return false;
   }
 }
Example #9
0
  /** Logs a call to the call from the parameters passed in. */
  public void logCall(
      CallerInfo ci,
      String number,
      int presentation,
      int callType,
      long start,
      long duration,
      int slotId) {
    final boolean isEmergencyNumber = PhoneNumberUtils.isLocalEmergencyNumber(number, mApplication);

    // On some devices, to avoid accidental redialing of
    // emergency numbers, we *never* log emergency calls to
    // the Call Log.  (This behavior is set on a per-product
    // basis, based on carrier requirements.)
    final boolean okToLogEmergencyNumber =
        mApplication.getResources().getBoolean(R.bool.allow_emergency_numbers_in_call_log);

    // Don't log emergency numbers if the device doesn't allow it,
    boolean isOkToLogThisCall = !isEmergencyNumber || okToLogEmergencyNumber;

    if (isOkToLogThisCall) {
      if (DBG) {
        log(
            "sending Calllog entry: "
                + ci
                + ", "
                + PhoneUtils.toLogSafePhoneNumber(number)
                + ","
                + presentation
                + ", "
                + callType
                + ", "
                + start
                + ", "
                + duration);
      }

      /// M: For GEMINI or Other type call(Ex: sip call/video call) @{
      CallLogAsync.AddCallArgs args;
      if (mPhoneType == PhoneConstants.PHONE_TYPE_CDMA && mIsCdmaCallWaitingReject) {
        args =
            getCallArgsForCdmaCallWaitingReject(
                ci, number, presentation, callType, start, duration, slotId);
      } else {
        args = getCallArgs(ci, number, presentation, callType, start, duration, slotId);
      }
      /// @}

      try {
        mCallLog.addCall(args);
      } catch (SQLiteDiskIOException e) {
        // TODO Auto-generated catch block
        Log.e(LOG_TAG, "Error!! - logCall() Disk Full!");
        e.printStackTrace();
      }
    }
    reset();
  }
Example #10
0
  /** Called when the phone state changes. */
  private void onPhoneStateChanged(AsyncResult r) {
    Log.i(TAG, "onPhoneStateChanged: ");
    // csvt state changed, do not update phone UI.
    if (PhoneGlobals.getInstance().isCsvtActive()) {
      Log.d(TAG, "csvt is active, do not update phone UI.");
      return;
    }
    final List<Call> updatedCalls = Lists.newArrayList();
    doUpdate(false, updatedCalls);

    if (updatedCalls.size() > 0) {
      for (int i = 0; i < mListeners.size(); ++i) {
        mListeners.get(i).onUpdate(updatedCalls);
      }
    }

    PhoneGlobals.getInstance().updateWakeState();
  }
 private static boolean handleAdnEntry(Context context, String s) {
   int i;
   if (!PhoneGlobals.getInstance().getKeyguardManager().inKeyguardRestrictedInputMode())
     if ((i = s.length()) > 1 && i < 5 && s.endsWith("#")) {
       int j = i - 1;
       try {
         int k = Integer.parseInt(s.substring(0, j));
         Intent intent = new Intent("android.intent.action.PICK");
         intent.setClassName("com.android.phone", com / android / phone / SimContacts.getName());
         intent.setFlags(0x10000000);
         intent.putExtra("index", k);
         PhoneGlobals.getInstance().startActivity(intent);
       } catch (NumberFormatException numberformatexception) {
         return false;
       }
       return true;
     }
   return false;
 }
Example #12
0
  /**
   * Logs a call to the call log based on the connection object passed in.
   *
   * @param c The connection object for the call being logged.
   * @param callLogType The type of call log entry.
   * @param slotId The slot id for the call being logged.
   */
  public void logCall(Connection c, int callLogType, int slotId) {
    final String number = c.getAddress();
    final long date = c.getCreateTime();
    final long duration = c.getDurationMillis();
    final Phone phone = c.getCall().getPhone();

    final CallerInfo ci = getCallerInfoFromConnection(c); // May be null.
    final String logNumber = getLogNumber(c, ci);

    if (DBG) {
      log(
          "- onDisconnect(): logNumber set to:"
              + PhoneUtils.toLogSafePhoneNumber(logNumber)
              + ", number set to: "
              + PhoneUtils.toLogSafePhoneNumber(number));
    }

    /// M: @{
    mPhoneType = phone.getPhoneType();
    mIsComing = c.isIncoming();
    if (FeatureOption.MTK_VT3G324M_SUPPORT) {
      mVtCall = c.isVideo() ? 1 : 0;
    }
    PhoneLog.d(LOG_TAG, "number=" + number + ", duration=" + duration + ", isVT=" + mVtCall);
    /// @}

    /// M: For ALPS00114062 @{
    // show every connection's last time of conference call.
    if (needToShowCallTime(c, duration)) {
      Toast.makeText(
              mApplication.getApplicationContext(),
              formatDuration((int) (duration / 1000)),
              Toast.LENGTH_SHORT)
          .show();
    }
    /// @}

    // TODO: In getLogNumber we use the presentation from
    // the connection for the CNAP. Should we use the one
    // below instead? (comes from caller info)

    // For international calls, 011 needs to be logged as +
    final int presentation = getPresentation(c, ci);

    final boolean isOtaspNumber =
        TelephonyCapabilities.supportsOtasp(phone) && phone.isOtaSpNumber(number);

    // Don't log OTASP calls.
    if (!isOtaspNumber) {
      logCall(ci, logNumber, presentation, callLogType, date, duration, slotId);
    }
  }
Example #13
0
  /**
   * Get the caller info.
   *
   * @param conn The phone connection.
   * @return The CallerInfo associated with the connection. Maybe null.
   */
  public static CallerInfo getCallerInfoFromConnection(Connection conn) {
    CallerInfo ci = null;
    Object o = conn.getUserData();

    if ((o == null) || (o instanceof CallerInfo)) {
      ci = (CallerInfo) o;
    } else if (o instanceof Uri) {
      ci = CallerInfo.getCallerInfo(PhoneGlobals.getInstance().getApplicationContext(), (Uri) o);
    } else {
      ci = ((PhoneUtils.CallerInfoToken) o).currentInfo;
    }
    return ci;
  }
Example #14
0
  private int translateStateFromTelephony(Connection connection, boolean isForConference) {

    com.android.internal.telephony.Call.State connState = connection.getState();

    // For the "fake" outgoing CDMA call, we need to always treat it as an outgoing call.
    if (mCdmaOutgoingConnection == connection) {
      connState = com.android.internal.telephony.Call.State.DIALING;
    }

    int retval = State.IDLE;
    switch (connState) {
      case ACTIVE:
        retval = State.ACTIVE;
        break;
      case INCOMING:
        retval = State.INCOMING;
        break;
      case DIALING:
      case ALERTING:
        if (PhoneGlobals.getInstance().notifier.getIsCdmaRedialCall()) {
          retval = State.REDIALING;
        } else {
          retval = State.DIALING;
        }
        break;
      case WAITING:
        retval = State.CALL_WAITING;
        break;
      case HOLDING:
        retval = State.ONHOLD;
        break;
      case DISCONNECTING:
        retval = State.DISCONNECTING;
        break;
      case DISCONNECTED:
        retval = State.DISCONNECTED;
      default:
    }

    // If we are dealing with a potential child call (not the parent conference call),
    // the check to see if we have to set the state to CONFERENCED.
    if (!isForConference) {
      // if the connection is part of a multiparty call, and it is live,
      // annotate it with CONFERENCED state instead.
      if (isPartOfLiveConferenceCall(connection) && connection.isAlive()) {
        return State.CONFERENCED;
      }
    }

    return retval;
  }
 private static void showDeviceIdPanel(Context context) {
   Phone phone = PhoneGlobals.getPhone();
   int i = TelephonyCapabilities.getDeviceIdLabel(phone);
   String s = phone.getDeviceId();
   AlertDialog alertdialog =
       (new android.app.AlertDialog.Builder(context))
           .setTitle(i)
           .setMessage(s)
           .setPositiveButton(0x7f0d0192, null)
           .setCancelable(false)
           .create();
   alertdialog.getWindow().setType(2007);
   alertdialog.show();
 }
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    mPhone = PhoneGlobals.getPhone();

    resolveIntent();

    setContentView(R.layout.change_sim_pin_screen);

    mOldPin = (EditText) findViewById(R.id.old_pin);
    mOldPin.setKeyListener(DigitsKeyListener.getInstance());
    mOldPin.setMovementMethod(null);
    mOldPin.setOnClickListener(mClicked);

    mNewPin1 = (EditText) findViewById(R.id.new_pin1);
    mNewPin1.setKeyListener(DigitsKeyListener.getInstance());
    mNewPin1.setMovementMethod(null);
    mNewPin1.setOnClickListener(mClicked);

    mNewPin2 = (EditText) findViewById(R.id.new_pin2);
    mNewPin2.setKeyListener(DigitsKeyListener.getInstance());
    mNewPin2.setMovementMethod(null);
    mNewPin2.setOnClickListener(mClicked);

    mBadPinError = (TextView) findViewById(R.id.bad_pin);
    mMismatchError = (TextView) findViewById(R.id.mismatch);

    mButton = (Button) findViewById(R.id.button);
    mButton.setOnClickListener(mClicked);

    mScrollView = (ScrollView) findViewById(R.id.scroll);

    mPUKCode = (EditText) findViewById(R.id.puk_code);
    mPUKCode.setKeyListener(DigitsKeyListener.getInstance());
    mPUKCode.setMovementMethod(null);
    mPUKCode.setOnClickListener(mClicked);

    mPUKSubmit = (Button) findViewById(R.id.puk_submit);
    mPUKSubmit.setOnClickListener(mClicked);

    mIccPUKPanel = (LinearLayout) findViewById(R.id.puk_panel);

    int id = mChangePin2 ? R.string.change_pin2 : R.string.change_pin;
    setTitle(getResources().getText(id));

    mState = EntryState.ES_PIN;
  }
Example #17
0
  /**
   * Get the call arguments when disconnected.
   *
   * @param ci The caller information for the call being logged.
   * @param number The number for the call being logged.
   * @param presentation The presentation to use in the logs.
   * @param callType The type of call log entry.
   * @param start The start time of call being logged.
   * @param duration The duration of call being logged.
   * @param slotId The slot id for the call being logged.
   * @return CallLogAsync.AddCallArgs related args for the call being logged.
   */
  private CallLogAsync.AddCallArgs getCallArgs(
      CallerInfo ci,
      String number,
      int presentation,
      int callType,
      long start,
      long duration,
      int slotId) {
    CallLogAsync.AddCallArgs args;
    int simIdEx = CallNotifier.CALL_TYPE_NONE;
    // Get the phone type for sip
    boolean isSipCall = false;
    if (mPhoneType == PhoneConstants.PHONE_TYPE_SIP) {
      isSipCall = true;
    }
    if (!GeminiUtils.isGeminiSupport() || isSipCall) {
      // Single Card
      if (isSipCall) {
        simIdEx = CallNotifier.CALL_TYPE_SIP;
      } else {
        simIdEx = CallNotifier.CALL_TYPE_NONE;
        if (ITelephonyWrapper.hasIccCard(PhoneConstants.GEMINI_SIM_1)) {
          SimInfoRecord info = SIMInfoWrapper.getDefault().getSimInfoBySlot(0);
          if (info != null) {
            simIdEx = (int) info.mSimInfoId;
          } else {
            // Give an default simId, in most case, this is invalid
            simIdEx = 1;
          }
        }
        if (DBG) {
          log("for single card, simIdEx = " + simIdEx);
        }
      }
    } else {
      // dual SIM
      // Geminni Enhancement: change call log to sim id;
      SimInfoRecord si;
      if (ITelephonyWrapper.hasIccCard(slotId)) {
        si = SimInfoManager.getSimInfoBySlot(PhoneGlobals.getInstance(), slotId);
        if (si != null) {
          simIdEx = (int) si.mSimInfoId;
        }
      }
      if (DBG) {
        log("for dual SIM, simIdEx = " + simIdEx);
      }
    }

    if (FeatureOption.MTK_VT3G324M_SUPPORT) {
      args =
          new CallLogAsync.AddCallArgs(
              mApplication, ci, number, presentation, callType, start, duration, simIdEx, mVtCall);
    } else {
      args =
          new CallLogAsync.AddCallArgs(
              mApplication, ci, number, presentation, callType, start, duration, simIdEx);
    }

    addCallHistoryAsync(number, start, duration, isSipCall, slotId);
    return args;
  }