Loading src/java/com/android/internal/telephony/GsmCdmaCallTracker.java +5 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,8 @@ public class GsmCdmaCallTracker extends CallTracker { Call.SrvccState mSrvccState = Call.SrvccState.NONE; private TelephonyEventLog mEventLog; // Following member variables are for CDMA only RegistrantList mCallWaitingRegistrants = new RegistrantList(); boolean mPendingCallInEcm; Loading Loading @@ -152,6 +154,8 @@ public class GsmCdmaCallTracker extends CallTracker { mPhone.getContext().registerReceiver(mEcmExitReceiver, filter); updatePhoneType(); mEventLog = TelephonyEventLog.getInstance(mPhone.getContext(), mPhone.getPhoneId()); } public void updatePhoneType() { Loading Loading @@ -725,6 +729,7 @@ public class GsmCdmaCallTracker extends CallTracker { } if (mState != oldState) { mPhone.notifyPhoneStateChanged(); mEventLog.writePhoneState(mState); } } Loading src/java/com/android/internal/telephony/RIL.java +12 −2 Original line number Diff line number Diff line Loading @@ -1556,8 +1556,16 @@ public final class RIL extends BaseCommands implements CommandsInterface { + profile + " " + apn + " " + user + " " + password + " " + authType + " " + protocol); mEventLog.writeRilSetupDataCall(rr.mSerial, radioTechnology, profile, apn, user, password, authType, protocol); // The first parameter passed to RIL_REQUEST_SETUP_DATA_CALL can be: // 0 - for CDMA // 1 - for GSM/UMTS // >=2 - RIL_RadioTechnology+2 // The framework never passes 0 or 1, so by subtracting 2 we convert this parameter // to RIL_RadioTechnology. final int rilRat = Integer.parseInt(radioTechnology) - 2; mEventLog.writeRilSetupDataCall(rr.mSerial, rilRat, Integer.parseInt(profile), apn, user, password, Integer.parseInt(authType), protocol); send(rr); } Loading Loading @@ -2125,6 +2133,8 @@ public final class RIL extends BaseCommands implements CommandsInterface { if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " : " + networkType); mEventLog.writeSetPreferredNetworkType(networkType); send(rr); } Loading src/java/com/android/internal/telephony/TelephonyEventLog.java +62 −9 Original line number Diff line number Diff line package com.android.internal.telephony; import com.android.ims.ImsConfig; import com.android.ims.ImsReasonInfo; import com.android.ims.internal.ImsCallSession; import com.android.internal.telephony.dataconnection.DataCallResponse; Loading Loading @@ -38,7 +39,6 @@ public class TelephonyEventLog { public static final int TAG_DATA_CALL_LIST = 5; public static final int TAG_PHONE_STATE = 8; public static final int TAG_SMS = 10; public static final int TAG_RIL_REQUEST = 1001; public static final int TAG_RIL_RESPONSE = 1002; Loading Loading @@ -81,6 +81,17 @@ public class TelephonyEventLog { public static final int TAG_IMS_CALL_STATE = 2030; public static final int SETTING_AIRPLANE_MODE = 1; public static final int SETTING_CELL_DATA_ENABLED = 2; public static final int SETTING_DATA_ROAMING_ENABLED = 3; public static final int SETTING_PREFERRED_NETWORK_MODE = 4; public static final int SETTING_WIFI_ENABLED = 5; public static final int SETTING_VO_LTE_ENABLED = 6; public static final int SETTING_VO_WIFI_ENABLED = 7; public static final int SETTING_WFC_MODE = 8; public static final int SETTING_VI_LTE_ENABLED = 9; public static final int SETTING_VI_WIFI_ENABLED = 10; public static final int IMS_CONNECTION_STATE_CONNECTED = 1; public static final int IMS_CONNECTION_STATE_PROGRESSING = 2; public static final int IMS_CONNECTION_STATE_DISCONNECTED = 3; Loading Loading @@ -147,7 +158,7 @@ public class TelephonyEventLog { final Intent intent = new Intent(); intent.setClassName(context, "com.android.phone.TelephonyDebugService"); ServiceConnection mConnection = new ServiceConnection() { ServiceConnection connection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { if (DBG) Log.d(TAG, "onServiceConnected()"); mService = ITelephonyDebug.Stub.asInterface(service); Loading @@ -159,7 +170,7 @@ public class TelephonyEventLog { } }; context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); context.bindService(intent, connection, Context.BIND_AUTO_CREATE); } private void writeEvent(int tag, Bundle data) { Loading Loading @@ -196,6 +207,47 @@ public class TelephonyEventLog { writeEvent(TAG_SERVICE_STATE, b); } public void writeSetAirplaneMode(boolean enabled) { writeEvent(TAG_SETTINGS, SETTING_AIRPLANE_MODE, enabled ? 1 : 0); } public void writeSetCellDataEnabled(boolean enabled) { writeEvent(TAG_SETTINGS, SETTING_CELL_DATA_ENABLED, enabled ? 1 : 0); } public void writeSetDataRoamingEnabled(boolean enabled) { writeEvent(TAG_SETTINGS, SETTING_DATA_ROAMING_ENABLED, enabled ? 1 : 0); } public void writeSetPreferredNetworkType(int mode) { writeEvent(TAG_SETTINGS, SETTING_PREFERRED_NETWORK_MODE, mode); } public void writeSetWifiEnabled(boolean enabled) { writeEvent(TAG_SETTINGS, SETTING_WIFI_ENABLED, enabled ? 1 : 0); } public void writeSetWfcMode(int mode) { writeEvent(TAG_SETTINGS, SETTING_WFC_MODE, mode); } public void writeImsSetFeatureValue(int feature, int network, int value, int status) { switch (feature) { case ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_LTE: writeEvent(TAG_SETTINGS, SETTING_VO_LTE_ENABLED, value); break; case ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_WIFI: writeEvent(TAG_SETTINGS, SETTING_VO_WIFI_ENABLED, value); break; case ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_LTE: writeEvent(TAG_SETTINGS, SETTING_VI_LTE_ENABLED, value); break; case ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_WIFI: writeEvent(TAG_SETTINGS, SETTING_VI_WIFI_ENABLED, value); break; } } public void writeOnImsConnectionState(int state, ImsReasonInfo reasonInfo) { writeEvent(TAG_IMS_CONNECTION_STATE, state, -1, imsReasonInfoToBundle(reasonInfo)); } Loading @@ -212,11 +264,11 @@ public class TelephonyEventLog { } public void writeRilSetupDataCall(int rilSerial, String radioTechnology, String profile, String apn, String user, String password, String authType, String protocol) { int radioTechnology, int profile, String apn, String user, String password, int authType, String protocol) { Bundle b = new Bundle(); b.putString(DATA_KEY_RAT, radioTechnology); b.putString(DATA_KEY_DATA_PROFILE, profile); b.putInt(DATA_KEY_RAT, radioTechnology); b.putInt(DATA_KEY_DATA_PROFILE, profile); b.putString(DATA_KEY_APN, apn); b.putString(DATA_KEY_PROTOCOL, protocol); writeEvent(TAG_RIL_REQUEST, RIL_REQUEST_SETUP_DATA_CALL, rilSerial, b); Loading Loading @@ -289,7 +341,8 @@ public class TelephonyEventLog { writeEvent(TAG_RIL_UNSOL_RESPONSE, response, -1, null); } public void writeOnRilSolicitedResponse(int rilSerial, int rilError, int rilRequest, Object ret) { public void writeOnRilSolicitedResponse(int rilSerial, int rilError, int rilRequest, Object ret) { Bundle b = new Bundle(); if (rilError != 0) b.putInt(DATA_KEY_RIL_ERROR, rilError); switch (rilRequest) { Loading Loading @@ -326,7 +379,7 @@ public class TelephonyEventLog { } } public void writeImsPhoneState(PhoneConstants.State phoneState) { public void writePhoneState(PhoneConstants.State phoneState) { int state; switch (phoneState) { case IDLE: state = 0; break; Loading src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +23 −3 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ import android.telephony.SubscriptionManager; import com.android.ims.ImsCall; import com.android.ims.ImsCallProfile; import com.android.ims.ImsConfig; import com.android.ims.ImsConfigListener; import com.android.ims.ImsConnectionStateListener; import com.android.ims.ImsEcbm; import com.android.ims.ImsException; Loading Loading @@ -254,6 +255,8 @@ public final class ImsPhoneCallTracker extends CallTracker { createIncomingCallPendingIntent(), mImsConnectionStateListener); mImsManager.setImsConfigListener(mImsConfigListener); // Get the ECBM interface and set IMSPhone's listener object for notifications getEcbmInterface().setEcbmStateListener(mPhone.mImsEcbmStateListener); if (mPhone.isInEcm()) { Loading Loading @@ -750,7 +753,7 @@ public final class ImsPhoneCallTracker extends CallTracker { if (mState != oldState) { mPhone.notifyPhoneStateChanged(); mEventLog.writeImsPhoneState(mState); mEventLog.writePhoneState(mState); } } Loading Loading @@ -1271,6 +1274,8 @@ public final class ImsPhoneCallTracker extends CallTracker { cause = DisconnectCause.IMS_MERGED_SUCCESSFULLY; } mEventLog.writeOnImsCallTerminated(imsCall.getCallSession(), reasonInfo); processCallStateChange(imsCall, ImsPhoneCall.State.DISCONNECTED, cause); if (mForegroundCall.getState() != ImsPhoneCall.State.ACTIVE) { if (mRingingCall.getState().isRinging()) { Loading Loading @@ -1304,8 +1309,6 @@ public final class ImsPhoneCallTracker extends CallTracker { mCallExpectedToResume = null; } } mEventLog.writeOnImsCallTerminated(imsCall.getCallSession(), reasonInfo); } @Override Loading Loading @@ -1794,6 +1797,23 @@ public final class ImsPhoneCallTracker extends CallTracker { } }; private ImsConfigListener.Stub mImsConfigListener = new ImsConfigListener.Stub() { @Override public void onGetFeatureResponse(int feature, int network, int value, int status) {} @Override public void onSetFeatureResponse(int feature, int network, int value, int status) { mEventLog.writeImsSetFeatureValue(feature, network, value, status); } @Override public void onGetVideoQuality(int status, int quality) {} @Override public void onSetVideoQuality(int status) {} }; /* package */ ImsUtInterface getUtInterface() throws ImsException { if (mImsManager == null) { Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyEventLogTest.java 0 → 100644 +386 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.telephony; import com.android.ims.ImsConfig; import com.android.ims.ImsReasonInfo; import android.content.ComponentName; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.RemoteException; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.test.mock.MockContext; import android.test.suitebuilder.annotation.SmallTest; import android.util.ArrayMap; import android.util.Log; import android.util.SparseArray; import static org.junit.Assert.*; import static org.mockito.Mockito.*; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.lang.reflect.Field; public class TelephonyEventLogTest { private static final String TAG = "TelephonyEventLogTest"; @Mock ITelephonyDebug.Stub mBinder; private EventLogContext mContext; private TelephonyEventLog mEventLog; private class EventLogContext extends MockContext { ITelephonyDebug.Stub mBinder; private EventLogContext(ITelephonyDebug.Stub binder) { mBinder = binder; } @Override public boolean bindService(Intent serviceIntent, ServiceConnection connection, int flags) { connection.onServiceConnected(new ComponentName("test", "test"), mBinder); return true; } @Override public String getPackageName() { return "com.android.internal.telephony"; } } private static final class BundleMatcher extends BaseMatcher<Bundle> { ArrayMap<String, Object> mMap = null; public BundleMatcher(ArrayMap<String, Object> m) { mMap = m; } @Override public boolean matches(Object item) { Bundle b = (Bundle) item; // compare only values stored in the map for (int i=0; i < mMap.size(); i++) { String key = mMap.keyAt(i); Object value = mMap.valueAt(i); if (!value.equals(b.get(key))) { logd("key: " + key + ", expected: " + value + ", actual: " + b.get(key)); return false; } } return true; } @Override public void describeTo(Description description) { description.appendText(mMap.toString()); } } @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mContext = new EventLogContext(mBinder); doReturn(mBinder).when(mBinder). queryLocalInterface(eq("com.android.internal.telephony.ITelephonyDebug")); //Use reflection to modify singleton Field field = TelephonyEventLog.class.getDeclaredField("sInstances"); field.setAccessible(true); SparseArray<TelephonyEventLog> instances = (SparseArray<TelephonyEventLog>)field.get(null); instances.clear(); mEventLog = TelephonyEventLog.getInstance(mContext, 0); } @After public void tearDown() throws Exception { mEventLog = null; } @Test @SmallTest public void testWriteServiceStateChanged() { ServiceState serviceState = new ServiceState(); serviceState.setVoiceRegState(ServiceState.STATE_IN_SERVICE); serviceState.setDataRegState(ServiceState.STATE_IN_SERVICE); serviceState.setVoiceRoamingType(ServiceState.ROAMING_TYPE_NOT_ROAMING); serviceState.setDataRoamingType(ServiceState.ROAMING_TYPE_NOT_ROAMING); serviceState.setVoiceOperatorName("Test Voice Long", "TestVoice", "12345"); serviceState.setDataOperatorName("Test Date Long", "TestData", "67890"); serviceState.setRilVoiceRadioTechnology(ServiceState.RIL_RADIO_TECHNOLOGY_LTE); serviceState.setRilDataRadioTechnology(ServiceState.RIL_RADIO_TECHNOLOGY_LTE); mEventLog.writeServiceStateChanged(serviceState); ArrayMap<String, Object> m = new ArrayMap<>(); m.put("voiceRegState", ServiceState.STATE_IN_SERVICE); m.put("dataRegState", ServiceState.STATE_IN_SERVICE); m.put("voiceRoamingType", ServiceState.ROAMING_TYPE_NOT_ROAMING); m.put("dataRoamingType", ServiceState.ROAMING_TYPE_NOT_ROAMING); m.put("operator-alpha-long", "Test Voice Long"); m.put("operator-alpha-short", "TestVoice"); m.put("operator-numeric", "12345"); m.put("data-operator-alpha-long", "Test Date Long"); m.put("data-operator-alpha-short", "TestData"); m.put("data-operator-numeric", "67890"); m.put("radioTechnology", ServiceState.RIL_RADIO_TECHNOLOGY_LTE); m.put("dataRadioTechnology", ServiceState.RIL_RADIO_TECHNOLOGY_LTE); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SERVICE_STATE), eq(-1), eq(-1), argThat(new BundleMatcher(m))); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteSetAirplaneMode() { mEventLog.writeSetAirplaneMode(true); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_AIRPLANE_MODE), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeSetAirplaneMode(false); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_AIRPLANE_MODE), eq(0), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteSetCellDataEnabled() { mEventLog.writeSetCellDataEnabled(true); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_CELL_DATA_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeSetCellDataEnabled(false); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_CELL_DATA_ENABLED), eq(0), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteSetDataRoamingEnabled() { mEventLog.writeSetDataRoamingEnabled(true); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_DATA_ROAMING_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeSetDataRoamingEnabled(false); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_DATA_ROAMING_ENABLED), eq(0), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteSetPreferredNetworkType() { mEventLog.writeSetPreferredNetworkType(RILConstants.NETWORK_MODE_GLOBAL); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_PREFERRED_NETWORK_MODE), eq(RILConstants.NETWORK_MODE_GLOBAL), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteSetWifiEnabled() { mEventLog.writeSetWifiEnabled(true); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_WIFI_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeSetWifiEnabled(false); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_WIFI_ENABLED), eq(0), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteSetWfcMode() { mEventLog.writeSetWfcMode(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_WFC_MODE), eq(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteImsSetFeatureValue() { mEventLog.writeImsSetFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_LTE, TelephonyManager.NETWORK_TYPE_LTE, 1, ImsConfig.OperationStatusConstants.SUCCESS); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_VO_LTE_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeImsSetFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_WIFI, TelephonyManager.NETWORK_TYPE_IWLAN, 1, ImsConfig.OperationStatusConstants.SUCCESS); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_VO_WIFI_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeImsSetFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_LTE, TelephonyManager.NETWORK_TYPE_LTE, 1, ImsConfig.OperationStatusConstants.SUCCESS); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_VI_LTE_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeImsSetFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_WIFI, TelephonyManager.NETWORK_TYPE_IWLAN, 1, ImsConfig.OperationStatusConstants.SUCCESS); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_VI_WIFI_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteImsConnectionState() { mEventLog.writeOnImsConnectionState( TelephonyEventLog.IMS_CONNECTION_STATE_CONNECTED, null); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_IMS_CONNECTION_STATE), eq(TelephonyEventLog.IMS_CONNECTION_STATE_CONNECTED), eq(-1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeOnImsConnectionState( TelephonyEventLog.IMS_CONNECTION_STATE_DISCONNECTED, new ImsReasonInfo(1, 2, "test")); ArrayMap<String, Object> m = new ArrayMap<>(); m.put(TelephonyEventLog.DATA_KEY_REASONINFO_CODE, 1); m.put(TelephonyEventLog.DATA_KEY_REASONINFO_EXTRA_CODE, 2); m.put(TelephonyEventLog.DATA_KEY_REASONINFO_EXTRA_MESSAGE, "test"); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_IMS_CONNECTION_STATE), eq(TelephonyEventLog.IMS_CONNECTION_STATE_DISCONNECTED), eq(-1), argThat(new BundleMatcher(m))); } catch (RemoteException e) { fail(e.toString()); } } private static void logd(String s) { Log.d(TAG, s); } } No newline at end of file Loading
src/java/com/android/internal/telephony/GsmCdmaCallTracker.java +5 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,8 @@ public class GsmCdmaCallTracker extends CallTracker { Call.SrvccState mSrvccState = Call.SrvccState.NONE; private TelephonyEventLog mEventLog; // Following member variables are for CDMA only RegistrantList mCallWaitingRegistrants = new RegistrantList(); boolean mPendingCallInEcm; Loading Loading @@ -152,6 +154,8 @@ public class GsmCdmaCallTracker extends CallTracker { mPhone.getContext().registerReceiver(mEcmExitReceiver, filter); updatePhoneType(); mEventLog = TelephonyEventLog.getInstance(mPhone.getContext(), mPhone.getPhoneId()); } public void updatePhoneType() { Loading Loading @@ -725,6 +729,7 @@ public class GsmCdmaCallTracker extends CallTracker { } if (mState != oldState) { mPhone.notifyPhoneStateChanged(); mEventLog.writePhoneState(mState); } } Loading
src/java/com/android/internal/telephony/RIL.java +12 −2 Original line number Diff line number Diff line Loading @@ -1556,8 +1556,16 @@ public final class RIL extends BaseCommands implements CommandsInterface { + profile + " " + apn + " " + user + " " + password + " " + authType + " " + protocol); mEventLog.writeRilSetupDataCall(rr.mSerial, radioTechnology, profile, apn, user, password, authType, protocol); // The first parameter passed to RIL_REQUEST_SETUP_DATA_CALL can be: // 0 - for CDMA // 1 - for GSM/UMTS // >=2 - RIL_RadioTechnology+2 // The framework never passes 0 or 1, so by subtracting 2 we convert this parameter // to RIL_RadioTechnology. final int rilRat = Integer.parseInt(radioTechnology) - 2; mEventLog.writeRilSetupDataCall(rr.mSerial, rilRat, Integer.parseInt(profile), apn, user, password, Integer.parseInt(authType), protocol); send(rr); } Loading Loading @@ -2125,6 +2133,8 @@ public final class RIL extends BaseCommands implements CommandsInterface { if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " : " + networkType); mEventLog.writeSetPreferredNetworkType(networkType); send(rr); } Loading
src/java/com/android/internal/telephony/TelephonyEventLog.java +62 −9 Original line number Diff line number Diff line package com.android.internal.telephony; import com.android.ims.ImsConfig; import com.android.ims.ImsReasonInfo; import com.android.ims.internal.ImsCallSession; import com.android.internal.telephony.dataconnection.DataCallResponse; Loading Loading @@ -38,7 +39,6 @@ public class TelephonyEventLog { public static final int TAG_DATA_CALL_LIST = 5; public static final int TAG_PHONE_STATE = 8; public static final int TAG_SMS = 10; public static final int TAG_RIL_REQUEST = 1001; public static final int TAG_RIL_RESPONSE = 1002; Loading Loading @@ -81,6 +81,17 @@ public class TelephonyEventLog { public static final int TAG_IMS_CALL_STATE = 2030; public static final int SETTING_AIRPLANE_MODE = 1; public static final int SETTING_CELL_DATA_ENABLED = 2; public static final int SETTING_DATA_ROAMING_ENABLED = 3; public static final int SETTING_PREFERRED_NETWORK_MODE = 4; public static final int SETTING_WIFI_ENABLED = 5; public static final int SETTING_VO_LTE_ENABLED = 6; public static final int SETTING_VO_WIFI_ENABLED = 7; public static final int SETTING_WFC_MODE = 8; public static final int SETTING_VI_LTE_ENABLED = 9; public static final int SETTING_VI_WIFI_ENABLED = 10; public static final int IMS_CONNECTION_STATE_CONNECTED = 1; public static final int IMS_CONNECTION_STATE_PROGRESSING = 2; public static final int IMS_CONNECTION_STATE_DISCONNECTED = 3; Loading Loading @@ -147,7 +158,7 @@ public class TelephonyEventLog { final Intent intent = new Intent(); intent.setClassName(context, "com.android.phone.TelephonyDebugService"); ServiceConnection mConnection = new ServiceConnection() { ServiceConnection connection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { if (DBG) Log.d(TAG, "onServiceConnected()"); mService = ITelephonyDebug.Stub.asInterface(service); Loading @@ -159,7 +170,7 @@ public class TelephonyEventLog { } }; context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); context.bindService(intent, connection, Context.BIND_AUTO_CREATE); } private void writeEvent(int tag, Bundle data) { Loading Loading @@ -196,6 +207,47 @@ public class TelephonyEventLog { writeEvent(TAG_SERVICE_STATE, b); } public void writeSetAirplaneMode(boolean enabled) { writeEvent(TAG_SETTINGS, SETTING_AIRPLANE_MODE, enabled ? 1 : 0); } public void writeSetCellDataEnabled(boolean enabled) { writeEvent(TAG_SETTINGS, SETTING_CELL_DATA_ENABLED, enabled ? 1 : 0); } public void writeSetDataRoamingEnabled(boolean enabled) { writeEvent(TAG_SETTINGS, SETTING_DATA_ROAMING_ENABLED, enabled ? 1 : 0); } public void writeSetPreferredNetworkType(int mode) { writeEvent(TAG_SETTINGS, SETTING_PREFERRED_NETWORK_MODE, mode); } public void writeSetWifiEnabled(boolean enabled) { writeEvent(TAG_SETTINGS, SETTING_WIFI_ENABLED, enabled ? 1 : 0); } public void writeSetWfcMode(int mode) { writeEvent(TAG_SETTINGS, SETTING_WFC_MODE, mode); } public void writeImsSetFeatureValue(int feature, int network, int value, int status) { switch (feature) { case ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_LTE: writeEvent(TAG_SETTINGS, SETTING_VO_LTE_ENABLED, value); break; case ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_WIFI: writeEvent(TAG_SETTINGS, SETTING_VO_WIFI_ENABLED, value); break; case ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_LTE: writeEvent(TAG_SETTINGS, SETTING_VI_LTE_ENABLED, value); break; case ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_WIFI: writeEvent(TAG_SETTINGS, SETTING_VI_WIFI_ENABLED, value); break; } } public void writeOnImsConnectionState(int state, ImsReasonInfo reasonInfo) { writeEvent(TAG_IMS_CONNECTION_STATE, state, -1, imsReasonInfoToBundle(reasonInfo)); } Loading @@ -212,11 +264,11 @@ public class TelephonyEventLog { } public void writeRilSetupDataCall(int rilSerial, String radioTechnology, String profile, String apn, String user, String password, String authType, String protocol) { int radioTechnology, int profile, String apn, String user, String password, int authType, String protocol) { Bundle b = new Bundle(); b.putString(DATA_KEY_RAT, radioTechnology); b.putString(DATA_KEY_DATA_PROFILE, profile); b.putInt(DATA_KEY_RAT, radioTechnology); b.putInt(DATA_KEY_DATA_PROFILE, profile); b.putString(DATA_KEY_APN, apn); b.putString(DATA_KEY_PROTOCOL, protocol); writeEvent(TAG_RIL_REQUEST, RIL_REQUEST_SETUP_DATA_CALL, rilSerial, b); Loading Loading @@ -289,7 +341,8 @@ public class TelephonyEventLog { writeEvent(TAG_RIL_UNSOL_RESPONSE, response, -1, null); } public void writeOnRilSolicitedResponse(int rilSerial, int rilError, int rilRequest, Object ret) { public void writeOnRilSolicitedResponse(int rilSerial, int rilError, int rilRequest, Object ret) { Bundle b = new Bundle(); if (rilError != 0) b.putInt(DATA_KEY_RIL_ERROR, rilError); switch (rilRequest) { Loading Loading @@ -326,7 +379,7 @@ public class TelephonyEventLog { } } public void writeImsPhoneState(PhoneConstants.State phoneState) { public void writePhoneState(PhoneConstants.State phoneState) { int state; switch (phoneState) { case IDLE: state = 0; break; Loading
src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +23 −3 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ import android.telephony.SubscriptionManager; import com.android.ims.ImsCall; import com.android.ims.ImsCallProfile; import com.android.ims.ImsConfig; import com.android.ims.ImsConfigListener; import com.android.ims.ImsConnectionStateListener; import com.android.ims.ImsEcbm; import com.android.ims.ImsException; Loading Loading @@ -254,6 +255,8 @@ public final class ImsPhoneCallTracker extends CallTracker { createIncomingCallPendingIntent(), mImsConnectionStateListener); mImsManager.setImsConfigListener(mImsConfigListener); // Get the ECBM interface and set IMSPhone's listener object for notifications getEcbmInterface().setEcbmStateListener(mPhone.mImsEcbmStateListener); if (mPhone.isInEcm()) { Loading Loading @@ -750,7 +753,7 @@ public final class ImsPhoneCallTracker extends CallTracker { if (mState != oldState) { mPhone.notifyPhoneStateChanged(); mEventLog.writeImsPhoneState(mState); mEventLog.writePhoneState(mState); } } Loading Loading @@ -1271,6 +1274,8 @@ public final class ImsPhoneCallTracker extends CallTracker { cause = DisconnectCause.IMS_MERGED_SUCCESSFULLY; } mEventLog.writeOnImsCallTerminated(imsCall.getCallSession(), reasonInfo); processCallStateChange(imsCall, ImsPhoneCall.State.DISCONNECTED, cause); if (mForegroundCall.getState() != ImsPhoneCall.State.ACTIVE) { if (mRingingCall.getState().isRinging()) { Loading Loading @@ -1304,8 +1309,6 @@ public final class ImsPhoneCallTracker extends CallTracker { mCallExpectedToResume = null; } } mEventLog.writeOnImsCallTerminated(imsCall.getCallSession(), reasonInfo); } @Override Loading Loading @@ -1794,6 +1797,23 @@ public final class ImsPhoneCallTracker extends CallTracker { } }; private ImsConfigListener.Stub mImsConfigListener = new ImsConfigListener.Stub() { @Override public void onGetFeatureResponse(int feature, int network, int value, int status) {} @Override public void onSetFeatureResponse(int feature, int network, int value, int status) { mEventLog.writeImsSetFeatureValue(feature, network, value, status); } @Override public void onGetVideoQuality(int status, int quality) {} @Override public void onSetVideoQuality(int status) {} }; /* package */ ImsUtInterface getUtInterface() throws ImsException { if (mImsManager == null) { Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyEventLogTest.java 0 → 100644 +386 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.telephony; import com.android.ims.ImsConfig; import com.android.ims.ImsReasonInfo; import android.content.ComponentName; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.RemoteException; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.test.mock.MockContext; import android.test.suitebuilder.annotation.SmallTest; import android.util.ArrayMap; import android.util.Log; import android.util.SparseArray; import static org.junit.Assert.*; import static org.mockito.Mockito.*; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.lang.reflect.Field; public class TelephonyEventLogTest { private static final String TAG = "TelephonyEventLogTest"; @Mock ITelephonyDebug.Stub mBinder; private EventLogContext mContext; private TelephonyEventLog mEventLog; private class EventLogContext extends MockContext { ITelephonyDebug.Stub mBinder; private EventLogContext(ITelephonyDebug.Stub binder) { mBinder = binder; } @Override public boolean bindService(Intent serviceIntent, ServiceConnection connection, int flags) { connection.onServiceConnected(new ComponentName("test", "test"), mBinder); return true; } @Override public String getPackageName() { return "com.android.internal.telephony"; } } private static final class BundleMatcher extends BaseMatcher<Bundle> { ArrayMap<String, Object> mMap = null; public BundleMatcher(ArrayMap<String, Object> m) { mMap = m; } @Override public boolean matches(Object item) { Bundle b = (Bundle) item; // compare only values stored in the map for (int i=0; i < mMap.size(); i++) { String key = mMap.keyAt(i); Object value = mMap.valueAt(i); if (!value.equals(b.get(key))) { logd("key: " + key + ", expected: " + value + ", actual: " + b.get(key)); return false; } } return true; } @Override public void describeTo(Description description) { description.appendText(mMap.toString()); } } @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mContext = new EventLogContext(mBinder); doReturn(mBinder).when(mBinder). queryLocalInterface(eq("com.android.internal.telephony.ITelephonyDebug")); //Use reflection to modify singleton Field field = TelephonyEventLog.class.getDeclaredField("sInstances"); field.setAccessible(true); SparseArray<TelephonyEventLog> instances = (SparseArray<TelephonyEventLog>)field.get(null); instances.clear(); mEventLog = TelephonyEventLog.getInstance(mContext, 0); } @After public void tearDown() throws Exception { mEventLog = null; } @Test @SmallTest public void testWriteServiceStateChanged() { ServiceState serviceState = new ServiceState(); serviceState.setVoiceRegState(ServiceState.STATE_IN_SERVICE); serviceState.setDataRegState(ServiceState.STATE_IN_SERVICE); serviceState.setVoiceRoamingType(ServiceState.ROAMING_TYPE_NOT_ROAMING); serviceState.setDataRoamingType(ServiceState.ROAMING_TYPE_NOT_ROAMING); serviceState.setVoiceOperatorName("Test Voice Long", "TestVoice", "12345"); serviceState.setDataOperatorName("Test Date Long", "TestData", "67890"); serviceState.setRilVoiceRadioTechnology(ServiceState.RIL_RADIO_TECHNOLOGY_LTE); serviceState.setRilDataRadioTechnology(ServiceState.RIL_RADIO_TECHNOLOGY_LTE); mEventLog.writeServiceStateChanged(serviceState); ArrayMap<String, Object> m = new ArrayMap<>(); m.put("voiceRegState", ServiceState.STATE_IN_SERVICE); m.put("dataRegState", ServiceState.STATE_IN_SERVICE); m.put("voiceRoamingType", ServiceState.ROAMING_TYPE_NOT_ROAMING); m.put("dataRoamingType", ServiceState.ROAMING_TYPE_NOT_ROAMING); m.put("operator-alpha-long", "Test Voice Long"); m.put("operator-alpha-short", "TestVoice"); m.put("operator-numeric", "12345"); m.put("data-operator-alpha-long", "Test Date Long"); m.put("data-operator-alpha-short", "TestData"); m.put("data-operator-numeric", "67890"); m.put("radioTechnology", ServiceState.RIL_RADIO_TECHNOLOGY_LTE); m.put("dataRadioTechnology", ServiceState.RIL_RADIO_TECHNOLOGY_LTE); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SERVICE_STATE), eq(-1), eq(-1), argThat(new BundleMatcher(m))); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteSetAirplaneMode() { mEventLog.writeSetAirplaneMode(true); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_AIRPLANE_MODE), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeSetAirplaneMode(false); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_AIRPLANE_MODE), eq(0), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteSetCellDataEnabled() { mEventLog.writeSetCellDataEnabled(true); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_CELL_DATA_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeSetCellDataEnabled(false); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_CELL_DATA_ENABLED), eq(0), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteSetDataRoamingEnabled() { mEventLog.writeSetDataRoamingEnabled(true); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_DATA_ROAMING_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeSetDataRoamingEnabled(false); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_DATA_ROAMING_ENABLED), eq(0), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteSetPreferredNetworkType() { mEventLog.writeSetPreferredNetworkType(RILConstants.NETWORK_MODE_GLOBAL); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_PREFERRED_NETWORK_MODE), eq(RILConstants.NETWORK_MODE_GLOBAL), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteSetWifiEnabled() { mEventLog.writeSetWifiEnabled(true); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_WIFI_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeSetWifiEnabled(false); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_WIFI_ENABLED), eq(0), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteSetWfcMode() { mEventLog.writeSetWfcMode(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_WFC_MODE), eq(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteImsSetFeatureValue() { mEventLog.writeImsSetFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_LTE, TelephonyManager.NETWORK_TYPE_LTE, 1, ImsConfig.OperationStatusConstants.SUCCESS); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_VO_LTE_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeImsSetFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_WIFI, TelephonyManager.NETWORK_TYPE_IWLAN, 1, ImsConfig.OperationStatusConstants.SUCCESS); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_VO_WIFI_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeImsSetFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_LTE, TelephonyManager.NETWORK_TYPE_LTE, 1, ImsConfig.OperationStatusConstants.SUCCESS); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_VI_LTE_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeImsSetFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_WIFI, TelephonyManager.NETWORK_TYPE_IWLAN, 1, ImsConfig.OperationStatusConstants.SUCCESS); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_SETTINGS), eq(TelephonyEventLog.SETTING_VI_WIFI_ENABLED), eq(1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } } @Test @SmallTest public void testWriteImsConnectionState() { mEventLog.writeOnImsConnectionState( TelephonyEventLog.IMS_CONNECTION_STATE_CONNECTED, null); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_IMS_CONNECTION_STATE), eq(TelephonyEventLog.IMS_CONNECTION_STATE_CONNECTED), eq(-1), isNull(Bundle.class)); } catch (RemoteException e) { fail(e.toString()); } mEventLog.writeOnImsConnectionState( TelephonyEventLog.IMS_CONNECTION_STATE_DISCONNECTED, new ImsReasonInfo(1, 2, "test")); ArrayMap<String, Object> m = new ArrayMap<>(); m.put(TelephonyEventLog.DATA_KEY_REASONINFO_CODE, 1); m.put(TelephonyEventLog.DATA_KEY_REASONINFO_EXTRA_CODE, 2); m.put(TelephonyEventLog.DATA_KEY_REASONINFO_EXTRA_MESSAGE, "test"); try { verify(mContext.mBinder).writeEvent(anyLong(), eq(0), eq(TelephonyEventLog.TAG_IMS_CONNECTION_STATE), eq(TelephonyEventLog.IMS_CONNECTION_STATE_DISCONNECTED), eq(-1), argThat(new BundleMatcher(m))); } catch (RemoteException e) { fail(e.toString()); } } private static void logd(String s) { Log.d(TAG, s); } } No newline at end of file