Loading src/java/com/android/internal/telephony/DebugService.java +55 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,11 @@ package com.android.internal.telephony; import android.annotation.NonNull; import android.content.Context; import android.content.pm.PackageManager; import android.os.Build; import android.util.Base64; import com.android.internal.telephony.metrics.TelephonyMetrics; import com.android.telephony.Rlog; Loading @@ -33,10 +37,12 @@ import java.io.PrintWriter; */ public class DebugService { private static String TAG = "DebugService"; private final Context mContext; /** Constructor */ public DebugService() { public DebugService(@NonNull Context context) { log("DebugService:"); mContext = context; } /** Loading @@ -58,9 +64,52 @@ public class DebugService { } return; case "--clearatoms": if (Build.IS_DEBUGGABLE) { if (Build.IS_DEBUGGABLE || mContext.checkCallingOrSelfPermission( android.Manifest.permission.DUMP) == PackageManager.PERMISSION_GRANTED) { log("Clearing atoms.."); PhoneFactory.getMetricsCollector().clearAtomsStorage(); if (args.length > 1 && "--saveFileImmediately".equals(args[1])) { log("Setting save-immediately mode to true after clearing."); PhoneFactory.getMetricsCollector().setSaveFileImmediately(true); } else { log("Restoring default save-delay mode after clearing."); PhoneFactory.getMetricsCollector().setSaveFileImmediately(false); } } else { pw.println("ERROR: Failed to clear atom, does not have permission."); logw("Clearing atoms.. failed, does not have permission"); } return; case "--pullAtomsBase64": if (Build.IS_DEBUGGABLE || mContext.checkCallingOrSelfPermission( android.Manifest.permission.DUMP) == PackageManager.PERMISSION_GRANTED) { log("Pulling atoms.."); try { // This method should be implemented to get the real atom proto // from PersistAtomsStorage and serialize it to bytes. byte[] atomProtoBytes = PhoneFactory.getMetricsCollector().getAtomsProtoBytes(); if (atomProtoBytes != null) { // Encode byte array to Base64 String and print it. String base64String = Base64.encodeToString(atomProtoBytes, Base64.NO_WRAP); pw.println(base64String); } if (args.length > 1 && "--clearAtoms".equals(args[1])) { log("clear atoms after pulling."); PhoneFactory.getMetricsCollector().clearAtomsStorage(); PhoneFactory.getMetricsCollector().setSaveFileImmediately(true); } } catch (Exception e) { Rlog.e(TAG, "Failed to get/encode atom data", e); } } else { logw("Pulling atoms.. failed does not have permission"); } return; } Loading @@ -72,4 +121,8 @@ public class DebugService { private static void log(String s) { Rlog.d(TAG, "DebugService " + s); } private static void logw(String s) { Rlog.w(TAG, "DebugService " + s); } } src/java/com/android/internal/telephony/metrics/MetricsCollector.java +18 −0 Original line number Diff line number Diff line Loading @@ -384,6 +384,24 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback { mStorage.clearAtoms(); } /** For CTS test purpose only. Sets whether atoms should be saved immediately. */ public void setSaveFileImmediately(boolean enable) { mStorage.setSaveImmediately(enable); } /** * Retrieves the persisted atoms from storage as a serialized byte array. * <p> * This is a pass-through method to get the raw protobuf data for debugging * or CTS verification purposes. * * @return A byte array representing the serialized atom data. */ public byte[] getAtomsProtoBytes() { concludeAll(); return mStorage.getAtomsProtoBytes(); } /** * Registers a {@link DataCallSessionStats} which will be pinged for on-going data calls when * data call atoms are pulled. Loading src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java +32 −4 Original line number Diff line number Diff line Loading @@ -774,6 +774,7 @@ public class PersistAtomsStorage { existingStats.countOfDisallowedSatelliteAccess += stats.countOfDisallowedSatelliteAccess; existingStats.countOfSatelliteAccessCheckFail += stats.countOfSatelliteAccessCheckFail; existingStats.isProvisioned = stats.isProvisioned; // Does not update isProvisioned and carrierId due to they are dimension fields. existingStats.countOfSatelliteAllowedStateChangedEvents += stats.countOfSatelliteAllowedStateChangedEvents; Loading @@ -784,7 +785,7 @@ public class PersistAtomsStorage { += stats.countOfP2PSmsAvailableNotificationShown; existingStats.countOfP2PSmsAvailableNotificationRemoved += stats.countOfP2PSmsAvailableNotificationRemoved; // Does not update isNtnOnlyCarrier due to it is a dimension field. existingStats.isNtnOnlyCarrier = stats.isNtnOnlyCarrier; existingStats.versionOfSatelliteAccessConfig = stats.versionOfSatelliteAccessConfig; existingStats.countOfIncomingDatagramTypeSosSmsSuccess += stats.countOfIncomingDatagramTypeSosSmsSuccess; Loading Loading @@ -1728,6 +1729,25 @@ public class PersistAtomsStorage { saveAtomsToFile(0); } /** * Gets the in-memory atoms as a serialized byte array. * <p> * This method serializes the current state of the in-memory {@link PersistAtoms} * into a byte array, which can be used for exporting or debugging. * * @return A byte array representing the serialized atom data, or null if the * in-memory atoms object is null. */ @Nullable public synchronized byte[] getAtomsProtoBytes() { if (mAtoms == null) { Rlog.w(TAG, "getAtomsProtoBytes: mAtoms is null, returning null."); return null; } return PersistAtoms.toByteArray(mAtoms); } /** Loads {@link PersistAtoms} from a file in private storage. */ private PersistAtoms loadAtomsFromFile() { try { Loading Loading @@ -2432,9 +2452,7 @@ public class PersistAtomsStorage { */ private @Nullable SatelliteController find(SatelliteController key) { for (SatelliteController stats : mAtoms.satelliteController) { if (stats.carrierId == key.carrierId && stats.isProvisioned == key.isProvisioned && stats.isNtnOnlyCarrier == key.isNtnOnlyCarrier) { if (stats.carrierId == key.carrierId) { return stats; } } Loading Loading @@ -2758,4 +2776,14 @@ public class PersistAtomsStorage { // Epoch time in UTC, preserved across reboots, but can be adjusted e.g. by the user or NTP return System.currentTimeMillis(); } /** * For CTS test purpose only. Sets whether atoms should be saved immediately. * * @param enabled true to enable immediate saving. */ public synchronized void setSaveImmediately(boolean enabled) { Rlog.d(TAG, "setSaveImmediately(" + enabled + ")"); mSaveImmediately = enabled; } } src/java/com/android/internal/telephony/metrics/SatelliteStats.java +3 −2 Original line number Diff line number Diff line Loading @@ -950,6 +950,7 @@ public class SatelliteStats { + mCountOfP2PSmsAvailableNotificationShown + ", countOfP2PSmsAvailableNotificationRemoved=" + mCountOfP2PSmsAvailableNotificationRemoved + ", isNtnOnlyCarrier=" + sIsNtnOnlyCarrier + ", versionOfSatelliteAccessConfig=" + sVersionOfSatelliteAccessConfig + ", countOfIncomingDatagramTypeSosSmsSuccess=" + mCountOfIncomingDatagramTypeSosSmsSuccess Loading Loading @@ -3377,10 +3378,10 @@ public class SatelliteStats { proto.initializationProcessingTimeMillis = param.getInitializationProcessingTime(); proto.terminationProcessingTimeMillis = param.getTerminationProcessingTime(); proto.sessionDurationSeconds = param.getSessionDuration(); proto.countOfOutgoingDatagramSuccess = param.getCountOfIncomingDatagramSuccess(); proto.countOfOutgoingDatagramSuccess = param.getCountOfOutgoingDatagramSuccess(); proto.countOfOutgoingDatagramFailed = param.getCountOfOutgoingDatagramFailed(); proto.countOfIncomingDatagramSuccess = param.getCountOfIncomingDatagramSuccess(); proto.countOfIncomingDatagramFailed = param.getCountOfOutgoingDatagramFailed(); proto.countOfIncomingDatagramFailed = param.getCountOfIncomingDatagramFailed(); proto.isDemoMode = param.getIsDemoMode(); proto.maxNtnSignalStrengthLevel = param.getMaxNtnSignalStrengthLevel(); proto.carrierId = param.getCarrierId(); Loading src/java/com/android/internal/telephony/satellite/SatelliteController.java +9 −12 Original line number Diff line number Diff line Loading @@ -1583,16 +1583,19 @@ public class SatelliteController extends Handler { getElapsedRealtime() - mSessionProcessingTimeStamp.get()) .setIsDemoMode(mIsDemoModeEnabled.get()) .setCarrierId(getSatelliteCarrierId()) .setIsNtnOnlyCarrier(isNtnOnlyCarrier()) .setIsEmergency(argument.isEmergency); mSessionProcessingTimeStamp.set(0); if (error == SATELLITE_RESULT_SUCCESS) { mControllerMetricsStats.onSatelliteEnabled(); mControllerMetricsStats.reportServiceEnablementSuccessCount(); mControllerMetricsStats.reportServiceEnablementSuccessCount( argument.enableDemoMode); } else { mSessionMetricsStats.reportSessionMetrics(); mSessionStartTimeStamp.set(0); mControllerMetricsStats.reportServiceEnablementFailCount(); mControllerMetricsStats.reportServiceEnablementFailCount( argument.enableDemoMode); } } else { mSessionMetricsStats.setTerminationResult(error) Loading Loading @@ -2972,9 +2975,8 @@ public class SatelliteController extends Handler { if (resultCode != SatelliteManager.SATELLITE_RESULT_SUCCESS) { plogd("requestSatelliteEnabled enable satellite is already in progress."); } sendErrorAndReportSessionMetrics(resultCode, result); result.accept(resultCode); } return; } /** Loading Loading @@ -7382,13 +7384,14 @@ public class SatelliteController extends Handler { sendRequestAsync(CMD_SET_SATELLITE_ENABLED, request, null); } mControllerMetricsStats.reportServiceEnablementFailCount(); mControllerMetricsStats.reportServiceEnablementFailCount(argument.enableDemoMode); mSessionMetricsStats.setInitializationResult(SATELLITE_RESULT_MODEM_TIMEOUT) .setSatelliteTechnology(getSupportedNtnRadioTechnology()) .setInitializationProcessingTime( getElapsedRealtime() - mSessionProcessingTimeStamp.get()) .setIsDemoMode(mIsDemoModeEnabled.get()) .setCarrierId(getSatelliteCarrierId()) .setIsNtnOnlyCarrier(isNtnOnlyCarrier()) .reportSessionMetrics(); } else { resetSatelliteDisabledRequest(); Loading Loading @@ -8423,13 +8426,7 @@ public class SatelliteController extends Handler { setSatellitePhone(selectedSubId); if (selectedSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) { int carrierId = getSatelliteCarrierId(); if (carrierId != UNKNOWN_CARRIER_ID) { mControllerMetricsStats.setCarrierId(carrierId); } else { logd("selectBindingSatelliteSubscription: Carrier ID is UNKNOWN_CARRIER_ID"); } mControllerMetricsStats.setIsNtnOnlyCarrier(isNtnOnlyCarrier()); mControllerMetricsStats.setCarrierIdInfo(getSatelliteCarrierId(), isNtnOnlyCarrier()); } plogd("selectBindingSatelliteSubscription: SelectedSatelliteSubId=" + selectedSubId); } Loading Loading
src/java/com/android/internal/telephony/DebugService.java +55 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,11 @@ package com.android.internal.telephony; import android.annotation.NonNull; import android.content.Context; import android.content.pm.PackageManager; import android.os.Build; import android.util.Base64; import com.android.internal.telephony.metrics.TelephonyMetrics; import com.android.telephony.Rlog; Loading @@ -33,10 +37,12 @@ import java.io.PrintWriter; */ public class DebugService { private static String TAG = "DebugService"; private final Context mContext; /** Constructor */ public DebugService() { public DebugService(@NonNull Context context) { log("DebugService:"); mContext = context; } /** Loading @@ -58,9 +64,52 @@ public class DebugService { } return; case "--clearatoms": if (Build.IS_DEBUGGABLE) { if (Build.IS_DEBUGGABLE || mContext.checkCallingOrSelfPermission( android.Manifest.permission.DUMP) == PackageManager.PERMISSION_GRANTED) { log("Clearing atoms.."); PhoneFactory.getMetricsCollector().clearAtomsStorage(); if (args.length > 1 && "--saveFileImmediately".equals(args[1])) { log("Setting save-immediately mode to true after clearing."); PhoneFactory.getMetricsCollector().setSaveFileImmediately(true); } else { log("Restoring default save-delay mode after clearing."); PhoneFactory.getMetricsCollector().setSaveFileImmediately(false); } } else { pw.println("ERROR: Failed to clear atom, does not have permission."); logw("Clearing atoms.. failed, does not have permission"); } return; case "--pullAtomsBase64": if (Build.IS_DEBUGGABLE || mContext.checkCallingOrSelfPermission( android.Manifest.permission.DUMP) == PackageManager.PERMISSION_GRANTED) { log("Pulling atoms.."); try { // This method should be implemented to get the real atom proto // from PersistAtomsStorage and serialize it to bytes. byte[] atomProtoBytes = PhoneFactory.getMetricsCollector().getAtomsProtoBytes(); if (atomProtoBytes != null) { // Encode byte array to Base64 String and print it. String base64String = Base64.encodeToString(atomProtoBytes, Base64.NO_WRAP); pw.println(base64String); } if (args.length > 1 && "--clearAtoms".equals(args[1])) { log("clear atoms after pulling."); PhoneFactory.getMetricsCollector().clearAtomsStorage(); PhoneFactory.getMetricsCollector().setSaveFileImmediately(true); } } catch (Exception e) { Rlog.e(TAG, "Failed to get/encode atom data", e); } } else { logw("Pulling atoms.. failed does not have permission"); } return; } Loading @@ -72,4 +121,8 @@ public class DebugService { private static void log(String s) { Rlog.d(TAG, "DebugService " + s); } private static void logw(String s) { Rlog.w(TAG, "DebugService " + s); } }
src/java/com/android/internal/telephony/metrics/MetricsCollector.java +18 −0 Original line number Diff line number Diff line Loading @@ -384,6 +384,24 @@ public class MetricsCollector implements StatsManager.StatsPullAtomCallback { mStorage.clearAtoms(); } /** For CTS test purpose only. Sets whether atoms should be saved immediately. */ public void setSaveFileImmediately(boolean enable) { mStorage.setSaveImmediately(enable); } /** * Retrieves the persisted atoms from storage as a serialized byte array. * <p> * This is a pass-through method to get the raw protobuf data for debugging * or CTS verification purposes. * * @return A byte array representing the serialized atom data. */ public byte[] getAtomsProtoBytes() { concludeAll(); return mStorage.getAtomsProtoBytes(); } /** * Registers a {@link DataCallSessionStats} which will be pinged for on-going data calls when * data call atoms are pulled. Loading
src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java +32 −4 Original line number Diff line number Diff line Loading @@ -774,6 +774,7 @@ public class PersistAtomsStorage { existingStats.countOfDisallowedSatelliteAccess += stats.countOfDisallowedSatelliteAccess; existingStats.countOfSatelliteAccessCheckFail += stats.countOfSatelliteAccessCheckFail; existingStats.isProvisioned = stats.isProvisioned; // Does not update isProvisioned and carrierId due to they are dimension fields. existingStats.countOfSatelliteAllowedStateChangedEvents += stats.countOfSatelliteAllowedStateChangedEvents; Loading @@ -784,7 +785,7 @@ public class PersistAtomsStorage { += stats.countOfP2PSmsAvailableNotificationShown; existingStats.countOfP2PSmsAvailableNotificationRemoved += stats.countOfP2PSmsAvailableNotificationRemoved; // Does not update isNtnOnlyCarrier due to it is a dimension field. existingStats.isNtnOnlyCarrier = stats.isNtnOnlyCarrier; existingStats.versionOfSatelliteAccessConfig = stats.versionOfSatelliteAccessConfig; existingStats.countOfIncomingDatagramTypeSosSmsSuccess += stats.countOfIncomingDatagramTypeSosSmsSuccess; Loading Loading @@ -1728,6 +1729,25 @@ public class PersistAtomsStorage { saveAtomsToFile(0); } /** * Gets the in-memory atoms as a serialized byte array. * <p> * This method serializes the current state of the in-memory {@link PersistAtoms} * into a byte array, which can be used for exporting or debugging. * * @return A byte array representing the serialized atom data, or null if the * in-memory atoms object is null. */ @Nullable public synchronized byte[] getAtomsProtoBytes() { if (mAtoms == null) { Rlog.w(TAG, "getAtomsProtoBytes: mAtoms is null, returning null."); return null; } return PersistAtoms.toByteArray(mAtoms); } /** Loads {@link PersistAtoms} from a file in private storage. */ private PersistAtoms loadAtomsFromFile() { try { Loading Loading @@ -2432,9 +2452,7 @@ public class PersistAtomsStorage { */ private @Nullable SatelliteController find(SatelliteController key) { for (SatelliteController stats : mAtoms.satelliteController) { if (stats.carrierId == key.carrierId && stats.isProvisioned == key.isProvisioned && stats.isNtnOnlyCarrier == key.isNtnOnlyCarrier) { if (stats.carrierId == key.carrierId) { return stats; } } Loading Loading @@ -2758,4 +2776,14 @@ public class PersistAtomsStorage { // Epoch time in UTC, preserved across reboots, but can be adjusted e.g. by the user or NTP return System.currentTimeMillis(); } /** * For CTS test purpose only. Sets whether atoms should be saved immediately. * * @param enabled true to enable immediate saving. */ public synchronized void setSaveImmediately(boolean enabled) { Rlog.d(TAG, "setSaveImmediately(" + enabled + ")"); mSaveImmediately = enabled; } }
src/java/com/android/internal/telephony/metrics/SatelliteStats.java +3 −2 Original line number Diff line number Diff line Loading @@ -950,6 +950,7 @@ public class SatelliteStats { + mCountOfP2PSmsAvailableNotificationShown + ", countOfP2PSmsAvailableNotificationRemoved=" + mCountOfP2PSmsAvailableNotificationRemoved + ", isNtnOnlyCarrier=" + sIsNtnOnlyCarrier + ", versionOfSatelliteAccessConfig=" + sVersionOfSatelliteAccessConfig + ", countOfIncomingDatagramTypeSosSmsSuccess=" + mCountOfIncomingDatagramTypeSosSmsSuccess Loading Loading @@ -3377,10 +3378,10 @@ public class SatelliteStats { proto.initializationProcessingTimeMillis = param.getInitializationProcessingTime(); proto.terminationProcessingTimeMillis = param.getTerminationProcessingTime(); proto.sessionDurationSeconds = param.getSessionDuration(); proto.countOfOutgoingDatagramSuccess = param.getCountOfIncomingDatagramSuccess(); proto.countOfOutgoingDatagramSuccess = param.getCountOfOutgoingDatagramSuccess(); proto.countOfOutgoingDatagramFailed = param.getCountOfOutgoingDatagramFailed(); proto.countOfIncomingDatagramSuccess = param.getCountOfIncomingDatagramSuccess(); proto.countOfIncomingDatagramFailed = param.getCountOfOutgoingDatagramFailed(); proto.countOfIncomingDatagramFailed = param.getCountOfIncomingDatagramFailed(); proto.isDemoMode = param.getIsDemoMode(); proto.maxNtnSignalStrengthLevel = param.getMaxNtnSignalStrengthLevel(); proto.carrierId = param.getCarrierId(); Loading
src/java/com/android/internal/telephony/satellite/SatelliteController.java +9 −12 Original line number Diff line number Diff line Loading @@ -1583,16 +1583,19 @@ public class SatelliteController extends Handler { getElapsedRealtime() - mSessionProcessingTimeStamp.get()) .setIsDemoMode(mIsDemoModeEnabled.get()) .setCarrierId(getSatelliteCarrierId()) .setIsNtnOnlyCarrier(isNtnOnlyCarrier()) .setIsEmergency(argument.isEmergency); mSessionProcessingTimeStamp.set(0); if (error == SATELLITE_RESULT_SUCCESS) { mControllerMetricsStats.onSatelliteEnabled(); mControllerMetricsStats.reportServiceEnablementSuccessCount(); mControllerMetricsStats.reportServiceEnablementSuccessCount( argument.enableDemoMode); } else { mSessionMetricsStats.reportSessionMetrics(); mSessionStartTimeStamp.set(0); mControllerMetricsStats.reportServiceEnablementFailCount(); mControllerMetricsStats.reportServiceEnablementFailCount( argument.enableDemoMode); } } else { mSessionMetricsStats.setTerminationResult(error) Loading Loading @@ -2972,9 +2975,8 @@ public class SatelliteController extends Handler { if (resultCode != SatelliteManager.SATELLITE_RESULT_SUCCESS) { plogd("requestSatelliteEnabled enable satellite is already in progress."); } sendErrorAndReportSessionMetrics(resultCode, result); result.accept(resultCode); } return; } /** Loading Loading @@ -7382,13 +7384,14 @@ public class SatelliteController extends Handler { sendRequestAsync(CMD_SET_SATELLITE_ENABLED, request, null); } mControllerMetricsStats.reportServiceEnablementFailCount(); mControllerMetricsStats.reportServiceEnablementFailCount(argument.enableDemoMode); mSessionMetricsStats.setInitializationResult(SATELLITE_RESULT_MODEM_TIMEOUT) .setSatelliteTechnology(getSupportedNtnRadioTechnology()) .setInitializationProcessingTime( getElapsedRealtime() - mSessionProcessingTimeStamp.get()) .setIsDemoMode(mIsDemoModeEnabled.get()) .setCarrierId(getSatelliteCarrierId()) .setIsNtnOnlyCarrier(isNtnOnlyCarrier()) .reportSessionMetrics(); } else { resetSatelliteDisabledRequest(); Loading Loading @@ -8423,13 +8426,7 @@ public class SatelliteController extends Handler { setSatellitePhone(selectedSubId); if (selectedSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) { int carrierId = getSatelliteCarrierId(); if (carrierId != UNKNOWN_CARRIER_ID) { mControllerMetricsStats.setCarrierId(carrierId); } else { logd("selectBindingSatelliteSubscription: Carrier ID is UNKNOWN_CARRIER_ID"); } mControllerMetricsStats.setIsNtnOnlyCarrier(isNtnOnlyCarrier()); mControllerMetricsStats.setCarrierIdInfo(getSatelliteCarrierId(), isNtnOnlyCarrier()); } plogd("selectBindingSatelliteSubscription: SelectedSatelliteSubId=" + selectedSubId); } Loading