コード例 #1
0
 @Override
 public void onCreate() {
   mState = QUERY_READY;
   mPhone = PhoneFactory.getDefaultPhone();
   /// M: support gemini phone
   if (FeatureOption.MTK_GEMINI_SUPPORT) {
     mGeminiPhone = (GeminiPhone) PhoneFactory.getDefaultPhone();
   }
 }
コード例 #2
0
 @Override
 protected void onResume() {
   super.onResume();
   mSim1Setting.setEnabled(PhoneFactory.isCardReady(0));
   mSim2Setting.setEnabled(PhoneFactory.isCardReady(1));
   mIpDailingOn.setChecked(mIpDailingUtils.getIsIpDial());
   mIpDailingPreference.setEnabled(mIpDailingOn.isChecked());
   mGsmButtonCallVibrate.setChecked(
       (defaultSharedpref == null ? true : defaultSharedpref.getBoolean(KEY_CALL_VIBRATE, true)));
 }
コード例 #3
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    addPreferencesFromResource(R.xml.my_phone_number);
    mPhoneNumberStatus = findPreference(KEY_PHONE_NUMBER_STATUS_PREFERENCE);

    mTelephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);

    mPhone = PhoneFactory.getDefaultPhone();

    String rawNumber = mTelephonyManager.getLine1Number();
    String formattedNumber = null;

    if (!TextUtils.isEmpty(rawNumber)) {
      formattedNumber = PhoneNumberUtils.formatNumber(rawNumber);
    } else {
      formattedNumber = getResources().getString(R.string.unknown);
    }

    mPhoneNumberStatus.setSummary(formattedNumber);

    Log.d(LOG_TAG, " sim state: " + mTelephonyManager.getSimState());

    // Check SIM status
    if (mTelephonyManager.getSimState() != TelephonyManager.SIM_STATE_READY) {
      showNoSimAlertDialog();
    }
  }
コード例 #4
0
  public CdmaSubscriptionListPreference(Context context, AttributeSet attrs) {
    super(context, attrs);

    mPhone = PhoneFactory.getDefaultPhone();
    mHandler = new CdmaSubscriptionButtonHandler();
    setCurrentCdmaSubscriptionModeValue();
  }
コード例 #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Utils.isMonkeyRunning()) {
      finish();
      return;
    }

    addPreferencesFromResource(R.xml.sim_lock_settings);

    mPinDialog = (EditPinPreference) findPreference(PIN_DIALOG);
    mPinToggle = (CheckBoxPreference) findPreference(PIN_TOGGLE);
    if (savedInstanceState != null && savedInstanceState.containsKey(DIALOG_STATE)) {
      mDialogState = savedInstanceState.getInt(DIALOG_STATE);
      mPin = savedInstanceState.getString(DIALOG_PIN);
      mError = savedInstanceState.getString(DIALOG_ERROR);
      mToState = savedInstanceState.getBoolean(ENABLE_TO_STATE);
    }

    mPinDialog.setOnPinEnteredListener(this);

    // Don't need any changes to be remembered
    getPreferenceScreen().setPersistent(false);

    mPhone = PhoneFactory.getDefaultPhone();
    mRes = getResources();
  }
コード例 #6
0
ファイル: RadioPowerTest.java プロジェクト: hiuga/ServiceMenu
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   addPreferencesFromResource(R.xml.radio_preference);
   mRFPreference = (CheckBoxPreference) findPreference(KEY_TOGGLE_RF);
   mRFPreference.setOnPreferenceChangeListener(this);
   phone = PhoneFactory.getDefaultPhone();
 }
コード例 #7
0
 private int getPhoneTypeFromNetworkType() {
   // When the system property CURRENT_ACTIVE_PHONE, has not been set,
   // use the system property for default network type.
   // This is a fail safe, and can only happen at first boot.
   int mode = SystemProperties.getInt("ro.telephony.default_network", -1);
   if (mode == -1) return PHONE_TYPE_NONE;
   return PhoneFactory.getPhoneType(mode);
 }
コード例 #8
0
ファイル: PhoneProxy.java プロジェクト: BvbKoala/SourceCode
  private void deleteAndCreatePhone(int newVoiceRadioTech) {

    String outgoingPhoneName = "Unknown";
    Phone oldPhone = mActivePhone;

    if (oldPhone != null) {
      outgoingPhoneName = ((PhoneBase) oldPhone).getPhoneName();
    }

    logd(
        "Switching Voice Phone : "
            + outgoingPhoneName
            + " >>> "
            + (ServiceState.isGsm(newVoiceRadioTech) ? "GSM" : "CDMA"));

    if (oldPhone != null) {
      CallManager.getInstance().unregisterPhone(oldPhone);
      logd("Disposing old phone..");
      oldPhone.dispose();
    }

    // Give the garbage collector a hint to start the garbage collection
    // asap NOTE this has been disabled since radio technology change could
    // happen during e.g. a multimedia playing and could slow the system.
    // Tests needs to be done to see the effects of the GC call here when
    // system is busy.
    // System.gc();

    if (ServiceState.isCdma(newVoiceRadioTech)) {
      mActivePhone = PhoneFactory.getCdmaPhone();
    } else if (ServiceState.isGsm(newVoiceRadioTech)) {
      mActivePhone = PhoneFactory.getGsmPhone();
    }

    if (oldPhone != null) {
      oldPhone.removeReferences();
    }

    if (mActivePhone != null) {
      CallManager.getInstance().registerPhone(mActivePhone);
    }

    oldPhone = null;
  }
コード例 #9
0
  @Override
  protected void onResume() {
    super.onResume();
    if (!isSimReady()) {
      log("Add NP lock fail : SIM not ready!");
      return;
    }

    // To get the MCC+MNC+GID1+GID2 from SIM card
    TelephonyManager telephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    if (!FeatureOption.MTK_GEMINI_SUPPORT) {
      mSimMccMnc = telephonyManager.getSimOperator();

      Phone phone = PhoneFactory.getDefaultPhone();
      IccFileHandler iccFh = ((PhoneProxy) phone).getIccFileHandler();
      iccFh.loadEFTransparent(IccConstants.EF_GID1, mHandler.obtainMessage(EVENT_GET_SIM_GID1));
      iccFh.loadEFTransparent(IccConstants.EF_GID2, mHandler.obtainMessage(EVENT_GET_SIM_GID2));
    } else {
      TelephonyManagerEx telephonyManagerEx = TelephonyManagerEx.getDefault();
      mSimMccMnc = telephonyManagerEx.getSimOperator(simNumber);

      GeminiPhone mGeminiPhone = (GeminiPhone) PhoneFactory.getDefaultPhone();
      IccFileHandler iccFh =
          ((PhoneProxy) (mGeminiPhone.getPhonebyId(simNumber))).getIccFileHandler();
      iccFh.loadEFTransparent(IccConstants.EF_GID1, mHandler.obtainMessage(EVENT_GET_SIM_GID1));
      iccFh.loadEFTransparent(IccConstants.EF_GID2, mHandler.obtainMessage(EVENT_GET_SIM_GID2));

      // To get the GID2 from SIM card //TEMP
      mSimGid2 = telephonyManagerEx.getSimOperatorName(simNumber);
      if (mSimGid2 == null) {
        log("Fail to read SIM GID2!");
      } else {
        log("[Gemini]Succeed to read SIM GID2. SIM GID2 is " + mSimGid2);
      }
    }

    if (mSimMccMnc == null) {
      log("Fail to read SIM MCC+MNC!");
    } else {
      log("Read SIM MCC+MNC: " + mSimMccMnc);
    }
  }
コード例 #10
0
ファイル: Status.java プロジェクト: huhuikevin/android_3G
  // SWISTART
  private void updatePhoneType() {
    mPhone = PhoneFactory.getDefaultPhone();
    if (mPhone != null) {
      // NOTE "imei" is the "Device ID" since it represents
      //  the IMEI in GSM and the MEID in CDMA
      if (mPhone.getPhoneName().equals("CDMA")) {
        setSummaryText(KEY_MEID_NUMBER, mPhone.getMeid());
        setSummaryText(KEY_MIN_NUMBER, mPhone.getCdmaMin());
        if (getResources().getBoolean(R.bool.config_msid_enable)) {
          findPreference(KEY_MIN_NUMBER).setTitle(R.string.status_msid_number);
        }
        setSummaryText(KEY_PRL_VERSION, mPhone.getCdmaPrlVersion());
        removePreferenceFromScreen(KEY_IMEI_SV);

        if (mPhone.getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE) {
          // Show ICC ID and IMEI for LTE device
          setSummaryText(KEY_ICC_ID, mPhone.getIccSerialNumber());
          setSummaryText(KEY_IMEI, mPhone.getImei());
        } else {
          // device is not GSM/UMTS, do not display GSM/UMTS features
          // check Null in case no specified preference in overlay xml
          removePreferenceFromScreen(KEY_IMEI);
          removePreferenceFromScreen(KEY_ICC_ID);
        }
      } else {
        setSummaryText(KEY_IMEI, mPhone.getDeviceId());

        setSummaryText(
            KEY_IMEI_SV,
            ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)).getDeviceSoftwareVersion());

        // device is not CDMA, do not display CDMA features
        // check Null in case no specified preference in overlay xml
        removePreferenceFromScreen(KEY_PRL_VERSION);
        removePreferenceFromScreen(KEY_MEID_NUMBER);
        removePreferenceFromScreen(KEY_MIN_NUMBER);
        removePreferenceFromScreen(KEY_ICC_ID);

        // only show area info when SIM country is Brazil
        if ("br".equals(mTelephonyManager.getSimCountryIso())) {
          mShowLatestAreaInfo = true;
        }
      }
      String rawNumber = mPhone.getLine1Number(); // may be null or empty
      String formattedNumber = null;
      if (!TextUtils.isEmpty(rawNumber)) {
        formattedNumber = PhoneNumberUtils.formatNumber(rawNumber);
      }
      // If formattedNumber is null or empty, it'll display as "Unknown".
      setSummaryText(KEY_PHONE_NUMBER, formattedNumber);
    }
  }
コード例 #11
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.antena_test);

    mSpinner = (Spinner) findViewById(R.id.spinner_antenna);
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(
            this,
            android.R.layout.simple_spinner_item,
            getResources().getStringArray(R.array.antenna_modes));
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mSpinner.setAdapter(adapter);
    mSpinner.setOnItemSelectedListener(mItemSelectedListener);
    mSpinner.setEnabled(false);

    if (FeatureOption.MTK_GEMINI_SUPPORT) {
      mGeminiPhone = (GeminiPhone) PhoneFactory.getDefaultPhone();
    } else {
      mPhone = (Phone) PhoneFactory.getDefaultPhone();
    }
  }
コード例 #12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.networkmode_switching);
    mSimType = getIntent().getIntExtra("mSimType", PhoneConstants.GEMINI_SIM_1);

    if (FeatureOption.MTK_GEMINI_SUPPORT) {
      mGeminiPhone = (GeminiPhone) PhoneFactory.getDefaultPhone();
    } else {
      mPhone = PhoneFactory.getDefaultPhone();
    }
    mPreferredNetworkSpinner = (Spinner) findViewById(R.id.networkModeSwitching);
    mModemType = getModemType();
    if (mModemType == MODEM_TD) {
      // No "CDMA preferred" for TD
      mNetworkTypeValues = new int[] {GSM_ONLY, WCDMA_ONLY, GSM_WCDMA_AUTO};
      ArrayAdapter<String> adapter =
          new ArrayAdapter<String>(
              this,
              android.R.layout.simple_spinner_item,
              getResources().getStringArray(R.array.mTddNetworkLabels));
      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      mPreferredNetworkSpinner.setAdapter(adapter);
    } else if (mModemType == MODEM_FDD) {
      mNetworkTypeValues = new int[] {WCDMA_PREFERRED, GSM_ONLY, WCDMA_ONLY, GSM_WCDMA_AUTO};
      ArrayAdapter<String> adapter =
          new ArrayAdapter<String>(
              this,
              android.R.layout.simple_spinner_item,
              getResources().getStringArray(R.array.mWcdmaNetworkLabels));
      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      mPreferredNetworkSpinner.setAdapter(adapter);
    } else {
      //            mPreferredNetworkSpinner.setEnabled(false);
      Xlog.w(TAG, "Isn't TD/WCDMA modem: " + mModemType);
    }

    mPreferredNetworkSpinner.setOnItemSelectedListener(mPreferredNetworkHandler);
  }
コード例 #13
0
    /**
     * Callback invoked when there is any change to any SubscriptionInfo. Typically this method
     * would invoke {@link SubscriptionManager#getActiveSubscriptionInfoList}
     */
    @Override
    public void onSubscriptionsChanged() {
      if (DBG) log("SubscriptionListener.onSubscriptionInfoChanged");
      // Set the network type, in case the radio does not restore it.
      int subId = mPhoneBase.getSubId();
      if (mPreviousSubId.getAndSet(subId) != subId) {
        if (SubscriptionManager.isValidSubscriptionId(subId)) {
          Context context = mPhoneBase.getContext();
          int networkType = PhoneFactory.calculatePreferredNetworkType(context, subId);
          mCi.setPreferredNetworkType(networkType, null);

          mPhoneBase.notifyCallForwardingIndicator();

          boolean skipRestoringSelection =
              context
                  .getResources()
                  .getBoolean(com.android.internal.R.bool.skip_restoring_network_selection);
          if (!skipRestoringSelection) {
            // restore the previous network selection.
            mPhoneBase.restoreSavedNetworkSelection(null);
          }

          mPhoneBase.setSystemProperty(
              TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
              ServiceState.rilRadioTechnologyToString(mSS.getRilDataRadioTechnology()));

          if (mSpnUpdatePending) {
            mSubscriptionController.setPlmnSpn(
                mPhoneBase.getPhoneId(), mCurShowPlmn, mCurPlmn, mCurShowSpn, mCurSpn);
            mSpnUpdatePending = false;
          }

          // Remove old network selection sharedPreferences since SP key names are now
          // changed to include subId. This will be done only once when upgrading from an
          // older build that did not include subId in the names.
          SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
          String oldNetworkSelectionName = sp.getString(PhoneBase.NETWORK_SELECTION_NAME_KEY, "");
          String oldNetworkSelection = sp.getString(PhoneBase.NETWORK_SELECTION_KEY, "");
          if (!TextUtils.isEmpty(oldNetworkSelectionName)
              || !TextUtils.isEmpty(oldNetworkSelection)) {
            SharedPreferences.Editor editor = sp.edit();
            editor.putString(PhoneBase.NETWORK_SELECTION_NAME_KEY + subId, oldNetworkSelectionName);
            editor.putString(PhoneBase.NETWORK_SELECTION_KEY + subId, oldNetworkSelection);
            editor.remove(PhoneBase.NETWORK_SELECTION_NAME_KEY);
            editor.remove(PhoneBase.NETWORK_SELECTION_KEY);
            editor.commit();
          }
        }
      }
    }
コード例 #14
0
    private void handleSetCdmaSubscriptionMode(Message msg) {
      mPhone = PhoneFactory.getDefaultPhone();
      AsyncResult ar = (AsyncResult) msg.obj;

      if (ar.exception == null) {
        // Get the original string entered by the user
        int cdmaSubscriptionMode = Integer.valueOf((String) ar.userObj).intValue();
        Settings.Global.putInt(
            mPhone.getContext().getContentResolver(),
            Settings.Global.CDMA_SUBSCRIPTION_MODE,
            cdmaSubscriptionMode);
      } else {
        Log.e(LOG_TAG, "Setting Cdma subscription source failed");
      }
    }
コード例 #15
0
  @Override
  protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    mSubId = getIntent().getIntExtra(CallSettingOptions.SUB_ID, 0);
    addPreferencesFromResource(R.xml.videophone_callforward_options);
    if (PhoneFactory.getPhoneCount() > 1) {
      if (mSubId == 0) {
        setTitle(
            getResources().getString(R.string.sim1)
                + getResources().getString(R.string.videophone_callforward_setting_title));
      } else if (mSubId == 1) {
        setTitle(
            getResources().getString(R.string.sim2)
                + getResources().getString(R.string.videophone_callforward_setting_title));
      }
    }
    PreferenceScreen prefSet = getPreferenceScreen();
    mButtonCFU = (CallForwardEditPreference) prefSet.findPreference(BUTTON_CFU_KEY);
    mButtonCFB = (CallForwardEditPreference) prefSet.findPreference(BUTTON_CFB_KEY);
    mButtonCFNRy = (CallForwardEditPreference) prefSet.findPreference(BUTTON_CFNRY_KEY);
    mButtonCFNRc = (CallForwardEditPreference) prefSet.findPreference(BUTTON_CFNRC_KEY);

    mButtonCFU.setParentActivity(this, mButtonCFU.reason);
    mButtonCFB.setParentActivity(this, mButtonCFB.reason);
    mButtonCFNRy.setParentActivity(this, mButtonCFNRy.reason);
    mButtonCFNRc.setParentActivity(this, mButtonCFNRc.reason);

    mPreferences.add(mButtonCFU);
    mPreferences.add(mButtonCFB);
    mPreferences.add(mButtonCFNRy);
    mPreferences.add(mButtonCFNRc);

    // we wait to do the initialization until onResume so that the
    // TimeConsumingPreferenceActivity dialog can display as it
    // relies on onResume / onPause to maintain its foreground state.

    mFirstResume = true;
    mIcicle = icicle;
  }
コード例 #16
0
  @Override
  protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mScreen = getPreferenceManager().createPreferenceScreen(this);
    setPreferenceScreen(mScreen);

    mDefaultTelephonyManager = MmsApp.getApplication().getTelephonyManager();
    mTelephonyManagers = new ArrayList<TelephonyManager>(2);
    mTelephonies = new ArrayList<ITelephony>(2);

    int phoneCount = mDefaultTelephonyManager.getPhoneCount();
    for (int i = 0; i < phoneCount; ++i) {
      TelephonyManager tm = MmsApp.getApplication().getTelephonyManager(i);
      mTelephonyManagers.add(tm);
      if (tm.hasIccCard() && tm.getSimState() == TelephonyManager.SIM_STATE_READY) {
        ITelephony telephony =
            ITelephony.Stub.asInterface(
                ServiceManager.getService(
                    PhoneFactory.getServiceName(Context.TELEPHONY_SERVICE, i)));
        mTelephonies.add(telephony);
      } else {
        mTelephonies.add(null); // just act as a place holder in the list
      }
    }

    Intent intent = getIntent();
    mMode = intent.getIntExtra(Mode.KEY, Mode.NIL);
    switch (mMode) {
      case Mode.MANAGE_MSG:
        handleManageSimMsg();
        break;
      case Mode.SMSC:
        handleSMSC();
        break;
      default:
        finish();
    }
  }
コード例 #17
0
 private void initPhoneInstance() {
   if (UserHandle.myUserId() == UserHandle.USER_OWNER && mUtility.isValidSubId()) {
     mPhone = PhoneFactory.getPhone(mUtility.getSlotId());
     initPhoneStateListener();
   }
 }
コード例 #18
0
ファイル: Status.java プロジェクト: huhuikevin/android_3G
  @Override
  protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    mHandler = new MyHandler(this);

    mTelephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);

    addPreferencesFromResource(R.xml.device_info_status);
    mBatteryLevel = findPreference(KEY_BATTERY_LEVEL);
    mBatteryStatus = findPreference(KEY_BATTERY_STATUS);

    mRes = getResources();
    sUnknown = mRes.getString(R.string.device_info_default);
    if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
      mPhone = PhoneFactory.getDefaultPhone();
    }
    // Note - missing in zaku build, be careful later...
    mSignalStrength = findPreference(KEY_SIGNAL_STRENGTH);
    mUptime = findPreference("up_time");

    if (mPhone == null || Utils.isWifiOnly(getApplicationContext())) {
      for (String key : PHONE_RELATED_ENTRIES) {
        removePreferenceFromScreen(key);
      }
    } else {
      // NOTE "imei" is the "Device ID" since it represents
      //  the IMEI in GSM and the MEID in CDMA
      if (mPhone.getPhoneName().equals("CDMA")) {
        setSummaryText(KEY_MEID_NUMBER, mPhone.getMeid());
        setSummaryText(KEY_MIN_NUMBER, mPhone.getCdmaMin());
        if (getResources().getBoolean(R.bool.config_msid_enable)) {
          findPreference(KEY_MIN_NUMBER).setTitle(R.string.status_msid_number);
        }
        setSummaryText(KEY_PRL_VERSION, mPhone.getCdmaPrlVersion());
        removePreferenceFromScreen(KEY_IMEI_SV);

        if (mPhone.getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE) {
          // Show ICC ID and IMEI for LTE device
          setSummaryText(KEY_ICC_ID, mPhone.getIccSerialNumber());
          setSummaryText(KEY_IMEI, mPhone.getImei());
        } else {
          // device is not GSM/UMTS, do not display GSM/UMTS features
          // check Null in case no specified preference in overlay xml
          removePreferenceFromScreen(KEY_IMEI);
          removePreferenceFromScreen(KEY_ICC_ID);
        }
      } else {
        setSummaryText(KEY_IMEI, mPhone.getDeviceId());

        setSummaryText(
            KEY_IMEI_SV,
            ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)).getDeviceSoftwareVersion());

        // device is not CDMA, do not display CDMA features
        // check Null in case no specified preference in overlay xml
        removePreferenceFromScreen(KEY_PRL_VERSION);
        removePreferenceFromScreen(KEY_MEID_NUMBER);
        removePreferenceFromScreen(KEY_MIN_NUMBER);
        removePreferenceFromScreen(KEY_ICC_ID);

        // only show area info when SIM country is Brazil
        if ("br".equals(mTelephonyManager.getSimCountryIso())) {
          mShowLatestAreaInfo = true;
        }
      }

      String rawNumber = mPhone.getLine1Number(); // may be null or empty
      String formattedNumber = null;
      if (!TextUtils.isEmpty(rawNumber)) {
        formattedNumber = PhoneNumberUtils.formatNumber(rawNumber);
      }
      // If formattedNumber is null or empty, it'll display as "Unknown".
      setSummaryText(KEY_PHONE_NUMBER, formattedNumber);

      mPhoneStateReceiver = new PhoneStateIntentReceiver(this, mHandler);
      mPhoneStateReceiver.notifySignalStrength(EVENT_SIGNAL_STRENGTH_CHANGED);
      mPhoneStateReceiver.notifyServiceState(EVENT_SERVICE_STATE_CHANGED);

      if (!mShowLatestAreaInfo) {
        removePreferenceFromScreen(KEY_LATEST_AREA_INFO);
      }
    }

    setWimaxStatus();
    setWifiStatus();
    setBtStatus();
    setIpAddressStatus();

    String serial = Build.SERIAL;
    if (serial != null && !serial.equals("")) {
      setSummaryText(KEY_SERIAL_NUMBER, serial);
    } else {
      removePreferenceFromScreen(KEY_SERIAL_NUMBER);
    }
  }
コード例 #19
0
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    addPreferencesFromResource(R.xml.cell_broadcast_sms);

    mPhone = PhoneFactory.getDefaultPhone();
    mHandler = new MyHandler();

    PreferenceScreen prefSet = getPreferenceScreen();

    mButtonBcSms = (CheckBoxPreference) prefSet.findPreference(BUTTON_ENABLE_DISABLE_BC_SMS_KEY);
    mListLanguage = (ListPreference) prefSet.findPreference(LIST_LANGUAGE_KEY);
    // set the listener for the language list preference
    mListLanguage.setOnPreferenceChangeListener(this);
    mButtonEmergencyBroadcast =
        (CheckBoxPreference) prefSet.findPreference(BUTTON_EMERGENCY_BROADCAST_KEY);
    mButtonAdministrative = (CheckBoxPreference) prefSet.findPreference(BUTTON_ADMINISTRATIVE_KEY);
    mButtonMaintenance = (CheckBoxPreference) prefSet.findPreference(BUTTON_MAINTENANCE_KEY);
    mButtonLocalWeather = (CheckBoxPreference) prefSet.findPreference(BUTTON_LOCAL_WEATHER_KEY);
    mButtonAtr = (CheckBoxPreference) prefSet.findPreference(BUTTON_ATR_KEY);
    mButtonLafs = (CheckBoxPreference) prefSet.findPreference(BUTTON_LAFS_KEY);
    mButtonRestaurants = (CheckBoxPreference) prefSet.findPreference(BUTTON_RESTAURANTS_KEY);
    mButtonLodgings = (CheckBoxPreference) prefSet.findPreference(BUTTON_LODGINGS_KEY);
    mButtonRetailDirectory =
        (CheckBoxPreference) prefSet.findPreference(BUTTON_RETAIL_DIRECTORY_KEY);
    mButtonAdvertisements = (CheckBoxPreference) prefSet.findPreference(BUTTON_ADVERTISEMENTS_KEY);
    mButtonStockQuotes = (CheckBoxPreference) prefSet.findPreference(BUTTON_STOCK_QUOTES_KEY);
    mButtonEo = (CheckBoxPreference) prefSet.findPreference(BUTTON_EO_KEY);
    mButtonMhh = (CheckBoxPreference) prefSet.findPreference(BUTTON_MHH_KEY);
    mButtonTechnologyNews = (CheckBoxPreference) prefSet.findPreference(BUTTON_TECHNOLOGY_NEWS_KEY);
    mButtonMultiCategory = (CheckBoxPreference) prefSet.findPreference(BUTTON_MULTI_CATEGORY_KEY);

    mButtonLocal1 = (CheckBoxPreference) prefSet.findPreference(BUTTON_LOCAL_GENERAL_NEWS_KEY);
    mButtonRegional1 =
        (CheckBoxPreference) prefSet.findPreference(BUTTON_REGIONAL_GENERAL_NEWS_KEY);
    mButtonNational1 =
        (CheckBoxPreference) prefSet.findPreference(BUTTON_NATIONAL_GENERAL_NEWS_KEY);
    mButtonInternational1 =
        (CheckBoxPreference) prefSet.findPreference(BUTTON_INTERNATIONAL_GENERAL_NEWS_KEY);

    mButtonLocal2 = (CheckBoxPreference) prefSet.findPreference(BUTTON_LOCAL_BF_NEWS_KEY);
    mButtonRegional2 = (CheckBoxPreference) prefSet.findPreference(BUTTON_REGIONAL_BF_NEWS_KEY);
    mButtonNational2 = (CheckBoxPreference) prefSet.findPreference(BUTTON_NATIONAL_BF_NEWS_KEY);
    mButtonInternational2 =
        (CheckBoxPreference) prefSet.findPreference(BUTTON_INTERNATIONAL_BF_NEWS_KEY);

    mButtonLocal3 = (CheckBoxPreference) prefSet.findPreference(BUTTON_LOCAL_SPORTS_NEWS_KEY);
    mButtonRegional3 = (CheckBoxPreference) prefSet.findPreference(BUTTON_REGIONAL_SPORTS_NEWS_KEY);
    mButtonNational3 = (CheckBoxPreference) prefSet.findPreference(BUTTON_NATIONAL_SPORTS_NEWS_KEY);
    mButtonInternational3 =
        (CheckBoxPreference) prefSet.findPreference(BUTTON_INTERNATIONAL_SPORTS_NEWS_KEY);

    mButtonLocal4 =
        (CheckBoxPreference) prefSet.findPreference(BUTTON_LOCAL_ENTERTAINMENT_NEWS_KEY);
    mButtonRegional4 =
        (CheckBoxPreference) prefSet.findPreference(BUTTON_REGIONAL_ENTERTAINMENT_NEWS_KEY);
    mButtonNational4 =
        (CheckBoxPreference) prefSet.findPreference(BUTTON_NATIONAL_ENTERTAINMENT_NEWS_KEY);
    mButtonInternational4 =
        (CheckBoxPreference) prefSet.findPreference(BUTTON_INTERNATIONAL_ENTERTAINMENT_NEWS_KEY);
  }
コード例 #20
0
 private Phone getPhone() {
   if (mPhone == null) mPhone = PhoneFactory.getDefaultPhone();
   return mPhone;
 }
コード例 #21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.modem_test_activity_6589);

    View.OnClickListener listener =
        new View.OnClickListener() {

          public void onClick(View v) {
            switch (v.getId()) {
              case R.id.modem_test_none_btn:
                sendATCommad("0", MODEM_NONE);
                if (mCurrentMode == MODEM_FTA) {
                  setGprsTransferType(PCH_CALL_PREFER);
                }
                break;
              case R.id.modem_test_cta_btn:
                if (mModemFlag) {
                  writePreferred(NETWORK_TYPE);
                  mPhone.setPreferredNetworkType(
                      NETWORK_TYPE, mATCmdHander.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE));
                }
                sendATCommad("1,0", MODEM_CTA);
                if (mCurrentMode == MODEM_FTA) {
                  setGprsTransferType(PCH_CALL_PREFER);
                }
                break;
              case R.id.modem_test_fta_btn:
                if (mModemFlag) {
                  writePreferred(NETWORK_TYPE);
                  mPhone.setPreferredNetworkType(
                      NETWORK_TYPE, mATCmdHander.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE));
                }
                showDialog(MODEM_FTA);
                break;
              case R.id.modem_test_iot_btn:
                showDialog(MODEM_IOT);
                break;
              case R.id.modem_test_operator_btn:
                if (mModemFlag) {
                  writePreferred(NETWORK_TYPE);
                  mPhone.setPreferredNetworkType(
                      NETWORK_TYPE, mATCmdHander.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE));
                }
                showDialog(MODEM_OPERATOR);
                break;
              case R.id.modem_test_factory_btn:
                if (mModemFlag) {
                  writePreferred(NETWORK_TYPE);
                  mPhone.setPreferredNetworkType(
                      NETWORK_TYPE, mATCmdHander.obtainMessage(EVENT_SET_PREFERRED_TYPE_DONE));
                }
                sendATCommad("5", MODEM_FACTORY);
                if (mCurrentMode == MODEM_FTA) {
                  setGprsTransferType(PCH_CALL_PREFER);
                }
                break;
              default:
                break;
            }
          }
        };
    mTextView = (TextView) findViewById(R.id.modem_test_textview);
    mNoneBtn = (Button) findViewById(R.id.modem_test_none_btn);
    mFactoryBtn = (Button) findViewById(R.id.modem_test_factory_btn);
    mFactoryBtn.setOnClickListener(listener);
    mCtaBtn = (Button) findViewById(R.id.modem_test_cta_btn);
    mCtaBtn.setOnClickListener(listener);

    mFtaBtn = (Button) findViewById(R.id.modem_test_fta_btn);
    mIotBtn = (Button) findViewById(R.id.modem_test_iot_btn);
    mOperatorBtn = (Button) findViewById(R.id.modem_test_operator_btn);
    mNoneBtn.setOnClickListener(listener);
    mFtaBtn.setOnClickListener(listener);
    mIotBtn.setOnClickListener(listener);
    mOperatorBtn.setOnClickListener(listener);
    mTextView.setText("The current mode is unknown");
    mCtaOptionsArray = getResources().getStringArray(R.array.modem_test_cta_options);
    mFtaOptionsArray = getResources().getStringArray(R.array.modem_test_fta_options);
    mIotOptionsArray = getResources().getStringArray(R.array.modem_test_iot_options_6589);
    mOperatorOptionsArray = getResources().getStringArray(R.array.modem_test_operator_options_6589);
    // send AT Cmd and register the event
    mPhone = PhoneFactory.getDefaultPhone();
    if (FeatureOption.MTK_GEMINI_SUPPORT) {
      mGeminiPhone = (GeminiPhone) PhoneFactory.getDefaultPhone();
    }
    // mPhone.registerForNetworkInfo(mResponseHander, EVENT_NW_INFO, null);

    String cmd[] = new String[2];
    cmd[0] = "AT+EPCT?";
    cmd[1] = "+EPCT:";
    mPhone.invokeOemRilRequestStrings(cmd, mATCmdHander.obtainMessage(MODEM_QUERY));
  }
コード例 #22
0
  @Override
  protected void onCreate(Bundle icicle) {
    Log.i(TAG, "onCreate()...  intent = " + getIntent());
    super.onCreate(icicle);

    // Watch out: the intent action we get here should always be
    // ACTION_CALL_EMERGENCY, since the whole point of this activity
    // is for it to be launched using the same intent originally
    // passed to the InCallScreen, which will always be
    // ACTION_CALL_EMERGENCY when making an emergency call.
    //
    // If we ever get launched with any other action, especially if it's
    // "com.android.phone.InCallScreen.UNDEFINED" (as in bug 3094858), that
    // almost certainly indicates a logic bug in the InCallScreen.
    if (!Intent.ACTION_CALL_EMERGENCY.equals(getIntent().getAction())) {
      Log.w(
          TAG,
          "Unexpected intent action!  Should be ACTION_CALL_EMERGENCY, "
              + "but instead got: "
              + getIntent().getAction());
    }

    // setup the phone and get the retry count embedded in the intent.
    Phone phone = PhoneFactory.getDefaultPhone();
    int retryCount = getIntent().getIntExtra(EMERGENCY_CALL_RETRY_KEY, INITIAL_ATTEMPT);

    // create a new message object.
    EmergencyCallInfo eci = new EmergencyCallInfo();
    eci.phone = phone;
    eci.app = getApplication();
    eci.dialog = constructDialog(retryCount);

    // The Intent we're going to fire off to retry the call is the
    // same one that got us here (except that we *don't* explicitly
    // specify this class as the component!)
    eci.intent = getIntent().setComponent(null);
    // And we'll be firing this Intent from the PhoneApp's context
    // (see the startActivity() calls above) so the
    // FLAG_ACTIVITY_NEW_TASK flag is required.
    eci.intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (DBG) Log.d(TAG, "- initial eci.intent: " + eci.intent);

    // create the handler.
    if (sHandler == null) {
      sHandler = new EmergencyCallEventHandler();
    }

    // If this is the initial attempt, we need to register for a radio state
    // change and turn the radio on.  Otherwise, this is just a retry, and
    // we simply wait the alloted time before sending the request to try
    // the call again.

    // Note: The radio logic ITSELF will try its best to put the emergency
    // call through once the radio is turned on.  The retry we have here
    // is in case it fails; the current constants we have include making
    // 6 attempts, with a 5 second delay between each.
    if (retryCount == INITIAL_ATTEMPT) {
      // place the number of pending retries in the intent.
      eci.intent.putExtra(EMERGENCY_CALL_RETRY_KEY, NUMBER_OF_RETRIES);
      int sub = PhoneApp.getInstance().getVoiceSubscriptionInService();
      eci.intent.putExtra(SUBSCRIPTION, sub);
      Log.d(TAG, "Attempting emergency call on sub :" + sub);

      // turn the radio on and listen for it to complete.
      phone.registerForServiceStateChanged(sHandler, EVENT_SERVICE_STATE_CHANGED, eci);

      // If airplane mode is on, we turn it off the same way that the
      // Settings activity turns it off.
      if (Settings.System.getInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) > 0) {
        if (DBG) Log.d(TAG, "Turning off airplane mode...");

        // Change the system setting
        Settings.System.putInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0);

        // Post the intent
        Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
        intent.putExtra("state", false);
        sendBroadcast(intent);

        // Otherwise, for some strange reason the radio is just off, so
        // we just turn it back on.
      } else {
        if (DBG) Log.d(TAG, "Manually powering radio on...");
        phone.setRadioPower(true);
      }

    } else {
      // decrement and store the number of retries.
      if (DBG) Log.d(TAG, "Retry attempt...  retryCount = " + retryCount);
      eci.intent.putExtra(EMERGENCY_CALL_RETRY_KEY, (retryCount - 1));

      // get the message and attach the data, then wait the alloted
      // time and send.
      Message m = sHandler.obtainMessage(EVENT_TIMEOUT_EMERGENCY_CALL);
      m.obj = eci;
      sHandler.sendMessageDelayed(m, TIME_BETWEEN_RETRIES_MS);
    }
    finish();
  }
コード例 #23
0
  public static void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    pw.println("PhoneFactory:");
    PhoneProxy[] phones = (PhoneProxy[]) PhoneFactory.getPhones();
    int i = -1;
    for (PhoneProxy phoneProxy : phones) {
      PhoneBase phoneBase;
      i += 1;

      try {
        phoneBase = (PhoneBase) phoneProxy.getActivePhone();
        phoneBase.dump(fd, pw, args);
      } catch (Exception e) {
        pw.println("Telephony DebugService: Could not get Phone[" + i + "] e=" + e);
        continue;
      }

      pw.flush();
      pw.println("++++++++++++++++++++++++++++++++");

      try {
        ((IccCardProxy) phoneProxy.getIccCard()).dump(fd, pw, args);
      } catch (Exception e) {
        e.printStackTrace();
      }
      pw.flush();
      pw.println("++++++++++++++++++++++++++++++++");
    }

    try {
      DctController.getInstance().dump(fd, pw, args);
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      mUiccController.dump(fd, pw, args);
    } catch (Exception e) {
      e.printStackTrace();
    }
    pw.flush();
    pw.println("++++++++++++++++++++++++++++++++");

    try {
      SubscriptionController.getInstance().dump(fd, pw, args);
    } catch (Exception e) {
      e.printStackTrace();
    }
    pw.flush();
    pw.println("++++++++++++++++++++++++++++++++");

    try {
      sSubInfoRecordUpdater.dump(fd, pw, args);
    } catch (Exception e) {
      e.printStackTrace();
    }
    pw.flush();

    pw.println("++++++++++++++++++++++++++++++++");
    synchronized (sLocalLogs) {
      final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "  ");
      for (String key : sLocalLogs.keySet()) {
        ipw.println(key);
        ipw.increaseIndent();
        sLocalLogs.get(key).dump(fd, ipw, args);
        ipw.decreaseIndent();
      }
      ipw.flush();
    }
  }
コード例 #24
0
 // For top-level settings screen to query
 static boolean isIccLockEnabled() {
   return PhoneFactory.getDefaultPhone().getIccCard().getIccLockEnabled();
 }
  public MSISDNEditPreference(Context context, AttributeSet attrs) {
    super(context, attrs);

    mPhone = PhoneFactory.getDefaultPhone();
    mContext = context;
  }
コード例 #26
0
ファイル: PhoneApp.java プロジェクト: Wysie/Phone_donut
  @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();
    }
  }