Loading src/java/com/android/internal/telephony/metrics/DataCallSessionStats.java +43 −63 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static com.android.internal.telephony.TelephonyStatsLog.DATA_CALL_SESSION import static com.android.internal.telephony.TelephonyStatsLog.DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_UNKNOWN; import static com.android.internal.telephony.TelephonyStatsLog.DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_UNKNOWN; import static com.android.internal.telephony.TelephonyStatsLog.DATA_CALL_SESSION__IP_TYPE__APN_PROTOCOL_IPV4; import static com.android.internal.telephony.TelephonyStatsLog.DATA_CALL_SESSION__IP_TYPE__APN_PROTOCOL_IPV4; import android.annotation.Nullable; import android.os.SystemClock; import android.os.SystemClock; import android.telephony.Annotation.ApnType; import android.telephony.Annotation.ApnType; import android.telephony.Annotation.DataFailureCause; import android.telephony.Annotation.DataFailureCause; Loading Loading @@ -51,8 +52,7 @@ public class DataCallSessionStats { private final Phone mPhone; private final Phone mPhone; private long mStartTime; private long mStartTime; private boolean mOnRatChangedCalledBeforeSetup = false; @Nullable private DataCallSession mDataCallSession; DataCallSession mOngoingDataCall; private final PersistAtomsStorage mAtomsStorage = private final PersistAtomsStorage mAtomsStorage = PhoneFactory.getMetricsCollector().getAtomsStorage(); PhoneFactory.getMetricsCollector().getAtomsStorage(); Loading @@ -65,21 +65,8 @@ public class DataCallSessionStats { /** Creates a new ongoing atom when data call is set up. */ /** Creates a new ongoing atom when data call is set up. */ public synchronized void onSetupDataCall(@ApnType int apnTypeBitMask) { public synchronized void onSetupDataCall(@ApnType int apnTypeBitMask) { if (!mOnRatChangedCalledBeforeSetup) { mDataCallSession = getDefaultProto(apnTypeBitMask); // there shouldn't be an ongoing data call here, if that's the case, it means that // deactivateDataCall hasn't been processed properly, so we save the previous atom here // and move on to create a new atom. if (mOngoingDataCall != null) { onDataCallDisconnected(DataFailCause.UNKNOWN); } mOngoingDataCall = getDefaultProto(apnTypeBitMask); mStartTime = getTimeMillis(); mStartTime = getTimeMillis(); } else { // if onRatChanged was called before onSetupDataCall, the atom is already initialized // but apnTypeBitMask is initialized to 0, so we need to update it mOngoingDataCall.apnTypeBitmask = apnTypeBitMask; } mOnRatChangedCalledBeforeSetup = false; } } /** /** Loading @@ -92,73 +79,70 @@ public class DataCallSessionStats { * @param failureCause failure cause as per android.telephony.DataFailCause * @param failureCause failure cause as per android.telephony.DataFailCause */ */ public synchronized void onSetupDataCallResponse( public synchronized void onSetupDataCallResponse( DataCallResponse response, @Nullable DataCallResponse response, @RilRadioTechnology int radioTechnology, @RilRadioTechnology int radioTechnology, @ApnType int apnTypeBitmask, @ApnType int apnTypeBitmask, @ProtocolType int protocol, @ProtocolType int protocol, @DataFailureCause int failureCause) { @DataFailureCause int failureCause) { // there should've been another call to initiate the atom, // there should've been a call to onSetupDataCall to initiate the atom, // so this method is being called out of order -> no metric will be logged // so this method is being called out of order -> no metric will be logged if (mOngoingDataCall == null) { if (mDataCallSession == null) { loge("onSetupDataCallResponse: no DataCallSession atom has been initiated."); loge("onSetupDataCallResponse: no DataCallSession atom has been initiated."); return; return; } } mOngoingDataCall.ratAtEnd = ServiceState.rilRadioTechnologyToNetworkType(radioTechnology); mDataCallSession.ratAtEnd = ServiceState.rilRadioTechnologyToNetworkType(radioTechnology); // only set if apn hasn't been set during setup // only set if apn hasn't been set during setup if (mOngoingDataCall.apnTypeBitmask == 0) { if (mDataCallSession.apnTypeBitmask == 0) { mOngoingDataCall.apnTypeBitmask = apnTypeBitmask; mDataCallSession.apnTypeBitmask = apnTypeBitmask; } } mOngoingDataCall.ipType = protocol; mDataCallSession.ipType = protocol; mOngoingDataCall.failureCause = failureCause; mDataCallSession.failureCause = failureCause; if (response != null) { if (response != null) { mOngoingDataCall.suggestedRetryMillis = mDataCallSession.suggestedRetryMillis = (int) Math.min(response.getRetryDurationMillis(), Integer.MAX_VALUE); (int) Math.min(response.getRetryDurationMillis(), Integer.MAX_VALUE); // If setup has failed, then store the atom if (failureCause != DataFailCause.NONE) { if (failureCause != DataFailCause.NONE) { mOngoingDataCall.failureCause = failureCause; mDataCallSession.failureCause = failureCause; mOngoingDataCall.setupFailed = true; mDataCallSession.setupFailed = true; // set dataCall as inactive mDataCallSession.ongoing = false; mOngoingDataCall.ongoing = false; mAtomsStorage.addDataCallSession(mDataCallSession); // store it only if setup has failed mDataCallSession = null; mAtomsStorage.addDataCallSession(mOngoingDataCall); mOngoingDataCall = null; } } } } } } /** /** * Updates the ongoing dataCall's atom when data call is deactivated. * Updates the dataCall atom when data call is deactivated. * * * @param reason Deactivate reason * @param reason Deactivate reason */ */ public synchronized void setDeactivateDataCallReason(@DeactivateDataReason int reason) { public synchronized void setDeactivateDataCallReason(@DeactivateDataReason int reason) { // there should've been another call to initiate the atom, // there should've been another call to initiate the atom, // so this method is being called out of order -> no metric will be logged // so this method is being called out of order -> no metric will be logged if (mOngoingDataCall == null) { if (mDataCallSession == null) { loge("onSetupDataCallResponse: no DataCallSession atom has been initiated."); loge("setDeactivateDataCallReason: no DataCallSession atom has been initiated."); return; return; } } switch (reason) { switch (reason) { case DataService.REQUEST_REASON_NORMAL: case DataService.REQUEST_REASON_NORMAL: mOngoingDataCall.deactivateReason = mDataCallSession.deactivateReason = DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_NORMAL; DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_NORMAL; break; break; case DataService.REQUEST_REASON_SHUTDOWN: case DataService.REQUEST_REASON_SHUTDOWN: mOngoingDataCall.deactivateReason = mDataCallSession.deactivateReason = DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_RADIO_OFF; DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_RADIO_OFF; break; break; case DataService.REQUEST_REASON_HANDOVER: case DataService.REQUEST_REASON_HANDOVER: mOngoingDataCall.deactivateReason = mDataCallSession.deactivateReason = DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_HANDOVER; DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_HANDOVER; break; break; default: default: mOngoingDataCall.deactivateReason = mDataCallSession.deactivateReason = DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_UNKNOWN; DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_UNKNOWN; break; break; } } mOngoingDataCall.oosAtEnd = getIsOos(); } } /** Stores the atom when DataConnection reaches DISCONNECTED state. /** Stores the atom when DataConnection reaches DISCONNECTED state. Loading @@ -167,17 +151,18 @@ public class DataCallSessionStats { public synchronized void onDataCallDisconnected(@DataFailureCause int failureCause) { public synchronized void onDataCallDisconnected(@DataFailureCause int failureCause) { // there should've been another call to initiate the atom, // there should've been another call to initiate the atom, // so this method is being called out of order -> no atom will be saved // so this method is being called out of order -> no atom will be saved if (mOngoingDataCall == null) { if (mDataCallSession == null) { loge("onSetupDataCallResponse: no DataCallSession atom has been initiated."); loge("onDataCallDisconnected: no DataCallSession atom has been initiated."); return; return; } } mOngoingDataCall.failureCause = failureCause; mDataCallSession.failureCause = failureCause; mOngoingDataCall.ongoing = false; mDataCallSession.oosAtEnd = getIsOos(); mOngoingDataCall.durationMinutes = convertMillisToMinutes(getTimeMillis() - mStartTime); mDataCallSession.ongoing = false; mDataCallSession.durationMinutes = convertMillisToMinutes(getTimeMillis() - mStartTime); // store for the data call list event, after DataCall is disconnected and entered into // store for the data call list event, after DataCall is disconnected and entered into // inactive mode // inactive mode mAtomsStorage.addDataCallSession(mOngoingDataCall); mAtomsStorage.addDataCallSession(mDataCallSession); mOngoingDataCall = null; mDataCallSession = null; } } /** /** Loading @@ -187,24 +172,19 @@ public class DataCallSessionStats { * registration state change. * registration state change. */ */ public synchronized void onDrsOrRatChanged(@RilRadioTechnology int radioTechnology) { public synchronized void onDrsOrRatChanged(@RilRadioTechnology int radioTechnology) { @NetworkType int rat = ServiceState.rilRadioTechnologyToNetworkType(radioTechnology); @NetworkType int currentRat = // if no data call is initiated, or we have a new data call while the last one has ended ServiceState.rilRadioTechnologyToNetworkType(radioTechnology); // because onRatChanged might be called before onSetupDataCall if (mDataCallSession != null if (mOngoingDataCall == null) { && currentRat != TelephonyManager.NETWORK_TYPE_UNKNOWN mOngoingDataCall = getDefaultProto(0); && mDataCallSession.ratAtEnd != currentRat) { mOngoingDataCall.ratAtEnd = rat; mDataCallSession.ratSwitchCount++; mStartTime = getTimeMillis(); mDataCallSession.ratAtEnd = currentRat; mOnRatChangedCalledBeforeSetup = true; mDataCallSession.bandAtEnd = ServiceStateStats.getBand(mPhone, currentRat); } if (rat != TelephonyManager.NETWORK_TYPE_UNKNOWN && mOngoingDataCall.ratAtEnd != rat) { mOngoingDataCall.ratSwitchCount++; mOngoingDataCall.ratAtEnd = rat; } } mOngoingDataCall.bandAtEnd = ServiceStateStats.getBand(mPhone, rat); } } private static long convertMillisToMinutes(long millis) { private static long convertMillisToMinutes(long millis) { return Math.round(millis / 60000); return Math.round(millis / 60000.0); } } /** Creates a proto for a normal {@code DataCallSession} with default values. */ /** Creates a proto for a normal {@code DataCallSession} with default values. */ Loading Loading
src/java/com/android/internal/telephony/metrics/DataCallSessionStats.java +43 −63 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static com.android.internal.telephony.TelephonyStatsLog.DATA_CALL_SESSION import static com.android.internal.telephony.TelephonyStatsLog.DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_UNKNOWN; import static com.android.internal.telephony.TelephonyStatsLog.DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_UNKNOWN; import static com.android.internal.telephony.TelephonyStatsLog.DATA_CALL_SESSION__IP_TYPE__APN_PROTOCOL_IPV4; import static com.android.internal.telephony.TelephonyStatsLog.DATA_CALL_SESSION__IP_TYPE__APN_PROTOCOL_IPV4; import android.annotation.Nullable; import android.os.SystemClock; import android.os.SystemClock; import android.telephony.Annotation.ApnType; import android.telephony.Annotation.ApnType; import android.telephony.Annotation.DataFailureCause; import android.telephony.Annotation.DataFailureCause; Loading Loading @@ -51,8 +52,7 @@ public class DataCallSessionStats { private final Phone mPhone; private final Phone mPhone; private long mStartTime; private long mStartTime; private boolean mOnRatChangedCalledBeforeSetup = false; @Nullable private DataCallSession mDataCallSession; DataCallSession mOngoingDataCall; private final PersistAtomsStorage mAtomsStorage = private final PersistAtomsStorage mAtomsStorage = PhoneFactory.getMetricsCollector().getAtomsStorage(); PhoneFactory.getMetricsCollector().getAtomsStorage(); Loading @@ -65,21 +65,8 @@ public class DataCallSessionStats { /** Creates a new ongoing atom when data call is set up. */ /** Creates a new ongoing atom when data call is set up. */ public synchronized void onSetupDataCall(@ApnType int apnTypeBitMask) { public synchronized void onSetupDataCall(@ApnType int apnTypeBitMask) { if (!mOnRatChangedCalledBeforeSetup) { mDataCallSession = getDefaultProto(apnTypeBitMask); // there shouldn't be an ongoing data call here, if that's the case, it means that // deactivateDataCall hasn't been processed properly, so we save the previous atom here // and move on to create a new atom. if (mOngoingDataCall != null) { onDataCallDisconnected(DataFailCause.UNKNOWN); } mOngoingDataCall = getDefaultProto(apnTypeBitMask); mStartTime = getTimeMillis(); mStartTime = getTimeMillis(); } else { // if onRatChanged was called before onSetupDataCall, the atom is already initialized // but apnTypeBitMask is initialized to 0, so we need to update it mOngoingDataCall.apnTypeBitmask = apnTypeBitMask; } mOnRatChangedCalledBeforeSetup = false; } } /** /** Loading @@ -92,73 +79,70 @@ public class DataCallSessionStats { * @param failureCause failure cause as per android.telephony.DataFailCause * @param failureCause failure cause as per android.telephony.DataFailCause */ */ public synchronized void onSetupDataCallResponse( public synchronized void onSetupDataCallResponse( DataCallResponse response, @Nullable DataCallResponse response, @RilRadioTechnology int radioTechnology, @RilRadioTechnology int radioTechnology, @ApnType int apnTypeBitmask, @ApnType int apnTypeBitmask, @ProtocolType int protocol, @ProtocolType int protocol, @DataFailureCause int failureCause) { @DataFailureCause int failureCause) { // there should've been another call to initiate the atom, // there should've been a call to onSetupDataCall to initiate the atom, // so this method is being called out of order -> no metric will be logged // so this method is being called out of order -> no metric will be logged if (mOngoingDataCall == null) { if (mDataCallSession == null) { loge("onSetupDataCallResponse: no DataCallSession atom has been initiated."); loge("onSetupDataCallResponse: no DataCallSession atom has been initiated."); return; return; } } mOngoingDataCall.ratAtEnd = ServiceState.rilRadioTechnologyToNetworkType(radioTechnology); mDataCallSession.ratAtEnd = ServiceState.rilRadioTechnologyToNetworkType(radioTechnology); // only set if apn hasn't been set during setup // only set if apn hasn't been set during setup if (mOngoingDataCall.apnTypeBitmask == 0) { if (mDataCallSession.apnTypeBitmask == 0) { mOngoingDataCall.apnTypeBitmask = apnTypeBitmask; mDataCallSession.apnTypeBitmask = apnTypeBitmask; } } mOngoingDataCall.ipType = protocol; mDataCallSession.ipType = protocol; mOngoingDataCall.failureCause = failureCause; mDataCallSession.failureCause = failureCause; if (response != null) { if (response != null) { mOngoingDataCall.suggestedRetryMillis = mDataCallSession.suggestedRetryMillis = (int) Math.min(response.getRetryDurationMillis(), Integer.MAX_VALUE); (int) Math.min(response.getRetryDurationMillis(), Integer.MAX_VALUE); // If setup has failed, then store the atom if (failureCause != DataFailCause.NONE) { if (failureCause != DataFailCause.NONE) { mOngoingDataCall.failureCause = failureCause; mDataCallSession.failureCause = failureCause; mOngoingDataCall.setupFailed = true; mDataCallSession.setupFailed = true; // set dataCall as inactive mDataCallSession.ongoing = false; mOngoingDataCall.ongoing = false; mAtomsStorage.addDataCallSession(mDataCallSession); // store it only if setup has failed mDataCallSession = null; mAtomsStorage.addDataCallSession(mOngoingDataCall); mOngoingDataCall = null; } } } } } } /** /** * Updates the ongoing dataCall's atom when data call is deactivated. * Updates the dataCall atom when data call is deactivated. * * * @param reason Deactivate reason * @param reason Deactivate reason */ */ public synchronized void setDeactivateDataCallReason(@DeactivateDataReason int reason) { public synchronized void setDeactivateDataCallReason(@DeactivateDataReason int reason) { // there should've been another call to initiate the atom, // there should've been another call to initiate the atom, // so this method is being called out of order -> no metric will be logged // so this method is being called out of order -> no metric will be logged if (mOngoingDataCall == null) { if (mDataCallSession == null) { loge("onSetupDataCallResponse: no DataCallSession atom has been initiated."); loge("setDeactivateDataCallReason: no DataCallSession atom has been initiated."); return; return; } } switch (reason) { switch (reason) { case DataService.REQUEST_REASON_NORMAL: case DataService.REQUEST_REASON_NORMAL: mOngoingDataCall.deactivateReason = mDataCallSession.deactivateReason = DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_NORMAL; DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_NORMAL; break; break; case DataService.REQUEST_REASON_SHUTDOWN: case DataService.REQUEST_REASON_SHUTDOWN: mOngoingDataCall.deactivateReason = mDataCallSession.deactivateReason = DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_RADIO_OFF; DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_RADIO_OFF; break; break; case DataService.REQUEST_REASON_HANDOVER: case DataService.REQUEST_REASON_HANDOVER: mOngoingDataCall.deactivateReason = mDataCallSession.deactivateReason = DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_HANDOVER; DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_HANDOVER; break; break; default: default: mOngoingDataCall.deactivateReason = mDataCallSession.deactivateReason = DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_UNKNOWN; DATA_CALL_SESSION__DEACTIVATE_REASON__DEACTIVATE_REASON_UNKNOWN; break; break; } } mOngoingDataCall.oosAtEnd = getIsOos(); } } /** Stores the atom when DataConnection reaches DISCONNECTED state. /** Stores the atom when DataConnection reaches DISCONNECTED state. Loading @@ -167,17 +151,18 @@ public class DataCallSessionStats { public synchronized void onDataCallDisconnected(@DataFailureCause int failureCause) { public synchronized void onDataCallDisconnected(@DataFailureCause int failureCause) { // there should've been another call to initiate the atom, // there should've been another call to initiate the atom, // so this method is being called out of order -> no atom will be saved // so this method is being called out of order -> no atom will be saved if (mOngoingDataCall == null) { if (mDataCallSession == null) { loge("onSetupDataCallResponse: no DataCallSession atom has been initiated."); loge("onDataCallDisconnected: no DataCallSession atom has been initiated."); return; return; } } mOngoingDataCall.failureCause = failureCause; mDataCallSession.failureCause = failureCause; mOngoingDataCall.ongoing = false; mDataCallSession.oosAtEnd = getIsOos(); mOngoingDataCall.durationMinutes = convertMillisToMinutes(getTimeMillis() - mStartTime); mDataCallSession.ongoing = false; mDataCallSession.durationMinutes = convertMillisToMinutes(getTimeMillis() - mStartTime); // store for the data call list event, after DataCall is disconnected and entered into // store for the data call list event, after DataCall is disconnected and entered into // inactive mode // inactive mode mAtomsStorage.addDataCallSession(mOngoingDataCall); mAtomsStorage.addDataCallSession(mDataCallSession); mOngoingDataCall = null; mDataCallSession = null; } } /** /** Loading @@ -187,24 +172,19 @@ public class DataCallSessionStats { * registration state change. * registration state change. */ */ public synchronized void onDrsOrRatChanged(@RilRadioTechnology int radioTechnology) { public synchronized void onDrsOrRatChanged(@RilRadioTechnology int radioTechnology) { @NetworkType int rat = ServiceState.rilRadioTechnologyToNetworkType(radioTechnology); @NetworkType int currentRat = // if no data call is initiated, or we have a new data call while the last one has ended ServiceState.rilRadioTechnologyToNetworkType(radioTechnology); // because onRatChanged might be called before onSetupDataCall if (mDataCallSession != null if (mOngoingDataCall == null) { && currentRat != TelephonyManager.NETWORK_TYPE_UNKNOWN mOngoingDataCall = getDefaultProto(0); && mDataCallSession.ratAtEnd != currentRat) { mOngoingDataCall.ratAtEnd = rat; mDataCallSession.ratSwitchCount++; mStartTime = getTimeMillis(); mDataCallSession.ratAtEnd = currentRat; mOnRatChangedCalledBeforeSetup = true; mDataCallSession.bandAtEnd = ServiceStateStats.getBand(mPhone, currentRat); } if (rat != TelephonyManager.NETWORK_TYPE_UNKNOWN && mOngoingDataCall.ratAtEnd != rat) { mOngoingDataCall.ratSwitchCount++; mOngoingDataCall.ratAtEnd = rat; } } mOngoingDataCall.bandAtEnd = ServiceStateStats.getBand(mPhone, rat); } } private static long convertMillisToMinutes(long millis) { private static long convertMillisToMinutes(long millis) { return Math.round(millis / 60000); return Math.round(millis / 60000.0); } } /** Creates a proto for a normal {@code DataCallSession} with default values. */ /** Creates a proto for a normal {@code DataCallSession} with default values. */ Loading