示例#1
0
  private void initForNewRadioTechnology() {
    if (DBG) Log.d(LOG_TAG, "initForNewRadioTechnology...");

    ringer.updateRingerContextAfterRadioTechnologyChange(this.phone);
    notifier.updateCallNotifierRegistrationsAfterRadioTechnologyChange();
    if (mBtHandsfree != null) {
      mBtHandsfree.updateBtHandsfreeAfterRadioTechnologyChange();
    }
    if (mInCallScreen != null) {
      mInCallScreen.updateAfterRadioTechnologyChange();
    }

    // Update registration for ICC status after radio technology change
    IccCard sim = phone.getIccCard();
    if (sim != null) {
      if (DBG) Log.d(LOG_TAG, "Update registration for ICC status...");

      // Register all events new to the new active phone
      sim.registerForAbsent(mHandler, EVENT_SIM_ABSENT, null);
      sim.registerForLocked(mHandler, EVENT_SIM_LOCKED, null);
      sim.registerForNetworkLocked(mHandler, EVENT_SIM_NETWORK_LOCKED, null);
    }

    if (phone.getPhoneName().equals("CDMA")) {
      // Create an instance of CdmaPhoneCallState and initialize it to IDLE
      cdmaPhoneCallState = new CdmaPhoneCallState();
      cdmaPhoneCallState.CdmaPhoneCallStateInit();
    }
  }
示例#2
0
 private void tryChangeIccLockState() {
   // Try to change icc lock. If it succeeds, toggle the lock state and
   // reset dialog state. Else inject error message and show dialog again.
   Message callback = Message.obtain(mHandler, MSG_ENABLE_ICC_PIN_COMPLETE);
   mPhone.getIccCard().setIccLockEnabled(mToState, mPin, callback);
   // Disable the setting till the response is received.
   mPinToggle.setEnabled(false);
 }
  @Override
  protected void onResume() {
    super.onResume();

    mPinToggle.setChecked(mPhone.getIccCard().getIccLockEnabled());

    if (mDialogState != OFF_MODE) {
      showPinDialog();
    } else {
      // Prep for standard click on "Change PIN"
      resetDialogState();
    }
  }
示例#4
0
 /**
  * Get the slotId's IccCard.
  *
  * @param phone
  * @param slotId
  * @return
  */
 public static IccCard getIccCard(Phone phone, int slotId) {
   Assert.assertNotNull(phone);
   IccCard iccCardInterface = null;
   if (GeminiUtils.isGeminiSupport()) {
     PhoneLog.d(TAG, "[getIccCard], slotId = " + slotId);
     if (GeminiUtils.isValidSlot(slotId)) {
       iccCardInterface = ((GeminiPhone) phone).getPhonebyId(slotId).getIccCard();
     }
   } else {
     iccCardInterface = phone.getIccCard();
   }
   return iccCardInterface;
 }
 /** @return true if a ICC card is present */
 public boolean hasIccCard() {
   return mPhone.getIccCard().hasIccCard();
 }
 // Gets the retry count during PIN1/PIN2/PUK1/PUK2 verification.
 public int getIccPin1RetryCount() {
   return mPhone.getIccCard().getIccPin1RetryCount();
 }
 public boolean supplyPuk(String puk, String pin) {
   enforceModifyPermission();
   final UnlockSim checkSimPuk = new UnlockSim(mPhone.getIccCard());
   checkSimPuk.start();
   return checkSimPuk.unlockSim(puk, pin);
 }
 public boolean supplyPin(String pin) {
   enforceModifyPermission();
   final UnlockSim checkSimPin = new UnlockSim(mPhone.getIccCard());
   checkSimPin.start();
   return checkSimPin.unlockSim(null, pin);
 }
示例#9
0
 private void tryChangePin() {
   Message callback = Message.obtain(mHandler, MSG_CHANGE_ICC_PIN_COMPLETE);
   mPhone.getIccCard().changeIccLockPassword(mOldPin, mNewPin, callback);
 }
示例#10
0
 private void updatePreferences() {
   mPinToggle.setChecked(mPhone.getIccCard().getIccLockEnabled());
 }
 private void tryChangeIccLockState() {
   // Try to change icc lock. If it succeeds, toggle the lock state and
   // reset dialog state. Else inject error message and show dialog again.
   Message callback = Message.obtain(mHandler, ENABLE_ICC_PIN_COMPLETE);
   mPhone.getIccCard().setIccLockEnabled(mToState, mPin, callback);
 }
        public void onClick(View v) {
          if (v == mOldPin) {
            mNewPin1.requestFocus();
          } else if (v == mNewPin1) {
            mNewPin2.requestFocus();
          } else if (v == mNewPin2) {
            mButton.requestFocus();
          } else if (v == mButton) {
            IccCard iccCardInterface = mPhone.getIccCard();
            if (iccCardInterface != null) {
              String oldPin = mOldPin.getText().toString();
              String newPin1 = mNewPin1.getText().toString();
              String newPin2 = mNewPin2.getText().toString();

              int error = validateNewPin(newPin1, newPin2);

              switch (error) {
                case PIN_INVALID_LENGTH:
                case PIN_MISMATCH:
                  mNewPin1.getText().clear();
                  mNewPin2.getText().clear();
                  mMismatchError.setVisibility(View.VISIBLE);

                  Resources r = getResources();
                  CharSequence text;

                  if (error == PIN_MISMATCH) {
                    text = r.getString(R.string.mismatchPin);
                  } else {
                    text = r.getString(R.string.invalidPin);
                  }

                  mMismatchError.setText(text);
                  break;

                default:
                  Message callBack = Message.obtain(mHandler, EVENT_PIN_CHANGED);

                  if (DBG) log("change pin attempt: old=" + oldPin + ", newPin=" + newPin1);

                  reset();

                  if (mChangePin2) {
                    iccCardInterface.changeIccFdnPassword(oldPin, newPin1, callBack);
                  } else {
                    iccCardInterface.changeIccLockPassword(oldPin, newPin1, callBack);
                  }

                  // TODO: show progress panel
              }
            }
          } else if (v == mPUKCode) {
            mPUKSubmit.requestFocus();
          } else if (v == mPUKSubmit) {
            mPhone
                .getIccCard()
                .supplyPuk2(
                    mPUKCode.getText().toString(),
                    mNewPin1.getText().toString(),
                    Message.obtain(mHandler, EVENT_PIN_CHANGED));
          }
        }
示例#13
0
  @Override
  public void onCreate() {
    if (Config.LOGV) Log.v(LOG_TAG, "onCreate()...");

    ContentResolver resolver = getContentResolver();

    if (phone == null) {
      // Initialize the telephony framework
      PhoneFactory.makeDefaultPhones(this);

      // Get the default phone
      phone = PhoneFactory.getDefaultPhone();

      NotificationMgr.init(this);

      phoneMgr = new PhoneInterfaceManager(this, phone);
      if (getSystemService(Context.BLUETOOTH_SERVICE) != null) {
        mBtHandsfree = new BluetoothHandsfree(this, phone);
        startService(new Intent(this, BluetoothHeadsetService.class));
      } else {
        // Device is not bluetooth capable
        mBtHandsfree = null;
      }

      ringer = new Ringer(phone);

      // before registering for phone state changes
      PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
      mWakeLock =
          pm.newWakeLock(
              PowerManager.FULL_WAKE_LOCK
                  | PowerManager.ACQUIRE_CAUSES_WAKEUP
                  | PowerManager.ON_AFTER_RELEASE,
              LOG_TAG);
      // lock used to keep the processor awake, when we don't care for the display.
      mPartialWakeLock =
          pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, LOG_TAG);
      mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
      mKeyguardLock = mKeyguardManager.newKeyguardLock(LOG_TAG);

      // get a handle to the service so that we can use it later when we
      // want to set the poke lock.
      mPowerManagerService = IPowerManager.Stub.asInterface(ServiceManager.getService("power"));

      notifier = new CallNotifier(this, phone, ringer, mBtHandsfree);

      // register for ICC status
      IccCard sim = phone.getIccCard();
      if (sim != null) {
        if (Config.LOGV) Log.v(LOG_TAG, "register for ICC status");
        sim.registerForAbsent(mHandler, EVENT_SIM_ABSENT, null);
        sim.registerForLocked(mHandler, EVENT_SIM_LOCKED, null);
        sim.registerForNetworkLocked(mHandler, EVENT_SIM_NETWORK_LOCKED, null);
      }

      // register for MMI/USSD
      phone.registerForMmiComplete(mHandler, MMI_COMPLETE, null);

      // register connection tracking to PhoneUtils
      PhoneUtils.initializeConnectionHandler(phone);

      // Register for misc other intent broadcasts.
      IntentFilter intentFilter = new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
      intentFilter.addAction(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION);
      intentFilter.addAction(BluetoothIntent.HEADSET_AUDIO_STATE_CHANGED_ACTION);
      intentFilter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
      intentFilter.addAction(Intent.ACTION_HEADSET_PLUG);
      intentFilter.addAction(Intent.ACTION_BATTERY_LOW);
      intentFilter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
      intentFilter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
      intentFilter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
      intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
      intentFilter.addAction(ACTION_VIBRATE_45);
      registerReceiver(mReceiver, intentFilter);

      // Use a separate receiver for ACTION_MEDIA_BUTTON broadcasts,
      // since we need to manually adjust its priority (to make sure
      // we get these intents *before* the media player.)
      IntentFilter mediaButtonIntentFilter = new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
      //
      // Make sure we're higher priority than the media player's
      // MediaButtonIntentReceiver (which currently has the default
      // priority of zero; see apps/Music/AndroidManifest.xml.)
      mediaButtonIntentFilter.setPriority(1);
      //
      registerReceiver(mMediaButtonReceiver, mediaButtonIntentFilter);

      // set the default values for the preferences in the phone.
      PreferenceManager.setDefaultValues(this, R.xml.network_setting, false);
      PreferenceManager.setDefaultValues(this, R.xml.call_feature_setting, false);

      // Make sure the audio mode (along with some
      // audio-mode-related state of our own) is initialized
      // correctly, given the current state of the phone.
      switch (phone.getState()) {
        case IDLE:
          if (DBG) Log.d(LOG_TAG, "Resetting audio state/mode: IDLE");
          PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_IDLE);
          PhoneUtils.setAudioMode(this, AudioManager.MODE_NORMAL);
          break;
        case RINGING:
          if (DBG) Log.d(LOG_TAG, "Resetting audio state/mode: RINGING");
          PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_RINGING);
          PhoneUtils.setAudioMode(this, AudioManager.MODE_RINGTONE);
          break;
        case OFFHOOK:
          if (DBG) Log.d(LOG_TAG, "Resetting audio state/mode: OFFHOOK");
          PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_OFFHOOK);
          PhoneUtils.setAudioMode(this, AudioManager.MODE_IN_CALL);
          break;
      }
    }

    // XXX pre-load the SimProvider so that it's ready
    resolver.getType(Uri.parse("content://icc/adn"));

    // start with the default value to set the mute state.
    mShouldRestoreMuteOnInCallResume = false;

    // add by cytown
    mSettings =
        CallFeaturesSetting.getInstance(PreferenceManager.getDefaultSharedPreferences(this));
    if (mVibrator == null) {
      mVibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
      mAM = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
      mVibrateIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_VIBRATE_45), 0);
    }

    // Register for Cdma Information Records
    // TODO(Moto): Merge
    // phone.registerCdmaInformationRecord(mHandler, EVENT_UNSOL_CDMA_INFO_RECORD, null);

    if (phone.getPhoneName().equals("CDMA")) {
      // Create an instance of CdmaPhoneCallState and initialize it to IDLE
      cdmaPhoneCallState = new CdmaPhoneCallState();
      cdmaPhoneCallState.CdmaPhoneCallStateInit();
    }
  }