private final void sendIntent() { // Pack up the values and broadcast them to everyone Intent intent = new Intent(Intent.ACTION_BATTERY_CHANGED); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_REPLACE_PENDING); int icon = getIcon(mBatteryLevel); intent.putExtra(BatteryManager.EXTRA_STATUS, mBatteryStatus); intent.putExtra(BatteryManager.EXTRA_HEALTH, mBatteryHealth); intent.putExtra(BatteryManager.EXTRA_PRESENT, mBatteryPresent); intent.putExtra(BatteryManager.EXTRA_LEVEL, mBatteryLevel); intent.putExtra(BatteryManager.EXTRA_SCALE, BATTERY_SCALE); intent.putExtra(BatteryManager.EXTRA_ICON_SMALL, icon); intent.putExtra(BatteryManager.EXTRA_PLUGGED, mPlugType); intent.putExtra(BatteryManager.EXTRA_VOLTAGE, mBatteryVoltage); intent.putExtra(BatteryManager.EXTRA_TEMPERATURE, mBatteryTemperature); intent.putExtra(BatteryManager.EXTRA_TECHNOLOGY, mBatteryTechnology); intent.putExtra(BatteryManager.EXTRA_INVALID_CHARGER, mInvalidCharger); if (false) { Slog.d( TAG, "level:" + mBatteryLevel + " scale:" + BATTERY_SCALE + " status:" + mBatteryStatus + " health:" + mBatteryHealth + " present:" + mBatteryPresent + " voltage: " + mBatteryVoltage + " temperature: " + mBatteryTemperature + " technology: " + mBatteryTechnology + " AC powered:" + mAcOnline + " USB powered:" + mUsbOnline + " icon:" + icon + " invalid charger:" + mInvalidCharger); } ActivityManagerNative.broadcastStickyIntent(intent, null); }
private void broadcastSimStateChanged(int slotId, String state, String reason) { Intent i = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED); // TODO - we'd like this intent to have a single snapshot of all sim state, // but until then this should not use REPLACE_PENDING or we may lose // information // i.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING // | Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); i.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); i.putExtra(PhoneConstants.PHONE_NAME_KEY, "Phone"); i.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE, state); i.putExtra(IccCardConstants.INTENT_KEY_LOCKED_REASON, reason); SubscriptionManager.putPhoneIdAndSubIdExtra(i, slotId); logd( "Broadcasting intent ACTION_SIM_STATE_CHANGED " + IccCardConstants.INTENT_VALUE_ICC_LOADED + " reason " + null + " for mCardIndex : " + slotId); ActivityManagerNative.broadcastStickyIntent(i, READ_PHONE_STATE, UserHandle.USER_ALL); }
private void updatePhoneObject(int newVoiceRadioTech) { if (mActivePhone != null) { if (mRilVersion == 6 && getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE) { /* * On v6 RIL, when LTE_ON_CDMA is TRUE, always create CDMALTEPhone * irrespective of the voice radio tech reported. */ if (mActivePhone.getPhoneType() == PHONE_TYPE_CDMA) { logd( "LTE ON CDMA property is set. Use CDMA Phone" + " newVoiceRadioTech = " + newVoiceRadioTech + " Active Phone = " + mActivePhone.getPhoneName()); return; } else { logd( "LTE ON CDMA property is set. Switch to CDMALTEPhone" + " newVoiceRadioTech = " + newVoiceRadioTech + " Active Phone = " + mActivePhone.getPhoneName()); newVoiceRadioTech = ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT; } } else { if ((ServiceState.isCdma(newVoiceRadioTech) && mActivePhone.getPhoneType() == PHONE_TYPE_CDMA) || (ServiceState.isGsm(newVoiceRadioTech) && mActivePhone.getPhoneType() == PHONE_TYPE_GSM)) { // Nothing changed. Keep phone as it is. logd( "Ignoring voice radio technology changed message." + " newVoiceRadioTech = " + newVoiceRadioTech + " Active Phone = " + mActivePhone.getPhoneName()); return; } } } if (newVoiceRadioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) { // We need some voice phone object to be active always, so never // delete the phone without anything to replace it with! logd( "Ignoring voice radio technology changed message. newVoiceRadioTech = Unknown." + " Active Phone = " + mActivePhone.getPhoneName()); return; } boolean oldPowerState = false; // old power state to off if (mResetModemOnRadioTechnologyChange) { if (mCommandsInterface.getRadioState().isOn()) { oldPowerState = true; logd("Setting Radio Power to Off"); mCommandsInterface.setRadioPower(false, null); } } deleteAndCreatePhone(newVoiceRadioTech); if (mResetModemOnRadioTechnologyChange && oldPowerState) { // restore power state logd("Resetting Radio"); mCommandsInterface.setRadioPower(oldPowerState, null); } // Set the new interfaces in the proxy's mIccSmsInterfaceManagerProxy.setmIccSmsInterfaceManager( mActivePhone.getIccSmsInterfaceManager()); mIccPhoneBookInterfaceManagerProxy.setmIccPhoneBookInterfaceManager( mActivePhone.getIccPhoneBookInterfaceManager()); mPhoneSubInfoProxy.setmPhoneSubInfo(this.mActivePhone.getPhoneSubInfo()); mCommandsInterface = ((PhoneBase) mActivePhone).mCM; // Send an Intent to the PhoneApp that we had a radio technology change Intent intent = new Intent(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED); intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); intent.putExtra(Phone.PHONE_NAME_KEY, mActivePhone.getPhoneName()); ActivityManagerNative.broadcastStickyIntent(intent, null); }
private final void sendIntent( int headset, int headsetState, int prevHeadsetState, String headsetName) { if ((headsetState & headset) != (prevHeadsetState & headset)) { int state = 0; if ((headsetState & headset) != 0) { state = 1; } if ((headset == BIT_USB_HEADSET_ANLG) || (headset == BIT_USB_HEADSET_DGTL) || (headset == BIT_HDMI_AUDIO)) { Intent intent; // Pack up the values and broadcast them to everyone if (headset == BIT_USB_HEADSET_ANLG) { intent = new Intent(Intent.ACTION_USB_ANLG_HEADSET_PLUG); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); intent.putExtra("state", state); intent.putExtra("name", headsetName); ActivityManagerNative.broadcastStickyIntent(intent, null); } else if (headset == BIT_USB_HEADSET_DGTL) { intent = new Intent(Intent.ACTION_USB_DGTL_HEADSET_PLUG); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); intent.putExtra("state", state); intent.putExtra("name", headsetName); ActivityManagerNative.broadcastStickyIntent(intent, null); } else if (headset == BIT_HDMI_AUDIO) { intent = new Intent(Intent.ACTION_HDMI_AUDIO_PLUG); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); intent.putExtra("state", state); intent.putExtra("name", headsetName); ActivityManagerNative.broadcastStickyIntent(intent, null); } if (LOG) Slog.v(TAG, "Intent.ACTION_USB_HEADSET_PLUG: state: " + state + " name: " + headsetName); // TODO: Should we require a permission? } if ((headset == BIT_HEADSET) || (headset == BIT_HEADSET_NO_MIC)) { // Pack up the values and broadcast them to everyone Intent intent = new Intent(Intent.ACTION_HEADSET_PLUG); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); // int state = 0; int microphone = 0; if ((headset & HEADSETS_WITH_MIC) != 0) { microphone = 1; } intent.putExtra("state", state); intent.putExtra("name", headsetName); intent.putExtra("microphone", microphone); if (LOG) Slog.v( TAG, "Intent.ACTION_HEADSET_PLUG: state: " + state + " name: " + headsetName + " mic: " + microphone); // TODO: Should we require a permission? ActivityManagerNative.broadcastStickyIntent(intent, null); } } }