Beispiel #1
1
 @Override
 public void onReceive(Context context, Intent intent) {
   String action = intent.getAction();
   if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
     mBatteryLevel.setSummary(Utils.getBatteryPercentage(intent));
     mBatteryStatus.setSummary(Utils.getBatteryStatus(getResources(), intent));
   } else if (SPN_STRINGS_UPDATED_ACTION.equals(action)) {
     String operatorName = null;
     String plmn = null;
     String spn = null;
     if (intent.getBooleanExtra(EXTRA_SHOW_PLMN, false)) {
       plmn = intent.getStringExtra(EXTRA_PLMN);
       if (plmn != null) {
         operatorName = plmn;
       }
     }
     if (intent.getBooleanExtra(EXTRA_SHOW_SPN, false)) {
       spn = intent.getStringExtra(EXTRA_SPN);
       if (spn != null) {
         operatorName = spn;
       }
     }
     Preference p = findPreference(KEY_OPERATOR_NAME);
     if (p != null) {
       mExt.updateOpNameFromRec(p, operatorName);
     }
   }
 }
Beispiel #2
0
  private void updateServiceState(ServiceState serviceState) {
    int state = serviceState.getState();
    String display = mRes.getString(R.string.radioInfo_unknown);

    switch (state) {
      case ServiceState.STATE_IN_SERVICE:
        display = mRes.getString(R.string.radioInfo_service_in);
        break;
      case ServiceState.STATE_OUT_OF_SERVICE:
      case ServiceState.STATE_EMERGENCY_ONLY:
        display = mRes.getString(R.string.radioInfo_service_out);
        break;
      case ServiceState.STATE_POWER_OFF:
        display = mRes.getString(R.string.radioInfo_service_off);
        break;
    }

    setSummaryText(KEY_SERVICE_STATE, display);

    if (serviceState.getRoaming()) {
      setSummaryText(KEY_ROAMING_STATE, mRes.getString(R.string.radioInfo_roaming_in));
    } else {
      setSummaryText(KEY_ROAMING_STATE, mRes.getString(R.string.radioInfo_roaming_not));
    }
    Preference p = findPreference(KEY_OPERATOR_NAME);
    String op = serviceState.getOperatorAlphaLong();
    if (TextUtils.isEmpty(op)) {
      op = this.getResources().getString(R.string.device_info_default);
    }
    if (p != null) {
      mExt.updateServiceState(p, serviceState.getOperatorAlphaLong());
    }
  }
Beispiel #3
0
  @Override
  protected void onResume() {
    super.onResume();

    if (mPhone != null && !Utils.isWifiOnly(getApplicationContext())) {
      mPhoneStateReceiver.registerIntent();

      updateSignalStrength();
      updateServiceState(mPhone.getServiceState());
      updateDataState();
      mTelephonyManager.listen(
          mPhoneStateListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
      mTelephonyManager.listen(mSignalStrengthListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
      mTelephonyManager.listen(mPhoneServiceListener, PhoneStateListener.LISTEN_SERVICE_STATE);
      if (mShowLatestAreaInfo) {
        registerReceiver(
            mAreaInfoReceiver,
            new IntentFilter(CB_AREA_INFO_RECEIVED_ACTION),
            CB_AREA_INFO_SENDER_PERMISSION,
            null);
        // Ask CellBroadcastReceiver to broadcast the latest area info received
        Intent getLatestIntent = new Intent(GET_LATEST_CB_AREA_INFO_ACTION);
        sendBroadcastAsUser(getLatestIntent, UserHandle.ALL, CB_AREA_INFO_SENDER_PERMISSION);
      }
    }
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_BATTERY_CHANGED);
    mExt.addAction(filter, SPN_STRINGS_UPDATED_ACTION);
    registerReceiver(mBatteryInfoReceiver, filter);
    mHandler.sendEmptyMessage(EVENT_UPDATE_STATS);
  }