@Override public void handleMessage(Message msg) { Status status = mStatus.get(); if (status == null) { return; } switch (msg.what) { case EVENT_SIGNAL_STRENGTH_CHANGED: status.updateSignalStrength(); break; case EVENT_SERVICE_STATE_CHANGED: ServiceState serviceState = status.mPhoneStateReceiver.getServiceState(); status.updateServiceState(serviceState); // SWISTART if (ServiceState.STATE_IN_SERVICE == serviceState.getState()) sendEmptyMessageDelayed(EVENT_UPDATE_PHONE_TYPE, 5000); // SWISTOP break; case EVENT_UPDATE_STATS: status.updateTimes(); sendEmptyMessageDelayed(EVENT_UPDATE_STATS, 1000); break; // SWISTART case EVENT_UPDATE_PHONE_TYPE: status.updatePhoneType(); break; // SWISTART } }
@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); 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); } } registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); mHandler.sendEmptyMessage(EVENT_UPDATE_STATS); }
@Override public void onServiceStateChanged(ServiceState serviceState) { mServiceState = serviceState.getState(); updateServiceState(serviceState); }