Loading src/com/android/bluetooth/hfp/HeadsetPhoneState.java +10 −38 Original line number Original line Diff line number Diff line Loading @@ -17,10 +17,7 @@ package com.android.bluetooth.hfp; package com.android.bluetooth.hfp; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.Handler; import android.telephony.PhoneStateListener; import android.telephony.PhoneStateListener; import android.telephony.ServiceState; import android.telephony.ServiceState; Loading Loading @@ -57,9 +54,6 @@ public class HeadsetPhoneState { // HFP 1.6 CIND service value // HFP 1.6 CIND service value private int mCindService = HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE; private int mCindService = HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE; // Check this before sending out service state to the device -- if the SIM isn't fully // loaded, don't expose that the network is available. private boolean mIsSimStateLoaded; // Number of active (foreground) calls // Number of active (foreground) calls private int mNumActive; private int mNumActive; // Current Call Setup State // Current Call Setup State Loading Loading @@ -207,6 +201,10 @@ public class HeadsetPhoneState { mNumHeld = numHeldCall; mNumHeld = numHeldCall; } } ServiceState getServiceState() { return mServiceState; } int getCindSignal() { int getCindSignal() { return mCindSignal; return mCindSignal; } } Loading Loading @@ -237,17 +235,15 @@ public class HeadsetPhoneState { } } private synchronized void sendDeviceStateChanged() { private synchronized void sendDeviceStateChanged() { int service = mIsSimStateLoaded ? mCindService : HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE; // When out of service, send signal strength as 0. Some devices don't // When out of service, send signal strength as 0. Some devices don't // use the service indicator, but only the signal indicator // use the service indicator, but only the signal indicator int signal = service == HeadsetHalConstants.NETWORK_STATE_AVAILABLE ? mCindSignal : 0; int signal = mCindService == HeadsetHalConstants.NETWORK_STATE_AVAILABLE ? mCindSignal : 0; Log.d(TAG, "sendDeviceStateChanged. mService=" + mCindService + " mIsSimStateLoaded=" Log.d(TAG, "sendDeviceStateChanged. mService=" + mCindService + mIsSimStateLoaded + " mSignal=" + signal + " mRoam=" + mCindRoam + " mSignal=" + mCindSignal + " mRoam=" + mCindRoam + " mBatteryCharge=" + mCindBatteryCharge); + " mBatteryCharge=" + mCindBatteryCharge); mHeadsetService.onDeviceStateChanged( mHeadsetService.onDeviceStateChanged( new HeadsetDeviceState(service, mCindRoam, signal, mCindBatteryCharge)); new HeadsetDeviceState(mCindService, mCindRoam, signal, mCindBatteryCharge)); } } private class HeadsetPhoneStateOnSubscriptionChangedListener private class HeadsetPhoneStateOnSubscriptionChangedListener Loading @@ -261,6 +257,7 @@ public class HeadsetPhoneState { synchronized (mDeviceEventMap) { synchronized (mDeviceEventMap) { int simState = mTelephonyManager.getSimState(); int simState = mTelephonyManager.getSimState(); if (simState != TelephonyManager.SIM_STATE_READY) { if (simState != TelephonyManager.SIM_STATE_READY) { mServiceState = null; mCindSignal = 0; mCindSignal = 0; mCindService = HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE; mCindService = HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE; sendDeviceStateChanged(); sendDeviceStateChanged(); Loading Loading @@ -291,32 +288,7 @@ public class HeadsetPhoneState { } } mCindService = cindService; mCindService = cindService; mCindRoam = newRoam; mCindRoam = newRoam; // If this is due to a SIM insertion, we want to defer sending device state changed // until all the SIM config is loaded. if (cindService == HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE) { mIsSimStateLoaded = false; sendDeviceStateChanged(); sendDeviceStateChanged(); return; } IntentFilter simStateChangedFilter = new IntentFilter(Intent.ACTION_SIM_STATE_CHANGED); mHeadsetService.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_SIM_STATE_CHANGED.equals(intent.getAction())) { // This is a sticky broadcast, so if it's already been loaded, // this'll execute immediately. if (Intent.SIM_STATE_LOADED.equals( intent.getStringExtra(Intent.EXTRA_SIM_STATE))) { mIsSimStateLoaded = true; sendDeviceStateChanged(); mHeadsetService.unregisterReceiver(this); } } } }, simStateChangedFilter); } } @Override @Override Loading src/com/android/bluetooth/hfp/HeadsetStateMachine.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.SystemClock; import android.os.UserHandle; import android.os.UserHandle; import android.telephony.PhoneNumberUtils; import android.telephony.PhoneNumberUtils; import android.telephony.PhoneStateListener; import android.telephony.PhoneStateListener; import android.telephony.ServiceState; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; Loading Loading @@ -1703,7 +1704,16 @@ public class HeadsetStateMachine extends StateMachine { } } private void processAtCops(BluetoothDevice device) { private void processAtCops(BluetoothDevice device) { String operatorName = mSystemInterface.getNetworkOperator(); // Get operator name suggested by Telephony String operatorName = null; ServiceState serviceState = mSystemInterface.getHeadsetPhoneState().getServiceState(); if (serviceState != null) { operatorName = serviceState.getOperatorAlpha(); } if (mSystemInterface.isInCall() || operatorName == null || operatorName.equals("")) { // Get operator name suggested by Telecom operatorName = mSystemInterface.getNetworkOperator(); } if (operatorName == null) { if (operatorName == null) { operatorName = ""; operatorName = ""; } } Loading Loading
src/com/android/bluetooth/hfp/HeadsetPhoneState.java +10 −38 Original line number Original line Diff line number Diff line Loading @@ -17,10 +17,7 @@ package com.android.bluetooth.hfp; package com.android.bluetooth.hfp; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.Handler; import android.telephony.PhoneStateListener; import android.telephony.PhoneStateListener; import android.telephony.ServiceState; import android.telephony.ServiceState; Loading Loading @@ -57,9 +54,6 @@ public class HeadsetPhoneState { // HFP 1.6 CIND service value // HFP 1.6 CIND service value private int mCindService = HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE; private int mCindService = HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE; // Check this before sending out service state to the device -- if the SIM isn't fully // loaded, don't expose that the network is available. private boolean mIsSimStateLoaded; // Number of active (foreground) calls // Number of active (foreground) calls private int mNumActive; private int mNumActive; // Current Call Setup State // Current Call Setup State Loading Loading @@ -207,6 +201,10 @@ public class HeadsetPhoneState { mNumHeld = numHeldCall; mNumHeld = numHeldCall; } } ServiceState getServiceState() { return mServiceState; } int getCindSignal() { int getCindSignal() { return mCindSignal; return mCindSignal; } } Loading Loading @@ -237,17 +235,15 @@ public class HeadsetPhoneState { } } private synchronized void sendDeviceStateChanged() { private synchronized void sendDeviceStateChanged() { int service = mIsSimStateLoaded ? mCindService : HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE; // When out of service, send signal strength as 0. Some devices don't // When out of service, send signal strength as 0. Some devices don't // use the service indicator, but only the signal indicator // use the service indicator, but only the signal indicator int signal = service == HeadsetHalConstants.NETWORK_STATE_AVAILABLE ? mCindSignal : 0; int signal = mCindService == HeadsetHalConstants.NETWORK_STATE_AVAILABLE ? mCindSignal : 0; Log.d(TAG, "sendDeviceStateChanged. mService=" + mCindService + " mIsSimStateLoaded=" Log.d(TAG, "sendDeviceStateChanged. mService=" + mCindService + mIsSimStateLoaded + " mSignal=" + signal + " mRoam=" + mCindRoam + " mSignal=" + mCindSignal + " mRoam=" + mCindRoam + " mBatteryCharge=" + mCindBatteryCharge); + " mBatteryCharge=" + mCindBatteryCharge); mHeadsetService.onDeviceStateChanged( mHeadsetService.onDeviceStateChanged( new HeadsetDeviceState(service, mCindRoam, signal, mCindBatteryCharge)); new HeadsetDeviceState(mCindService, mCindRoam, signal, mCindBatteryCharge)); } } private class HeadsetPhoneStateOnSubscriptionChangedListener private class HeadsetPhoneStateOnSubscriptionChangedListener Loading @@ -261,6 +257,7 @@ public class HeadsetPhoneState { synchronized (mDeviceEventMap) { synchronized (mDeviceEventMap) { int simState = mTelephonyManager.getSimState(); int simState = mTelephonyManager.getSimState(); if (simState != TelephonyManager.SIM_STATE_READY) { if (simState != TelephonyManager.SIM_STATE_READY) { mServiceState = null; mCindSignal = 0; mCindSignal = 0; mCindService = HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE; mCindService = HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE; sendDeviceStateChanged(); sendDeviceStateChanged(); Loading Loading @@ -291,32 +288,7 @@ public class HeadsetPhoneState { } } mCindService = cindService; mCindService = cindService; mCindRoam = newRoam; mCindRoam = newRoam; // If this is due to a SIM insertion, we want to defer sending device state changed // until all the SIM config is loaded. if (cindService == HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE) { mIsSimStateLoaded = false; sendDeviceStateChanged(); sendDeviceStateChanged(); return; } IntentFilter simStateChangedFilter = new IntentFilter(Intent.ACTION_SIM_STATE_CHANGED); mHeadsetService.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_SIM_STATE_CHANGED.equals(intent.getAction())) { // This is a sticky broadcast, so if it's already been loaded, // this'll execute immediately. if (Intent.SIM_STATE_LOADED.equals( intent.getStringExtra(Intent.EXTRA_SIM_STATE))) { mIsSimStateLoaded = true; sendDeviceStateChanged(); mHeadsetService.unregisterReceiver(this); } } } }, simStateChangedFilter); } } @Override @Override Loading
src/com/android/bluetooth/hfp/HeadsetStateMachine.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.SystemClock; import android.os.UserHandle; import android.os.UserHandle; import android.telephony.PhoneNumberUtils; import android.telephony.PhoneNumberUtils; import android.telephony.PhoneStateListener; import android.telephony.PhoneStateListener; import android.telephony.ServiceState; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; Loading Loading @@ -1703,7 +1704,16 @@ public class HeadsetStateMachine extends StateMachine { } } private void processAtCops(BluetoothDevice device) { private void processAtCops(BluetoothDevice device) { String operatorName = mSystemInterface.getNetworkOperator(); // Get operator name suggested by Telephony String operatorName = null; ServiceState serviceState = mSystemInterface.getHeadsetPhoneState().getServiceState(); if (serviceState != null) { operatorName = serviceState.getOperatorAlpha(); } if (mSystemInterface.isInCall() || operatorName == null || operatorName.equals("")) { // Get operator name suggested by Telecom operatorName = mSystemInterface.getNetworkOperator(); } if (operatorName == null) { if (operatorName == null) { operatorName = ""; operatorName = ""; } } Loading