aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--car-usb-handler/src/android/car/usb/handler/UsbHostManagementActivity.java20
-rw-r--r--service/jni/evs/EvsServiceContext.cpp8
-rw-r--r--service/jni/evs/EvsServiceContext.h2
-rw-r--r--service/src/com/android/car/evs/CarEvsService.java39
-rw-r--r--service/src/com/android/car/oem/CarOemAudioFocusProxyService.java2
-rw-r--r--service/src/com/android/car/oem/CarOemProxyService.java1
-rw-r--r--service/src/com/android/car/oem/CarOemProxyServiceHelper.java192
-rw-r--r--service/src/com/android/car/telemetry/publisher/ConnectivityPublisher.java2
-rw-r--r--service/src/com/android/car/telemetry/publisher/Constants.java13
-rw-r--r--service/src/com/android/car/telemetry/publisher/MemoryPublisher.java35
-rw-r--r--service/src/com/android/car/telemetry/publisher/statsconverters/AbstractAtomConverter.java18
-rw-r--r--service/src/com/android/car/telemetry/publisher/statsconverters/EventMetricDataConverter.java6
-rw-r--r--service/src/com/android/car/telemetry/publisher/statsconverters/GaugeMetricDataConverter.java6
-rw-r--r--service/src/com/android/car/telemetry/sessioncontroller/SessionAnnotation.java29
-rw-r--r--tests/carservice_unit_test/src/com/android/car/hardware/power/CarPowerManagerUnitTest.java24
-rw-r--r--tests/carservice_unit_test/src/com/android/car/oem/CarOemProxyServiceHelperTest.java40
-rw-r--r--tests/carservice_unit_test/src/com/android/car/power/CarPowerManagementServiceUnitTest.java4
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/CarTelemetrydPublisherTest.java10
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/ConnectivityPublisherTest.java9
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/MemoryPublisherTest.java77
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/StatsPublisherTest.java14
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ActivityForegroundStateChangedConverterTest.java16
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AnrOccurredConverterTest.java16
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AppCrashOccurredConverterTest.java15
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AppStartMemoryStateCapturedConverterTest.java33
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AtomListConverterTest.java25
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ConfigMetricsReportListConverterTest.java30
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/EventMetricDataConverterTest.java26
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/GaugeMetricDataConverterTest.java40
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ProcessCpuTimeConverterTest.java15
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ProcessMemoryStateConverterTest.java30
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/WtfOccurredConverterTest.java24
-rw-r--r--tests/carservice_unit_test/src/com/android/car/telemetry/sessioncontroller/SessionAnnotationUnitTest.java12
33 files changed, 571 insertions, 262 deletions
diff --git a/car-usb-handler/src/android/car/usb/handler/UsbHostManagementActivity.java b/car-usb-handler/src/android/car/usb/handler/UsbHostManagementActivity.java
index 9be12ec8df..0bc17c1c73 100644
--- a/car-usb-handler/src/android/car/usb/handler/UsbHostManagementActivity.java
+++ b/car-usb-handler/src/android/car/usb/handler/UsbHostManagementActivity.java
@@ -118,6 +118,7 @@ public class UsbHostManagementActivity extends Activity {
mHandlersList.setOnItemClickListener(mHandlerClickListener);
mController = new UsbHostController(this, new UsbCallbacks());
mPackageManager = getPackageManager();
+ hideDialog();
}
@Override
@@ -150,6 +151,21 @@ public class UsbHostManagementActivity extends Activity {
}
}
+ private void hideDialog() {
+ setTheme(android.R.style.Theme_Translucent);
+ if (mUsbHandlersDialog != null) {
+ mUsbHandlersDialog.setVisibility(View.GONE);
+ }
+ }
+
+ private void showDialog() {
+ setTranslucent(false);
+ setTheme(android.R.style.Theme_DeviceDefault_Dialog);
+ if (mUsbHandlersDialog != null) {
+ mUsbHandlersDialog.setVisibility(View.VISIBLE);
+ }
+ }
+
class UsbCallbacks implements UsbHostController.UsbHostControllerCallbacks {
private boolean mProcessing = false;
@@ -170,7 +186,7 @@ public class UsbHostManagementActivity extends Activity {
@Override
public void run() {
if (mProcessing && !mListAdapter.isEmpty()) {
- mUsbHandlersDialog.setVisibility(View.VISIBLE);
+ showDialog();
}
}
});
@@ -188,7 +204,7 @@ public class UsbHostManagementActivity extends Activity {
@Override
public void run() {
if (mProcessing) {
- mUsbHandlersDialog.setVisibility(View.VISIBLE);
+ showDialog();
}
mListAdapter.clear();
mListAdapter.addAll(options);
diff --git a/service/jni/evs/EvsServiceContext.cpp b/service/jni/evs/EvsServiceContext.cpp
index e3d722019e..ff6f7ae134 100644
--- a/service/jni/evs/EvsServiceContext.cpp
+++ b/service/jni/evs/EvsServiceContext.cpp
@@ -179,7 +179,8 @@ bool EvsServiceContext::initialize(JNIEnv* env, jobject thiz) {
mCarEvsServiceObj = env->NewGlobalRef(thiz);
}
- // Reset a EvsDisplay handle
+ // Reset a stored camera id and a display handle
+ mCameraIdInUse.clear();
mDisplay = nullptr;
}
@@ -273,6 +274,10 @@ void EvsServiceContext::closeCamera() {
LOG(WARNING) << "Failed to close a current camera device.";
}
}
+
+ // Reset a camera reference and id in use.
+ mCamera.reset();
+ mCameraIdInUse.clear();
}
bool EvsServiceContext::startVideoStream() {
@@ -429,6 +434,7 @@ void EvsServiceContext::onEvsServiceDiedImpl() {
mService = nullptr;
mStreamHandler = nullptr;
mBufferRecords.clear();
+ mCameraIdInUse.clear();
}
LOG(ERROR) << "The native EVS service has died.";
diff --git a/service/jni/evs/EvsServiceContext.h b/service/jni/evs/EvsServiceContext.h
index 87966d113c..38e1b5e0d5 100644
--- a/service/jni/evs/EvsServiceContext.h
+++ b/service/jni/evs/EvsServiceContext.h
@@ -160,7 +160,7 @@ private:
std::set<int> mBufferRecords GUARDED_BY(mLock);
// A name of the camera device currently in use.
- std::string_view mCameraIdInUse;
+ std::string mCameraIdInUse;
// List of available camera devices
std::vector<::aidl::android::hardware::automotive::evs::CameraDesc> mCameraList;
diff --git a/service/src/com/android/car/evs/CarEvsService.java b/service/src/com/android/car/evs/CarEvsService.java
index c1026dd72e..142e7b364f 100644
--- a/service/src/com/android/car/evs/CarEvsService.java
+++ b/service/src/com/android/car/evs/CarEvsService.java
@@ -467,11 +467,7 @@ public final class CarEvsService extends android.car.evs.ICarEvsService.Stub
return ERROR_BUSY;
}
- if (callback != null) {
- stopVideoStreamAndUnregisterCallback(callback);
- } else {
- stopService();
- }
+ stopService(callback);
break;
default:
@@ -600,6 +596,7 @@ public final class CarEvsService extends android.car.evs.ICarEvsService.Stub
if (mStreamCallback != null) {
// keep old reference for Runnable.
ICarEvsStreamCallback previousCallback = mStreamCallback;
+ mStreamCallback = null;
mHandler.post(() -> notifyStreamStopped(previousCallback));
}
@@ -684,7 +681,7 @@ public final class CarEvsService extends android.car.evs.ICarEvsService.Stub
// Stops a current video stream and unregisters a callback
private void stopVideoStreamAndUnregisterCallback(ICarEvsStreamCallback callback) {
synchronized (mLock) {
- if (callback.asBinder() != mStreamCallback.asBinder()) {
+ if (callback == null || callback.asBinder() != mStreamCallback.asBinder()) {
Slogf.i(TAG_EVS, "Declines a request to stop a video not from a current client.");
return;
}
@@ -1023,7 +1020,6 @@ public final class CarEvsService extends android.car.evs.ICarEvsService.Stub
public void stopVideoStream(@NonNull ICarEvsStreamCallback callback) {
CarServiceUtils.assertPermission(mContext, Car.PERMISSION_USE_CAR_EVS_CAMERA);
Objects.requireNonNull(callback);
-
synchronized (mLock) {
if (mStreamCallback == null || callback.asBinder() != mStreamCallback.asBinder()) {
Slogf.i(TAG_EVS, "Ignores a video stream request not from current stream client.");
@@ -1243,16 +1239,32 @@ public final class CarEvsService extends android.car.evs.ICarEvsService.Stub
/** Stops a current service */
private void stopService() {
+ stopService(/* callback= */ null);
+ }
+
+ private void stopService(ICarEvsStreamCallback callback) {
try {
- mHalWrapper.requestToStopVideoStream();
- } catch (RuntimeException e) {
- Slogf.w(TAG_EVS, Log.getStackTraceString(e));
- } finally {
- // Unregister all stream callbacks.
synchronized (mLock) {
+ if (callback != null && callback.asBinder() != mStreamCallback.asBinder()) {
+ Slogf.w(TAG_EVS, "Decline a request to stop a video from an unknown client.");
+ return;
+ }
+
+ unlinkToDeathStreamCallbackLocked();
mStreamCallback = null;
}
+ Slogf.i(TAG_EVS, "Last stream client has been disconnected.");
+
+ // Notify the client that the stream has ended.
+ if (callback != null) {
+ notifyStreamStopped(callback);
+ }
+ // Request to stop a video stream if it is active.
+ mHalWrapper.requestToStopVideoStream();
+ } catch (RuntimeException e) {
+ Slogf.w(TAG_EVS, Log.getStackTraceString(e));
+ } finally {
// We simply drop all buffer records; the native method will return all pending buffers
// to the native Extended System View service if it is alive.
synchronized (mBufferRecords) {
@@ -1261,6 +1273,9 @@ public final class CarEvsService extends android.car.evs.ICarEvsService.Stub
// Cancel a pending message to check a request timeout
mHandler.removeCallbacks(mActivityRequestTimeoutRunnable);
+
+ // Close current camera
+ mHalWrapper.closeCamera();
}
}
diff --git a/service/src/com/android/car/oem/CarOemAudioFocusProxyService.java b/service/src/com/android/car/oem/CarOemAudioFocusProxyService.java
index 21b5e4c69c..ae55a45cb1 100644
--- a/service/src/com/android/car/oem/CarOemAudioFocusProxyService.java
+++ b/service/src/com/android/car/oem/CarOemAudioFocusProxyService.java
@@ -23,6 +23,7 @@ import android.os.RemoteException;
import com.android.car.CarLog;
import java.util.List;
+import java.util.Optional;
/**
* Provides functionality of the OEM Audio Focus Service.
@@ -55,7 +56,6 @@ public final class CarOemAudioFocusProxyService {
"audioFocusChanged call received RemoteException- currentFocusHolders:%s, "
+ "currentFocusLosers:%s, ZoneId: %s, , calling to crash CarService",
currentFocusHolders, currentFocusLosers, zoneId);
- mHelper.crashCarService("Remote Exception");
}
});
}
diff --git a/service/src/com/android/car/oem/CarOemProxyService.java b/service/src/com/android/car/oem/CarOemProxyService.java
index 1eec505c58..5624267f9b 100644
--- a/service/src/com/android/car/oem/CarOemProxyService.java
+++ b/service/src/com/android/car/oem/CarOemProxyService.java
@@ -381,7 +381,6 @@ public final class CarOemProxyService implements CarServiceBase {
} catch (RemoteException ex) {
Slogf.e(TAG, "Binder call received RemoteException, calling to crash CarService",
ex);
- mHelper.crashCarService("Remote Exception");
}
});
waitForOemServiceReady();
diff --git a/service/src/com/android/car/oem/CarOemProxyServiceHelper.java b/service/src/com/android/car/oem/CarOemProxyServiceHelper.java
index 1360435c78..9f194f0bec 100644
--- a/service/src/com/android/car/oem/CarOemProxyServiceHelper.java
+++ b/service/src/com/android/car/oem/CarOemProxyServiceHelper.java
@@ -22,8 +22,6 @@ import android.content.Context;
import android.content.res.Resources;
import android.os.Binder;
import android.os.Process;
-import android.os.RemoteException;
-import android.os.SystemClock;
import android.util.ArrayMap;
import android.util.Log;
@@ -32,6 +30,7 @@ import com.android.car.R;
import com.android.car.internal.util.IndentingPrintWriter;
import com.android.internal.annotations.GuardedBy;
+import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@@ -64,7 +63,7 @@ public final class CarOemProxyServiceHelper {
private static final int MAX_CIRCULAR_CALLS_PER_CALLER = 5;
private static final int MAX_CIRCULAR_CALL_TOTAL = 10;
private static final int MAX_THREAD_POOL_SIZE = 16;
- private static final int MIN_THREAD_POOL_SIZE = 18;
+ private static final int MIN_THREAD_POOL_SIZE = 8;
private final Object mLock = new Object();
@@ -133,7 +132,7 @@ public final class CarOemProxyServiceHelper {
/**
* Does timed call to the OEM service and returns default value if OEM service timed out or
- * throws any Exception.
+ * throws any other Exception.
*
* <p>Caller would not know if the call to OEM service timed out or returned a valid value which
* could be same as defaultValue. It is preferred way to call OEM service if the defaultValue is
@@ -144,7 +143,7 @@ public final class CarOemProxyServiceHelper {
* @param callable containing binder call.
* @param defaultValue to be returned if call timeout or any other exception is thrown.
*
- * @return Result of the binder call. Callable result can be null.
+ * @return Result of the binder call. Result can be null.
*/
@Nullable
public <T> T doBinderTimedCallWithDefaultValue(String callerTag, Callable<T> callable,
@@ -159,6 +158,9 @@ public final class CarOemProxyServiceHelper {
try {
return result.get(mRegularCallTimeoutMs, TimeUnit.MILLISECONDS);
} catch (Exception e) {
+ if (e instanceof InterruptedException) {
+ Thread.currentThread().interrupt(); // Restore the interrupted status
+ }
Slogf.w(TAG, "Binder call threw an exception. Return default value %s for caller "
+ "tag: %s", defaultValue, callerTag);
return defaultValue;
@@ -171,19 +173,17 @@ public final class CarOemProxyServiceHelper {
/**
* Does timed call to the OEM service and throws timeout exception.
*
- * <p>Throws timeout exception if OEM service timed out. If OEM service throw RemoteException it
- * would crash the CarService. If OemService throws InterruptedException or ExecutionException
- * (except RemoteException), and elapsed time is less than timeout, callable would be retried;
- * if elapsed time is more than timeout then timeout exception will be thrown.
+ * <p>Throws timeout exception if OEM service times out. If OEM service throw any other
+ * exception, it is wrapped in Timeout exception.
*
* @param <T> Type of the result.
* @param callerTag is tag from the caller. Used for tracking circular calls per binder.
* @param callable containing binder call.
* @param timeoutMs in milliseconds.
*
- * @return result of the binder call. Callable result can be null.
+ * @return result of the binder call. Result can be null.
*
- * @throws TimeoutException if call timed out.
+ * @throws TimeoutException if call times out or throws any other exception.
*/
@Nullable
public <T> T doBinderTimedCallWithTimeout(String callerTag, Callable<T> callable,
@@ -194,37 +194,111 @@ public final class CarOemProxyServiceHelper {
}
startTracking(callerTag);
try {
- long startTime = SystemClock.uptimeMillis();
- long remainingTime = timeoutMs;
- Future<T> result;
- while (remainingTime > 0) {
- result = mThreadPool.submit(callable);
- try {
- return result.get(remainingTime, TimeUnit.MILLISECONDS);
- } catch (InterruptedException e) {
+ Future<T> result = mThreadPool.submit(callable);
+ try {
+ return result.get(timeoutMs, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException | ExecutionException e) {
+ Slogf.w(TAG, "Binder call received Exception", e);
+ if (e instanceof InterruptedException) {
Thread.currentThread().interrupt(); // Restore the interrupted status
- Slogf.w(TAG, "Binder call received InterruptedException", e);
- } catch (ExecutionException e) {
- if (e.getCause() instanceof RemoteException) {
- Slogf.e(TAG, "Binder call received RemoteException, calling to crash "
- + "CarService");
- crashCarService("Remote Exception");
- }
- Slogf.w(TAG, "Binder call received ExecutionException", e);
}
- remainingTime = timeoutMs - (SystemClock.uptimeMillis() - startTime);
+ // Throw timeout exception even for other exception as caller knows how to handle
+ // timeout exception in this case.
+ TimeoutException exception = new TimeoutException();
+ exception.initCause(e);
+ throw exception;
+ }
+ } finally {
+ stopTracking(callerTag);
+ }
+ }
- if (remainingTime > 0) {
- Slogf.w(TAG, "Binder call threw exception. Call would be retried with "
- + "remainingTime: %s", remainingTime);
+ /**
+ * Does timed call to OEM service with two different timeouts.
+ *
+ * <p>If OEM service returns before the {@code defaultTimeoutMs}, it would return OEM response.
+ * After {@code defaultTimeoutMs}, call will return {@link Optional#empty()} and queue a tracker
+ * for OEM service response asynchronously. Tracker would wait for {@code mCrashCallTimeoutMs}
+ * for OEM service to response. If OEM service respond before {code mCrashCallTimeoutMs},
+ * callback {@code CallbackForDelayedResult} will be used to post the OEM results on the
+ * original caller. If OEM service doesn't respond within {code mCrashCallTimeoutMs}, CarService
+ * and OEM service both will be crashed.
+ *
+ * <p>This call should be used if it is okay to quickly check for results from OEM Service, and
+ * it is possible to incorporate results from OEM service if delivered late.
+ *
+ * <p>If the binder to OEM service throw any exception during short timeout, it would be ignored
+ * and {@link Optional#empty()} is returned. If the binder to OEM service throw timeout
+ * exception after the longer timeout, it would rash the CarService and OEM Service. If the
+ * binder to OEM service throw any other exception during longer timeout, it would be ignored
+ * and {@link Optional#empty()} is returned.
+ *
+ * @param <T> Type of the result.
+ * @param callerTag is tag from the caller. Used for tracking circular calls per binder.
+ * @param callable containing binder call.
+ * @param defaultTimeoutMs in milliseconds.
+ * @param callback for the delayed results. Callback waits for {@code mCrashCallTimeoutMs}.
+ *
+ * @return Optional carrying result of the binder call. Optional can be empty.
+ */
+ public <T> Optional<T> doBinderCallWithDefaultValueAndDelayedWaitAndCrash(String callerTag,
+ Callable<T> callable, long defaultTimeoutMs,
+ CallbackForDelayedResult<T> callback) {
+ if (DBG) {
+ Slogf.d(TAG, "Received doBinderCallWithDefaultValueAndDelayedWaitAndCrash call for"
+ + " caller tag: %s.", callerTag);
+ }
+ startTracking(callerTag);
+ try {
+ Future<T> result = mThreadPool.submit(callable);
+ try {
+ return Optional.ofNullable(result.get(defaultTimeoutMs, TimeUnit.MILLISECONDS));
+ } catch (Exception e) {
+ if (e instanceof InterruptedException) {
+ Thread.currentThread().interrupt(); // Restore the interrupted status
}
+ Slogf.e(TAG, "Binder call received Exception", e);
}
- Slogf.w(TAG, "Binder called timeout. throwing timeout exception for caller tag: %s",
- callerTag);
- throw new TimeoutException("Binder called timeout. Timeout: " + timeoutMs + "ms");
+
+ // Queue for long wait time check
+ mThreadPool.execute(() -> {
+ startTracking(callerTag);
+ try {
+ callback.onDelayedResults(
+ Optional.ofNullable(
+ result.get(mCrashCallTimeoutMs, TimeUnit.MILLISECONDS)));
+ } catch (TimeoutException e) {
+ Slogf.e(TAG, "Binder call received TimeoutException", e);
+ crashCarService("TimeoutException");
+ } catch (InterruptedException | ExecutionException e) {
+ if (e instanceof InterruptedException) {
+ Thread.currentThread().interrupt(); // Restore the interrupted status
+ }
+ Slogf.e(TAG, "Binder call received Eexception", e);
+ callback.onDelayedResults(Optional.empty());
+ } finally {
+ stopTracking(callerTag);
+ }
+ });
} finally {
stopTracking(callerTag);
}
+
+ return Optional.empty();
+ }
+
+ /**
+ * Callback for getting OEM results after default timeout.
+ *
+ * @param <T> Type of the result.
+ */
+ public interface CallbackForDelayedResult<T> {
+ /**
+ * Invoked when OEM results are received after default timeout.
+ *
+ * @param result received from OEM service
+ */
+ void onDelayedResults(Optional<T> result);
}
private void stopTracking(String callerTag) {
@@ -285,58 +359,39 @@ public final class CarOemProxyServiceHelper {
* Does timed call to the OEM service and crashes the OEM and Car Service if call is not served
* within time.
*
- * <p>If OEM service throw RemoteException, it would crash the CarService. If OemService throws
- * InterruptedException or ExecutionException (except RemoteException), and elapsed time is less
- * than mCrashTimeout, callable would be retried; if elapsed time is more than timeout then
- * crashes the OEM and Car Service.
+ * <p>If OEM service throw TimeoutException, it would crash the CarService and OEM service. If
+ * OemService throws any other exception, {@link Optional#empty()} is returned.
*
* @param <T> Type of the result.
* @param callerTag is tag from the caller. Used for tracking circular calls per binder.
* @param callable containing binder call.
*
- * @return result of the binder call. Callable result can be null.
+ * @return Optional carrying result of the binder call. Optional can be empty.
*/
- @Nullable
- public <T> T doBinderCallWithTimeoutCrash(String callerTag, Callable<T> callable) {
+ public <T> Optional<T> doBinderCallWithTimeoutCrash(String callerTag, Callable<T> callable) {
if (DBG) {
Slogf.d(TAG, "Received doBinderCallWithTimeoutCrash call for caller tag: %s.",
callerTag);
}
startTracking(callerTag);
try {
- long startTime = SystemClock.uptimeMillis();
- long remainingTime = mCrashCallTimeoutMs;
- Future<T> result;
- while (remainingTime > 0) {
- result = mThreadPool.submit(callable);
- try {
- return result.get(remainingTime, TimeUnit.MILLISECONDS);
- } catch (TimeoutException e) {
- Slogf.e(TAG, "Binder call timeout, calling to crash CarService");
- crashCarService("Timeout Exception");
- } catch (InterruptedException e) {
+ Future<T> result = mThreadPool.submit(callable);
+ try {
+ return Optional.ofNullable(result.get(mCrashCallTimeoutMs, TimeUnit.MILLISECONDS));
+ } catch (TimeoutException e) {
+ Slogf.e(TAG, "Binder call received Exception", e);
+ crashCarService("TimeoutException");
+ } catch (InterruptedException | ExecutionException e) {
+ if (e instanceof InterruptedException) {
Thread.currentThread().interrupt(); // Restore the interrupted status
- Slogf.w(TAG, "Binder call received InterruptedException", e);
- } catch (ExecutionException e) {
- if (e.getCause() instanceof RemoteException) {
- Slogf.e(TAG, "Binder call received RemoteException, calling to crash "
- + "CarService", e);
- crashCarService("Remote Exception");
- }
- Slogf.w(TAG, "Binder call received ExecutionException", e);
- }
- remainingTime = mCrashCallTimeoutMs - (SystemClock.uptimeMillis() - startTime);
- if (remainingTime > 0) {
- Slogf.w(TAG, "Binder call threw exception. Call would be retried with "
- + "remainingTime:%s for caller tag: %s", remainingTime, callerTag);
}
+ Slogf.e(TAG, "Binder call received Exception", e);
+ return Optional.empty();
}
} finally {
stopTracking(callerTag);
}
- Slogf.e(TAG, "Binder called timeout. calling to crash CarService");
- crashCarService("Timeout Exception");
throw new AssertionError("Should not return from crashCarService");
}
@@ -362,6 +417,9 @@ public final class CarOemProxyServiceHelper {
try {
result.get(mRegularCallTimeoutMs, TimeUnit.MILLISECONDS);
} catch (Exception e) {
+ if (e instanceof InterruptedException) {
+ Thread.currentThread().interrupt(); // Restore the interrupted status
+ }
Slogf.e(TAG, "Exception while running a runnable for caller tag: " + callerTag,
e);
}
diff --git a/service/src/com/android/car/telemetry/publisher/ConnectivityPublisher.java b/service/src/com/android/car/telemetry/publisher/ConnectivityPublisher.java
index f161cd5d42..ca4ef84280 100644
--- a/service/src/com/android/car/telemetry/publisher/ConnectivityPublisher.java
+++ b/service/src/com/android/car/telemetry/publisher/ConnectivityPublisher.java
@@ -204,7 +204,7 @@ public class ConnectivityPublisher extends AbstractPublisher {
continue;
}
PersistableBundle data = previousSessionData.getPersistableBundle(key);
- if (!data.containsKey(SessionAnnotation.ANNOTATION_BUNDLE_KEY_SESSION_ID)) {
+ if (!data.containsKey(Constants.ANNOTATION_BUNDLE_KEY_SESSION_ID)) {
Slogf.e(CarLog.TAG_TELEMETRY,
"Session annotations is unexpectedly missing. Skipping this batch.");
continue;
diff --git a/service/src/com/android/car/telemetry/publisher/Constants.java b/service/src/com/android/car/telemetry/publisher/Constants.java
index 4dc05facd5..53db1700d3 100644
--- a/service/src/com/android/car/telemetry/publisher/Constants.java
+++ b/service/src/com/android/car/telemetry/publisher/Constants.java
@@ -30,11 +30,24 @@ package com.android.car.telemetry.publisher;
* populated.
*/
public final class Constants {
+ // Session Annotations
+ public static final String ANNOTATION_BUNDLE_KEY_SESSION_ID = "session.sessionId";
+ public static final String ANNOTATION_BUNDLE_KEY_SESSION_STATE = "session.sessionState";
+ public static final String ANNOTATION_BUNDLE_KEY_CREATED_AT_SINCE_BOOT_MILLIS =
+ "session.createdAtSinceBootMillis";
+ public static final String ANNOTATION_BUNDLE_KEY_CREATED_AT_MILLIS = "session.createdAtMillis";
+ public static final String ANNOTATION_BUNDLE_KEY_BOOT_REASON = "session.bootReason";
+
+ // StatsPublisher
+ public static final String STATS_BUNDLE_KEY_PREFIX = "stats.";
+ public static final String STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP = "stats.elapsed_timestamp_nanos";
+
// CarTelemetrydPublisher
public static final String CAR_TELEMETRYD_BUNDLE_KEY_ID = "ct.id";
public static final String CAR_TELEMETRYD_BUNDLE_KEY_CONTENT = "ct.content";
// MemoryPublisher
+ public static final String MEMORY_BUNDLE_KEY_PREFIX = "mem.";
public static final String MEMORY_BUNDLE_KEY_MEMINFO = "mem.meminfo";
public static final String MEMORY_BUNDLE_KEY_TIMESTAMP = "mem.timestamp_millis";
public static final String MEMORY_BUNDLE_KEY_TOTAL_SWAPPABLE_PSS = "mem.total_swappable_pss";
diff --git a/service/src/com/android/car/telemetry/publisher/MemoryPublisher.java b/service/src/com/android/car/telemetry/publisher/MemoryPublisher.java
index 0d6cc34d4c..7d30fe0ae2 100644
--- a/service/src/com/android/car/telemetry/publisher/MemoryPublisher.java
+++ b/service/src/com/android/car/telemetry/publisher/MemoryPublisher.java
@@ -62,23 +62,23 @@ import java.util.Set;
*
* <p>The published data format is:
* <code>
- * - timestamp_millis : long
- * - meminfo : string (device meminfo)
+ * - mem.timestamp_millis : long
+ * - mem.meminfo : string (device meminfo)
* - package_name:uid:process_name : PersistableBundle (parsed from Debug.MemInfo, listed below)
- * - summary.total-pss : int
- * - summary.java-heap : int
- * - summary.native-heap : int
- * - summary.stack=44 : int
- * - summary.system : int
- * - summary.code : int
- * - summary.graphics=0,
- * - summary.private-other : int
- * - summary.total-swap=31904
- * - total_shared_clean : int
- * - total_shared_dirty : int
- * - total_private_clean : int
- * - total_private_dirty : int
- * - total_swappable_pss : int
+ * - mem.summary.total-pss : int
+ * - mem.summary.java-heap : int
+ * - mem.summary.native-heap : int
+ * - mem.summary.stack : int
+ * - mem.summary.system : int
+ * - mem.summary.code : int
+ * - mem.summary.graphics : int
+ * - mem.summary.private-other : int
+ * - mem.summary.total-swap : int
+ * - mem.total_shared_clean : int
+ * - mem.total_shared_dirty : int
+ * - mem.total_private_clean : int
+ * - mem.total_private_dirty : int
+ * - mem.total_swappable_pss : int
* </code>
*/
public class MemoryPublisher extends AbstractPublisher {
@@ -327,7 +327,8 @@ public class MemoryPublisher extends AbstractPublisher {
Integer.valueOf(mi.getTotalSharedClean()));
Map<String, String> map = mi.getMemoryStats();
for (Map.Entry<String, String> entry : map.entrySet()) {
- processMeminfoBundle.putInt(entry.getKey(), Integer.valueOf(entry.getValue()));
+ processMeminfoBundle.putInt(Constants.MEMORY_BUNDLE_KEY_PREFIX + entry.getKey(),
+ Integer.valueOf(entry.getValue()));
}
data.putPersistableBundle(bundleKeys.get(i), processMeminfoBundle);
}
diff --git a/service/src/com/android/car/telemetry/publisher/statsconverters/AbstractAtomConverter.java b/service/src/com/android/car/telemetry/publisher/statsconverters/AbstractAtomConverter.java
index c01d4836f4..14d969dfe0 100644
--- a/service/src/com/android/car/telemetry/publisher/statsconverters/AbstractAtomConverter.java
+++ b/service/src/com/android/car/telemetry/publisher/statsconverters/AbstractAtomConverter.java
@@ -16,6 +16,8 @@
package com.android.car.telemetry.publisher.statsconverters;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_PREFIX;
+
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.PersistableBundle;
@@ -123,7 +125,7 @@ public abstract class AbstractAtomConverter<T extends MessageLite> {
valueList.add(atomFieldAccessor.getField(atomData));
}
setPersistableBundleArrayField(
- atomFieldAccessor.getFieldName(), valueList, bundle);
+ createBundleKey(atomFieldAccessor.getFieldName()), valueList, bundle);
}
}
// Check if there are dimension fields needing conversion
@@ -139,7 +141,7 @@ public abstract class AbstractAtomConverter<T extends MessageLite> {
valueList.add(extractDimensionsValue(dvList.get(i), hashToStringMap));
}
setPersistableBundleArrayField(
- getAtomFieldAccessorMap().get(fieldId).getFieldName(),
+ createBundleKey(getAtomFieldAccessorMap().get(fieldId).getFieldName()),
valueList,
bundle);
}
@@ -227,4 +229,16 @@ public abstract class AbstractAtomConverter<T extends MessageLite> {
bundle.putDoubleArray(name, doubleArray);
}
}
+
+ /**
+ * Creates the bundle key string for a metric field.
+ *
+ * The bundle key differs from the original metric field name by having a namespace prefix.
+ *
+ * @param metricFieldName the metric field name string.
+ * @return the bundle key string.
+ */
+ private String createBundleKey(String metricFieldName) {
+ return STATS_BUNDLE_KEY_PREFIX + metricFieldName;
+ }
}
diff --git a/service/src/com/android/car/telemetry/publisher/statsconverters/EventMetricDataConverter.java b/service/src/com/android/car/telemetry/publisher/statsconverters/EventMetricDataConverter.java
index 38be9405a4..ad72e73edd 100644
--- a/service/src/com/android/car/telemetry/publisher/statsconverters/EventMetricDataConverter.java
+++ b/service/src/com/android/car/telemetry/publisher/statsconverters/EventMetricDataConverter.java
@@ -16,6 +16,8 @@
package com.android.car.telemetry.publisher.statsconverters;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP;
+
import android.annotation.NonNull;
import android.os.PersistableBundle;
@@ -29,8 +31,6 @@ import java.util.List;
* Class for converting event metric data to {@link PersistableBundle} compatible format.
*/
public class EventMetricDataConverter {
- static final String ELAPSED_TIME_NANOS = "elapsed_timestamp_nanos";
-
/**
* Converts a list of {@link StatsLogProto.EventMetricData} to {@link PersistableBundle} format
* such that along with the elapsed time array each field of the atom has an associated array
@@ -67,7 +67,7 @@ public class EventMetricDataConverter {
for (int i = 0; i < elapsedTimes.size(); ++i) {
elapsedTimesArray[i] = elapsedTimes.get(i);
}
- bundle.putLongArray(ELAPSED_TIME_NANOS, elapsedTimesArray);
+ bundle.putLongArray(STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP, elapsedTimesArray);
return bundle;
}
}
diff --git a/service/src/com/android/car/telemetry/publisher/statsconverters/GaugeMetricDataConverter.java b/service/src/com/android/car/telemetry/publisher/statsconverters/GaugeMetricDataConverter.java
index cc29aa4762..d260e04982 100644
--- a/service/src/com/android/car/telemetry/publisher/statsconverters/GaugeMetricDataConverter.java
+++ b/service/src/com/android/car/telemetry/publisher/statsconverters/GaugeMetricDataConverter.java
@@ -16,6 +16,8 @@
package com.android.car.telemetry.publisher.statsconverters;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP;
+
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.PersistableBundle;
@@ -34,8 +36,6 @@ import java.util.Map;
* Class for converting gauge metric data to {@link PersistableBundle} compatible format.
*/
public class GaugeMetricDataConverter {
- static final String ELAPSED_TIME_NANOS = "elapsed_timestamp_nanos";
-
/**
* Converts a list of {@link StatsLogProto.GaugeMetricData} to {@link PersistableBundle}
* format such that along with the elapsed time array each field of the atom has an associated
@@ -97,7 +97,7 @@ public class GaugeMetricDataConverter {
for (int i = 0; i < elapsedTimes.size(); ++i) {
elapsedTimesArray[i] = elapsedTimes.get(i);
}
- bundle.putLongArray(ELAPSED_TIME_NANOS, elapsedTimesArray);
+ bundle.putLongArray(STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP, elapsedTimesArray);
return bundle;
}
}
diff --git a/service/src/com/android/car/telemetry/sessioncontroller/SessionAnnotation.java b/service/src/com/android/car/telemetry/sessioncontroller/SessionAnnotation.java
index 7e4d44c315..d24e06d57e 100644
--- a/service/src/com/android/car/telemetry/sessioncontroller/SessionAnnotation.java
+++ b/service/src/com/android/car/telemetry/sessioncontroller/SessionAnnotation.java
@@ -19,6 +19,8 @@ package com.android.car.telemetry.sessioncontroller;
import android.annotation.NonNull;
import android.os.PersistableBundle;
+import com.android.car.telemetry.publisher.Constants;
+
import java.util.Objects;
/**
@@ -27,13 +29,6 @@ import java.util.Objects;
* respective public fields are equal by value.
*/
public class SessionAnnotation {
- public static final String ANNOTATION_BUNDLE_KEY_SESSION_ID = "sessionId";
- public static final String ANNOTATION_BUNDLE_KEY_SESSION_STATE = "sessionState";
- public static final String ANNOTATION_BUNDLE_KEY_CREATED_AT_SINCE_BOOT_MILLIS =
- "createdAtSinceBootMillis";
- public static final String ANNOTATION_BUNDLE_KEY_CREATED_AT_MILLIS = "createdAtMillis";
- public static final String ANNOTATION_BUNDLE_KEY_BOOT_REASON = "bootReason";
-
public final int sessionId;
public final int sessionState;
public final long createdAtSinceBootMillis; // Milliseconds since boot.
@@ -66,15 +61,15 @@ public class SessionAnnotation {
public String toString() {
return new StringBuilder()
.append("{")
- .append(ANNOTATION_BUNDLE_KEY_SESSION_ID).append(": ")
+ .append(Constants.ANNOTATION_BUNDLE_KEY_SESSION_ID).append(": ")
.append(sessionId).append(", ")
- .append(ANNOTATION_BUNDLE_KEY_SESSION_STATE).append(": ")
+ .append(Constants.ANNOTATION_BUNDLE_KEY_SESSION_STATE).append(": ")
.append(sessionState).append(", ")
- .append(ANNOTATION_BUNDLE_KEY_CREATED_AT_SINCE_BOOT_MILLIS).append(": ")
+ .append(Constants.ANNOTATION_BUNDLE_KEY_CREATED_AT_SINCE_BOOT_MILLIS).append(": ")
.append(createdAtSinceBootMillis).append(", ")
- .append(ANNOTATION_BUNDLE_KEY_CREATED_AT_MILLIS).append(": ")
+ .append(Constants.ANNOTATION_BUNDLE_KEY_CREATED_AT_MILLIS).append(": ")
.append(createdAtMillis).append(", ")
- .append(ANNOTATION_BUNDLE_KEY_BOOT_REASON).append(": ")
+ .append(Constants.ANNOTATION_BUNDLE_KEY_BOOT_REASON).append(": ")
.append(bootReason)
.append("}")
.toString();
@@ -107,12 +102,12 @@ public class SessionAnnotation {
* @param bundle A {@link PersistableBundle} that we want to get the annotations to.
*/
public void addAnnotationsToBundle(@NonNull PersistableBundle bundle) {
- bundle.putInt(ANNOTATION_BUNDLE_KEY_SESSION_ID, sessionId);
- bundle.putInt(ANNOTATION_BUNDLE_KEY_SESSION_STATE, sessionState);
- bundle.putLong(ANNOTATION_BUNDLE_KEY_CREATED_AT_SINCE_BOOT_MILLIS,
+ bundle.putInt(Constants.ANNOTATION_BUNDLE_KEY_SESSION_ID, sessionId);
+ bundle.putInt(Constants.ANNOTATION_BUNDLE_KEY_SESSION_STATE, sessionState);
+ bundle.putLong(Constants.ANNOTATION_BUNDLE_KEY_CREATED_AT_SINCE_BOOT_MILLIS,
createdAtSinceBootMillis);
- bundle.putLong(ANNOTATION_BUNDLE_KEY_CREATED_AT_MILLIS, createdAtMillis);
- bundle.putString(ANNOTATION_BUNDLE_KEY_BOOT_REASON, bootReason);
+ bundle.putLong(Constants.ANNOTATION_BUNDLE_KEY_CREATED_AT_MILLIS, createdAtMillis);
+ bundle.putString(Constants.ANNOTATION_BUNDLE_KEY_BOOT_REASON, bootReason);
}
}
diff --git a/tests/carservice_unit_test/src/com/android/car/hardware/power/CarPowerManagerUnitTest.java b/tests/carservice_unit_test/src/com/android/car/hardware/power/CarPowerManagerUnitTest.java
index ac7b5ba4a6..0b522d7e8c 100644
--- a/tests/carservice_unit_test/src/com/android/car/hardware/power/CarPowerManagerUnitTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/hardware/power/CarPowerManagerUnitTest.java
@@ -74,6 +74,7 @@ import com.android.car.systeminterface.SystemInterface;
import com.android.car.systeminterface.SystemStateInterface;
import com.android.car.test.utils.TemporaryFile;
import com.android.car.user.CarUserService;
+import com.android.compatibility.common.util.PollingCheck;
import com.android.internal.annotations.GuardedBy;
import org.junit.After;
@@ -337,8 +338,10 @@ public final class CarPowerManagerUnitTest extends AbstractExtendedMockitoTestCa
mCarPowerManager.addPowerPolicyListener(mExecutor, filterLocation, listenerLocation);
mCarPowerManager.applyPowerPolicy(policyId);
- assertThat(listenerAudio.getCurrentPolicyId()).isEqualTo(policyId);
- assertThat(listenerWifi.getCurrentPolicyId()).isEqualTo(policyId);
+ assertPowerPolicyId(listenerAudio, policyId, "Current policy ID of listenerAudio is not "
+ + policyId);
+ assertPowerPolicyId(listenerWifi, policyId, "Current policy ID of listenerWifi is not "
+ + policyId);
assertThat(listenerLocation.getCurrentPolicyId()).isNull();
}
@@ -378,7 +381,8 @@ public final class CarPowerManagerUnitTest extends AbstractExtendedMockitoTestCa
public void testRemovePowerPolicyListener() throws Exception {
grantPowerPolicyPermission();
- applyInitialPolicyForTest(/* policyName= */ "audio_off", /* enabledComponents= */
+ String initialPolicyId = "audio_off";
+ applyInitialPolicyForTest(initialPolicyId, /* enabledComponents= */
new String[]{}, /* disabledComponents= */ new String[]{"AUDIO"});
String policyId = "audio_on_wifi_off";
@@ -393,8 +397,12 @@ public final class CarPowerManagerUnitTest extends AbstractExtendedMockitoTestCa
mCarPowerManager.removePowerPolicyListener(listenerOne);
mCarPowerManager.applyPowerPolicy(policyId);
- assertThat(listenerOne.getCurrentPolicyId()).isNull();
- assertThat(listenerTwo.getCurrentPolicyId()).isEqualTo(policyId);
+ String receivedPolicyId = listenerOne.getCurrentPolicyId();
+ assertWithMessage("Policy ID received after removing listeners")
+ .that(receivedPolicyId == null || receivedPolicyId.equals(initialPolicyId))
+ .isTrue();
+ assertPowerPolicyId(listenerTwo, policyId, "Current policy ID of listenerTwo is not "
+ + policyId);
}
private void applyInitialPolicyForTest(String policyName, String[] enabledComponents,
@@ -501,6 +509,12 @@ public final class CarPowerManagerUnitTest extends AbstractExtendedMockitoTestCa
referenceStates).inOrder();
}
+ private static void assertPowerPolicyId(MockedPowerPolicyListener listener, String policyId,
+ String errorMsg) throws Exception {
+ PollingCheck.check(errorMsg, WAIT_TIMEOUT_MS,
+ () -> policyId.equals(listener.getCurrentPolicyId()));
+ }
+
private static boolean isCompletionAllowed(@CarPowerManager.CarPowerState int state) {
switch (state) {
case CarPowerManager.STATE_PRE_SHUTDOWN_PREPARE:
diff --git a/tests/carservice_unit_test/src/com/android/car/oem/CarOemProxyServiceHelperTest.java b/tests/carservice_unit_test/src/com/android/car/oem/CarOemProxyServiceHelperTest.java
index bf6af20ec3..e71c4cde6f 100644
--- a/tests/carservice_unit_test/src/com/android/car/oem/CarOemProxyServiceHelperTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/oem/CarOemProxyServiceHelperTest.java
@@ -25,16 +25,21 @@ import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.when;
import android.car.test.mocks.AbstractExtendedMockitoTestCase;
+import android.car.test.mocks.JavaMockitoHelper;
import android.content.Context;
import android.content.res.Resources;
import android.os.Process;
+import android.os.RemoteException;
import com.android.car.R;
+import com.android.car.oem.CarOemProxyServiceHelper.CallbackForDelayedResult;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
+import java.util.Optional;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeoutException;
public final class CarOemProxyServiceHelperTest extends AbstractExtendedMockitoTestCase {
@@ -95,8 +100,9 @@ public final class CarOemProxyServiceHelperTest extends AbstractExtendedMockitoT
@Test
public void testDoBinderCallTimeoutCrash_returnCalculatedValue() throws Exception {
- assertThat(mCarOemProxyServiceHelper.doBinderCallWithTimeoutCrash(CALLER_TAG, () -> 42))
- .isEqualTo(42);
+ assertThat(
+ mCarOemProxyServiceHelper.doBinderCallWithTimeoutCrash(CALLER_TAG, () -> 42).get())
+ .isEqualTo(42);
}
@Test
@@ -117,6 +123,36 @@ public final class CarOemProxyServiceHelperTest extends AbstractExtendedMockitoT
}
@Test
+ public void testDoBinderCallTimeoutCrash_withExecutionException() throws Exception {
+ assertThat(mCarOemProxyServiceHelper.doBinderCallWithTimeoutCrash(CALLER_TAG, () -> {
+ if (true) {
+ throw new RemoteException();
+ }
+ return 42;
+ }).isEmpty()).isTrue();
+ }
+
+ @Test
+ public void testDoBinderCallWithDefaultValueAndDelayedWaitAndCrash() throws Exception {
+ CountDownLatch latch = new CountDownLatch(1);
+ int delayFromOemCallMs = 100;
+ CallbackForDelayedResult<String> callback = (result) -> latch.countDown();
+
+ Optional<String> result = mCarOemProxyServiceHelper
+ .doBinderCallWithDefaultValueAndDelayedWaitAndCrash(
+ CALLER_TAG,
+ () -> {
+ Thread.sleep(delayFromOemCallMs);
+ return "result";
+ },
+ /* defaultTimeoutMs= */ 10,
+ callback);
+ assertThat(result.isEmpty()).isTrue();
+ JavaMockitoHelper.await(latch, 1000); //latch would be waiting at max delayFromOemCallMs
+ assertThat(latch.getCount()).isEqualTo(0);
+ }
+
+ @Test
public void testCrashCarService() {
doAnswer(inv -> {
throw new IllegalStateException();
diff --git a/tests/carservice_unit_test/src/com/android/car/power/CarPowerManagementServiceUnitTest.java b/tests/carservice_unit_test/src/com/android/car/power/CarPowerManagementServiceUnitTest.java
index 734f70b018..67a55ed23a 100644
--- a/tests/carservice_unit_test/src/com/android/car/power/CarPowerManagementServiceUnitTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/power/CarPowerManagementServiceUnitTest.java
@@ -91,7 +91,6 @@ import java.io.IOException;
import java.io.StringWriter;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
@@ -626,7 +625,8 @@ public final class CarPowerManagementServiceUnitTest extends AbstractExtendedMoc
waitForPowerPolicy(policyId);
assertThat(mPowerComponentHandler.getAccumulatedPolicy().getPolicyId()).isEqualTo(policyId);
- assertThat(listenerToWait.getCurrentPowerPolicy()).isNotNull();
+ PollingCheck.check("Current power policy of listener is null", WAIT_TIMEOUT_LONG_MS,
+ () -> listenerToWait.getCurrentPowerPolicy() != null);
assertThat(mPowerPolicyDaemon.getLastNotifiedPolicyId()).isEqualTo(policyId);
}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/CarTelemetrydPublisherTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/CarTelemetrydPublisherTest.java
index 503cbeafbb..cadfbb4caa 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/CarTelemetrydPublisherTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/CarTelemetrydPublisherTest.java
@@ -76,11 +76,11 @@ public class CarTelemetrydPublisherTest extends AbstractExtendedMockitoTestCase
private static final SessionAnnotation SESSION_ANNOTATION_BEGIN_1 =
new SessionAnnotation(1, SessionController.STATE_ENTER_DRIVING_SESSION, 0, 0, "");
private static final String[] SESSION_ANNOTATION_KEYS =
- {SessionAnnotation.ANNOTATION_BUNDLE_KEY_SESSION_ID,
- SessionAnnotation.ANNOTATION_BUNDLE_KEY_BOOT_REASON,
- SessionAnnotation.ANNOTATION_BUNDLE_KEY_SESSION_STATE,
- SessionAnnotation.ANNOTATION_BUNDLE_KEY_CREATED_AT_MILLIS,
- SessionAnnotation.ANNOTATION_BUNDLE_KEY_CREATED_AT_SINCE_BOOT_MILLIS};
+ {Constants.ANNOTATION_BUNDLE_KEY_SESSION_ID,
+ Constants.ANNOTATION_BUNDLE_KEY_BOOT_REASON,
+ Constants.ANNOTATION_BUNDLE_KEY_SESSION_STATE,
+ Constants.ANNOTATION_BUNDLE_KEY_CREATED_AT_MILLIS,
+ Constants.ANNOTATION_BUNDLE_KEY_CREATED_AT_SINCE_BOOT_MILLIS};
private final FakeHandlerWrapper mFakeHandlerWrapper =
new FakeHandlerWrapper(Looper.getMainLooper(), FakeHandlerWrapper.Mode.IMMEDIATE);
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/ConnectivityPublisherTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/ConnectivityPublisherTest.java
index be142d084f..93ebc907cb 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/ConnectivityPublisherTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/ConnectivityPublisherTest.java
@@ -195,8 +195,8 @@ public class ConnectivityPublisherTest {
return false;
}
- return savedResult.containsKey(SessionAnnotation.ANNOTATION_BUNDLE_KEY_SESSION_ID)
- && savedResult.getInt(SessionAnnotation.ANNOTATION_BUNDLE_KEY_SESSION_ID)
+ return savedResult.containsKey(Constants.ANNOTATION_BUNDLE_KEY_SESSION_ID)
+ && savedResult.getInt(Constants.ANNOTATION_BUNDLE_KEY_SESSION_ID)
== expectedSessionId;
}
@@ -334,7 +334,7 @@ public class ConnectivityPublisherTest {
assertThat(mDataSubscriberWifiOemManaged.mPushedData).hasSize(1);
PersistableBundle result = mDataSubscriberWifiOemManaged.get(0);
- assertThat(result.getInt(SessionAnnotation.ANNOTATION_BUNDLE_KEY_SESSION_ID))
+ assertThat(result.getInt(Constants.ANNOTATION_BUNDLE_KEY_SESSION_ID))
.isEqualTo(1);
assertThat(result.getInt(Constants.CONNECTIVITY_BUNDLE_KEY_SIZE))
.isEqualTo(2);
@@ -369,8 +369,7 @@ public class ConnectivityPublisherTest {
assertThat(mDataSubscriberWifi.mPushedData).hasSize(1);
PersistableBundle result = mDataSubscriberWifi.get(0);
- assertThat(result.getInt(SessionAnnotation.ANNOTATION_BUNDLE_KEY_SESSION_ID))
- .isEqualTo(1);
+ assertThat(result.getInt(Constants.ANNOTATION_BUNDLE_KEY_SESSION_ID)).isEqualTo(1);
// Matches only UID_1.
assertThat(result.getInt(Constants.CONNECTIVITY_BUNDLE_KEY_SIZE))
.isEqualTo(1);
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/MemoryPublisherTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/MemoryPublisherTest.java
index 5b24c20d32..0ccb99c0f1 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/MemoryPublisherTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/MemoryPublisherTest.java
@@ -208,11 +208,28 @@ public class MemoryPublisherTest {
assertThat(mPublisher.hasDataSubscriber(dataSubscriber)).isTrue();
verify(dataSubscriber).push(mBundleCaptor.capture(), anyBoolean());
- assertThat(mBundleCaptor.getValue().keySet().stream().collect(Collectors.toList()))
- .containsExactly(
- Constants.MEMORY_BUNDLE_KEY_MEMINFO,
- Constants.MEMORY_BUNDLE_KEY_TIMESTAMP,
- "com.android.car:0:com.android.car");
+ PersistableBundle bundle = mBundleCaptor.getValue();
+ assertThat(bundle.keySet().stream().collect(Collectors.toList())).containsExactly(
+ Constants.MEMORY_BUNDLE_KEY_MEMINFO,
+ Constants.MEMORY_BUNDLE_KEY_TIMESTAMP,
+ "com.android.car:0:com.android.car");
+ PersistableBundle processBundle = bundle.getPersistableBundle(
+ "com.android.car:0:com.android.car");
+ assertThat(processBundle.keySet().stream().collect(Collectors.toList())).containsExactly(
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_SWAPPABLE_PSS,
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_PRIVATE_DIRTY,
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_SHARED_DIRTY,
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_PRIVATE_CLEAN,
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_SHARED_CLEAN,
+ "mem.summary.java-heap",
+ "mem.summary.total-pss",
+ "mem.summary.private-other",
+ "mem.summary.native-heap",
+ "mem.summary.stack",
+ "mem.summary.system",
+ "mem.summary.code",
+ "mem.summary.graphics",
+ "mem.summary.total-swap");
}
@Test
@@ -237,12 +254,46 @@ public class MemoryPublisherTest {
assertThat(mPublisher.hasDataSubscriber(dataSubscriber)).isTrue();
verify(dataSubscriber).push(mBundleCaptor.capture(), anyBoolean());
- assertThat(mBundleCaptor.getValue().keySet().stream().collect(Collectors.toList()))
- .containsExactly(
- Constants.MEMORY_BUNDLE_KEY_MEMINFO,
- Constants.MEMORY_BUNDLE_KEY_TIMESTAMP,
- "com.android.car:12345:com.android.car",
- "com.android.car:67890:com.android.car");
+ PersistableBundle bundle = mBundleCaptor.getValue();
+ assertThat(bundle.keySet().stream().collect(Collectors.toList())).containsExactly(
+ Constants.MEMORY_BUNDLE_KEY_MEMINFO,
+ Constants.MEMORY_BUNDLE_KEY_TIMESTAMP,
+ "com.android.car:12345:com.android.car",
+ "com.android.car:67890:com.android.car");
+ PersistableBundle processBundle1 = bundle.getPersistableBundle(
+ "com.android.car:12345:com.android.car");
+ PersistableBundle processBundle2 = bundle.getPersistableBundle(
+ "com.android.car:67890:com.android.car");
+ assertThat(processBundle1.keySet().stream().collect(Collectors.toList())).containsExactly(
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_SWAPPABLE_PSS,
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_PRIVATE_DIRTY,
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_SHARED_DIRTY,
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_PRIVATE_CLEAN,
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_SHARED_CLEAN,
+ "mem.summary.java-heap",
+ "mem.summary.total-pss",
+ "mem.summary.private-other",
+ "mem.summary.native-heap",
+ "mem.summary.stack",
+ "mem.summary.system",
+ "mem.summary.code",
+ "mem.summary.graphics",
+ "mem.summary.total-swap");
+ assertThat(processBundle2.keySet().stream().collect(Collectors.toList())).containsExactly(
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_SWAPPABLE_PSS,
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_PRIVATE_DIRTY,
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_SHARED_DIRTY,
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_PRIVATE_CLEAN,
+ Constants.MEMORY_BUNDLE_KEY_TOTAL_SHARED_CLEAN,
+ "mem.summary.java-heap",
+ "mem.summary.total-pss",
+ "mem.summary.private-other",
+ "mem.summary.native-heap",
+ "mem.summary.stack",
+ "mem.summary.system",
+ "mem.summary.code",
+ "mem.summary.graphics",
+ "mem.summary.total-swap");
}
@Test
@@ -275,8 +326,8 @@ public class MemoryPublisherTest {
verify(mMockDataSubscriber).push(mBundleCaptor.capture(), anyBoolean());
PersistableBundle report = mBundleCaptor.getValue();
- assertThat(report.getInt(SessionAnnotation.ANNOTATION_BUNDLE_KEY_SESSION_ID)).isEqualTo(2);
- assertThat(report.getString(SessionAnnotation.ANNOTATION_BUNDLE_KEY_BOOT_REASON))
+ assertThat(report.getInt(Constants.ANNOTATION_BUNDLE_KEY_SESSION_ID)).isEqualTo(2);
+ assertThat(report.getString(Constants.ANNOTATION_BUNDLE_KEY_BOOT_REASON))
.isEqualTo("reboot");
}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/StatsPublisherTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/StatsPublisherTest.java
index f8f5f6d928..59e27e043c 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/StatsPublisherTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/StatsPublisherTest.java
@@ -454,17 +454,17 @@ public class StatsPublisherTest {
verify(subscriber1).push(mBundleCaptor.capture(), anyBoolean());
PersistableBundle bundle1 = mBundleCaptor.getValue();
- assertThat(bundle1.getLongArray("elapsed_timestamp_nanos"))
+ assertThat(bundle1.getLongArray("stats.elapsed_timestamp_nanos"))
.asList().containsExactly(99999999L);
- assertThat(bundle1.getIntArray("uid")).asList().containsExactly(1000);
- assertThat(Arrays.asList(bundle1.getStringArray("activity_name")))
+ assertThat(bundle1.getIntArray("stats.uid")).asList().containsExactly(1000);
+ assertThat(Arrays.asList(bundle1.getStringArray("stats.activity_name")))
.containsExactly("activityName");
- assertThat(bundle1.getLongArray("rss_in_bytes")).asList().containsExactly(1234L);
+ assertThat(bundle1.getLongArray("stats.rss_in_bytes")).asList().containsExactly(1234L);
verify(subscriber2).push(mBundleCaptor.capture(), anyBoolean());
PersistableBundle bundle2 = mBundleCaptor.getValue();
- assertThat(bundle2.getIntArray("uid")).asList().containsExactly(234);
- assertThat(bundle2.getLongArray("rss_in_bytes")).asList().containsExactly(4567L);
- assertThat(bundle2.getLongArray("elapsed_timestamp_nanos"))
+ assertThat(bundle2.getIntArray("stats.uid")).asList().containsExactly(234);
+ assertThat(bundle2.getLongArray("stats.rss_in_bytes")).asList().containsExactly(4567L);
+ assertThat(bundle2.getLongArray("stats.elapsed_timestamp_nanos"))
.asList().containsExactly(445678901L);
}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ActivityForegroundStateChangedConverterTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ActivityForegroundStateChangedConverterTest.java
index 8efaf1bf3c..5a9ddd75f8 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ActivityForegroundStateChangedConverterTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ActivityForegroundStateChangedConverterTest.java
@@ -20,6 +20,7 @@ import static com.android.car.telemetry.AtomsProto.ActivityForegroundStateChange
import static com.android.car.telemetry.AtomsProto.ActivityForegroundStateChanged.PKG_NAME_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.ActivityForegroundStateChanged.STATE_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.ActivityForegroundStateChanged.UID_FIELD_NUMBER;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_PREFIX;
import static com.google.common.truth.Truth.assertThat;
@@ -105,15 +106,18 @@ public class ActivityForegroundStateChangedConverterTest {
dimensionsValuesList, HASH_STR_MAP);
assertThat(bundle.size()).isEqualTo(4);
- assertThat(bundle.getIntArray(accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1000, 2000).inOrder();
- assertThat(Arrays.asList(
- bundle.getStringArray(accessorMap.get(PKG_NAME_FIELD_NUMBER).getFieldName())))
+ assertThat(Arrays.asList(bundle.getStringArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(PKG_NAME_FIELD_NUMBER).getFieldName())))
.containsExactly("package.name.1", "package.name.2").inOrder();
- assertThat(Arrays.asList(
- bundle.getStringArray(accessorMap.get(CLASS_NAME_FIELD_NUMBER).getFieldName())))
+ assertThat(Arrays.asList(bundle.getStringArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ CLASS_NAME_FIELD_NUMBER).getFieldName())))
.containsExactly("className1", "className2").inOrder();
- assertThat(bundle.getIntArray(accessorMap.get(STATE_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(STATE_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(0, 1).inOrder(); // States background=0 and foreground=1
}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AnrOccurredConverterTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AnrOccurredConverterTest.java
index f776da9b91..9cfa917b70 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AnrOccurredConverterTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AnrOccurredConverterTest.java
@@ -20,6 +20,7 @@ import static com.android.car.telemetry.AtomsProto.ANROccurred.ERROR_SOURCE_FIEL
import static com.android.car.telemetry.AtomsProto.ANROccurred.PACKAGE_NAME_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.ANROccurred.REASON_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.ANROccurred.UID_FIELD_NUMBER;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_PREFIX;
import static com.google.common.truth.Truth.assertThat;
@@ -78,14 +79,19 @@ public class AnrOccurredConverterTest {
PersistableBundle bundle = mConverter.convert(atomsList, null, null, null);
assertThat(bundle.size()).isEqualTo(4);
- assertThat(bundle.getIntArray(accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1000, 2000).inOrder();
- assertThat(Arrays.asList(
- bundle.getStringArray(accessorMap.get(PACKAGE_NAME_FIELD_NUMBER).getFieldName())))
+ assertThat(Arrays.asList(bundle.getStringArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ PACKAGE_NAME_FIELD_NUMBER).getFieldName())))
.containsExactly(PACKAGE_NAME_1, PACKAGE_NAME_2).inOrder();
- assertThat(bundle.getStringArray(accessorMap.get(REASON_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getStringArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(REASON_FIELD_NUMBER).getFieldName()))
.asList().containsExactly("test1", "test2").inOrder();
- assertThat(bundle.getIntArray(accessorMap.get(ERROR_SOURCE_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(ERROR_SOURCE_FIELD_NUMBER)
+ .getFieldName()))
.asList().containsExactly(1, 2).inOrder(); // DATA_APP=1, SYSTEM_APP=2
}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AppCrashOccurredConverterTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AppCrashOccurredConverterTest.java
index 9ceef706b6..b925af0289 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AppCrashOccurredConverterTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AppCrashOccurredConverterTest.java
@@ -20,6 +20,7 @@ import static com.android.car.telemetry.AtomsProto.AppCrashOccurred.ERROR_SOURCE
import static com.android.car.telemetry.AtomsProto.AppCrashOccurred.PACKAGE_NAME_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.AppCrashOccurred.PID_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.AppCrashOccurred.UID_FIELD_NUMBER;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_PREFIX;
import static com.google.common.truth.Truth.assertThat;
@@ -77,13 +78,19 @@ public class AppCrashOccurredConverterTest {
PersistableBundle bundle = mConverter.convert(atomsList, null, null, null);
assertThat(bundle.size()).isEqualTo(4);
- assertThat(bundle.getIntArray(accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1000, 2000).inOrder();
- assertThat(bundle.getIntArray(accessorMap.get(PID_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(PID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(12345, 67890).inOrder();
- assertThat(bundle.getStringArray(accessorMap.get(PACKAGE_NAME_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getStringArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(PACKAGE_NAME_FIELD_NUMBER)
+ .getFieldName()))
.asList().containsExactly(PACKAGE_NAME_1, PACKAGE_NAME_2).inOrder();
- assertThat(bundle.getIntArray(accessorMap.get(ERROR_SOURCE_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(ERROR_SOURCE_FIELD_NUMBER)
+ .getFieldName()))
.asList().containsExactly(1, 2).inOrder(); // DATA_APP=1, SYSTEM_APP=2
}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AppStartMemoryStateCapturedConverterTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AppStartMemoryStateCapturedConverterTest.java
index c2346a1097..30b5f21702 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AppStartMemoryStateCapturedConverterTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AppStartMemoryStateCapturedConverterTest.java
@@ -24,6 +24,7 @@ import static com.android.car.telemetry.AtomsProto.AppStartMemoryStateCaptured.P
import static com.android.car.telemetry.AtomsProto.AppStartMemoryStateCaptured.RSS_IN_BYTES_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.AppStartMemoryStateCaptured.SWAP_IN_BYTES_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.AppStartMemoryStateCaptured.UID_FIELD_NUMBER;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_PREFIX;
import static com.google.common.truth.Truth.assertThat;
@@ -119,24 +120,36 @@ public class AppStartMemoryStateCapturedConverterTest {
dimensionsValuesList, HASH_STR_MAP);
assertThat(bundle.size()).isEqualTo(8);
- assertThat(bundle.getIntArray(accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1000, 2000).inOrder();
- assertThat(Arrays.asList(
- bundle.getStringArray(accessorMap.get(PROCESS_NAME_FIELD_NUMBER).getFieldName())))
+ assertThat(Arrays.asList(bundle.getStringArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(PROCESS_NAME_FIELD_NUMBER)
+ .getFieldName())))
.containsExactly("process.name.1", "process.name.2").inOrder();
- assertThat(Arrays.asList(
- bundle.getStringArray(accessorMap.get(ACTIVITY_NAME_FIELD_NUMBER).getFieldName())))
+ assertThat(Arrays.asList(bundle.getStringArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(ACTIVITY_NAME_FIELD_NUMBER)
+ .getFieldName())))
.containsExactly("activityName1", "activityName2").inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(PAGE_FAULT_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(PAGE_FAULT_FIELD_NUMBER)
+ .getFieldName()))
.asList().containsExactly(59L, 99L).inOrder();
assertThat(bundle.getLongArray(
- accessorMap.get(PAGE_MAJOR_FAULT_FIELD_NUMBER).getFieldName()))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(PAGE_MAJOR_FAULT_FIELD_NUMBER)
+ .getFieldName()))
.asList().containsExactly(34L, 55L).inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(RSS_IN_BYTES_FIELD_NUMBER)
+ .getFieldName()))
.asList().containsExactly(1234L, 2345L).inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(CACHE_IN_BYTES_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(CACHE_IN_BYTES_FIELD_NUMBER)
+ .getFieldName()))
.asList().containsExactly(234L, 345L).inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(SWAP_IN_BYTES_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(SWAP_IN_BYTES_FIELD_NUMBER)
+ .getFieldName()))
.asList().containsExactly(111L, 222L).inOrder();
}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AtomListConverterTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AtomListConverterTest.java
index 752cd366e6..51dd912044 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AtomListConverterTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/AtomListConverterTest.java
@@ -16,6 +16,8 @@
package com.android.car.telemetry.publisher.statsconverters;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_PREFIX;
+
import static com.google.common.truth.Truth.assertThat;
import android.os.PersistableBundle;
@@ -60,15 +62,17 @@ public class AtomListConverterTest {
assertThat(bundle.size()).isEqualTo(3);
assertThat(bundle.getIntArray(
- accessorMap.get(AppStartMemoryStateCaptured.UID_FIELD_NUMBER).getFieldName()))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ AppStartMemoryStateCaptured.UID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1000, 1100).inOrder();
assertThat(Arrays.asList(bundle.getStringArray(
- accessorMap.get(AppStartMemoryStateCaptured.ACTIVITY_NAME_FIELD_NUMBER)
- .getFieldName())))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ AppStartMemoryStateCaptured.ACTIVITY_NAME_FIELD_NUMBER)
+ .getFieldName())))
.containsExactly("activityName1", "activityName2").inOrder();
assertThat(bundle.getLongArray(
- accessorMap.get(AppStartMemoryStateCaptured.RSS_IN_BYTES_FIELD_NUMBER)
- .getFieldName()))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ AppStartMemoryStateCaptured.RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1234L, 2345L).inOrder();
}
@@ -96,13 +100,16 @@ public class AtomListConverterTest {
assertThat(bundle.size()).isEqualTo(3);
assertThat(bundle.getIntArray(
- accessorMap.get(ProcessMemoryState.UID_FIELD_NUMBER).getFieldName()))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(ProcessMemoryState.UID_FIELD_NUMBER)
+ .getFieldName()))
.asList().containsExactly(1000, 1100).inOrder();
assertThat(Arrays.asList(bundle.getStringArray(
- accessorMap.get(ProcessMemoryState.PROCESS_NAME_FIELD_NUMBER).getFieldName())))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ ProcessMemoryState.PROCESS_NAME_FIELD_NUMBER).getFieldName())))
.containsExactly("processName1", "processName2").inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(
- ProcessMemoryState.RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ ProcessMemoryState.RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1234L, 2345L).inOrder();
}
}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ConfigMetricsReportListConverterTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ConfigMetricsReportListConverterTest.java
index da486d8598..cd7da4b48b 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ConfigMetricsReportListConverterTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ConfigMetricsReportListConverterTest.java
@@ -16,6 +16,9 @@
package com.android.car.telemetry.publisher.statsconverters;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_PREFIX;
+
import static com.google.common.truth.Truth.assertThat;
import android.os.PersistableBundle;
@@ -101,33 +104,34 @@ public class ConfigMetricsReportListConverterTest {
assertThat(new ArrayList<Long>(map.keySet())).containsExactly(12345L, 23456L);
PersistableBundle eventBundle = map.get(12345L);
- assertThat(eventBundle.getLongArray(EventMetricDataConverter.ELAPSED_TIME_NANOS))
+ assertThat(eventBundle.getLongArray(STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP))
.asList().containsExactly(99999999L);
assertThat(eventBundle.getIntArray(
- appMemAccessorMap.get(AppStartMemoryStateCaptured.UID_FIELD_NUMBER)
- .getFieldName()))
+ STATS_BUNDLE_KEY_PREFIX + appMemAccessorMap.get(
+ AppStartMemoryStateCaptured.UID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1000);
assertThat(Arrays.asList(eventBundle.getStringArray(
- appMemAccessorMap.get(AppStartMemoryStateCaptured.ACTIVITY_NAME_FIELD_NUMBER)
- .getFieldName())))
+ STATS_BUNDLE_KEY_PREFIX + appMemAccessorMap.get(
+ AppStartMemoryStateCaptured.ACTIVITY_NAME_FIELD_NUMBER).getFieldName())))
.containsExactly("activityName");
assertThat(eventBundle.getLongArray(
- appMemAccessorMap.get(AppStartMemoryStateCaptured.RSS_IN_BYTES_FIELD_NUMBER)
- .getFieldName()))
+ STATS_BUNDLE_KEY_PREFIX + appMemAccessorMap.get(
+ AppStartMemoryStateCaptured.RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1234L);
PersistableBundle gaugeBundle = map.get(23456L);
assertThat(gaugeBundle.getIntArray(
- procMemAccessorMap.get(ProcessMemoryState.UID_FIELD_NUMBER).getFieldName()))
+ STATS_BUNDLE_KEY_PREFIX + procMemAccessorMap.get(
+ ProcessMemoryState.UID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(234);
assertThat(Arrays.asList(gaugeBundle.getStringArray(
- procMemAccessorMap.get(ProcessMemoryState.PROCESS_NAME_FIELD_NUMBER)
- .getFieldName())))
+ STATS_BUNDLE_KEY_PREFIX + procMemAccessorMap.get(
+ ProcessMemoryState.PROCESS_NAME_FIELD_NUMBER).getFieldName())))
.containsExactly("process.name");
assertThat(gaugeBundle.getLongArray(
- procMemAccessorMap.get(ProcessMemoryState.RSS_IN_BYTES_FIELD_NUMBER)
- .getFieldName()))
+ STATS_BUNDLE_KEY_PREFIX + procMemAccessorMap.get(
+ ProcessMemoryState.RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(4567L);
- assertThat(gaugeBundle.getLongArray(GaugeMetricDataConverter.ELAPSED_TIME_NANOS))
+ assertThat(gaugeBundle.getLongArray(STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP))
.asList().containsExactly(445678901L);
}
}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/EventMetricDataConverterTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/EventMetricDataConverterTest.java
index 5cb41c08da..2b4ee7b530 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/EventMetricDataConverterTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/EventMetricDataConverterTest.java
@@ -19,6 +19,8 @@ package com.android.car.telemetry.publisher.statsconverters;
import static com.android.car.telemetry.AtomsProto.AppStartMemoryStateCaptured.ACTIVITY_NAME_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.AppStartMemoryStateCaptured.RSS_IN_BYTES_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.AppStartMemoryStateCaptured.UID_FIELD_NUMBER;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_PREFIX;
import static com.google.common.truth.Truth.assertThat;
@@ -68,14 +70,18 @@ public class EventMetricDataConverterTest {
PersistableBundle bundle = EventMetricDataConverter.convertEventDataList(eventDataList);
assertThat(bundle.size()).isEqualTo(4);
- assertThat(bundle.getLongArray(EventMetricDataConverter.ELAPSED_TIME_NANOS))
+ assertThat(bundle.getLongArray(STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP))
.asList().containsExactly(12345678L, 23456789L).inOrder();
- assertThat(bundle.getIntArray(accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1000, 1100).inOrder();
assertThat(Arrays.asList(bundle.getStringArray(
- accessorMap.get(ACTIVITY_NAME_FIELD_NUMBER).getFieldName())))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ ACTIVITY_NAME_FIELD_NUMBER).getFieldName())))
.containsExactly("activityName1", "activityName2").inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1234L, 2345L).inOrder();
}
@@ -112,14 +118,18 @@ public class EventMetricDataConverterTest {
PersistableBundle bundle = EventMetricDataConverter.convertEventDataList(eventDataList);
assertThat(bundle.size()).isEqualTo(4);
- assertThat(bundle.getLongArray(EventMetricDataConverter.ELAPSED_TIME_NANOS))
+ assertThat(bundle.getLongArray(STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP))
.asList().containsExactly(12345678L, 12345679L, 23456789L).inOrder();
- assertThat(bundle.getIntArray(accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1000, 1000, 1100).inOrder();
assertThat(Arrays.asList(bundle.getStringArray(
- accessorMap.get(ACTIVITY_NAME_FIELD_NUMBER).getFieldName())))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ ACTIVITY_NAME_FIELD_NUMBER).getFieldName())))
.containsExactly("activityName1", "activityName1", "activityName2").inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1234L, 1234L, 2345L).inOrder();
}
}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/GaugeMetricDataConverterTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/GaugeMetricDataConverterTest.java
index 4053135540..e80a29de2b 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/GaugeMetricDataConverterTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/GaugeMetricDataConverterTest.java
@@ -21,6 +21,8 @@ import static com.android.car.telemetry.AtomsProto.ProcessMemoryState.PROCESS_NA
import static com.android.car.telemetry.AtomsProto.ProcessMemoryState.RSS_IN_BYTES_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.ProcessMemoryState.SWAP_IN_BYTES_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.ProcessMemoryState.UID_FIELD_NUMBER;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_PREFIX;
import static com.google.common.truth.Truth.assertThat;
@@ -105,19 +107,26 @@ public class GaugeMetricDataConverterTest {
// For each atom 2 fields were set, additionally 3 fields were encoded in dimension values,
// and 1 elapsed time array, so 6 arrays are expected in the bundle.
assertThat(bundle.size()).isEqualTo(6);
- assertThat(bundle.getIntArray(accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(123, 123, 123, 234).inOrder();
assertThat(Arrays.asList(bundle.getStringArray(
- accessorMap.get(PROCESS_NAME_FIELD_NUMBER).getFieldName())))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ PROCESS_NAME_FIELD_NUMBER).getFieldName())))
.containsExactly("process.name.1", "process.name.1",
"process.name.1", "process.name.2").inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(PAGE_FAULT_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(PAGE_FAULT_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1000L, 1100L, 1200L, 1300L).inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1234L, 2345L, 3456L, 4567L).inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(SWAP_IN_BYTES_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ SWAP_IN_BYTES_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(11111111L, 11111111L, 11111111L, 22222222L).inOrder();
- assertThat(bundle.getLongArray(GaugeMetricDataConverter.ELAPSED_TIME_NANOS))
+ assertThat(bundle.getLongArray(STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP))
.asList().containsExactly(12345678L, 23456789L, 34567890L, 445678901L).inOrder();
}
@@ -190,20 +199,27 @@ public class GaugeMetricDataConverterTest {
// For each atom 2 fields were set, additionally 3 fields were encoded in dimension values,
// and 1 elapsed time array, so 6 arrays are expected in the bundle.
assertThat(bundle.size()).isEqualTo(6);
- assertThat(bundle.getIntArray(accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(123, 123, 123, 123, 123, 234).inOrder();
assertThat(Arrays.asList(bundle.getStringArray(
- accessorMap.get(PROCESS_NAME_FIELD_NUMBER).getFieldName())))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ PROCESS_NAME_FIELD_NUMBER).getFieldName())))
.containsExactly("process.name.1", "process.name.1", "process.name.1",
"process.name.1", "process.name.1", "process.name.2").inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(PAGE_FAULT_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(PAGE_FAULT_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1000L, 1000L, 1100L, 1200L, 1200L, 1300L).inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1234L, 1234L, 2345L, 3456L, 3456L, 4567L).inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(SWAP_IN_BYTES_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ SWAP_IN_BYTES_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(
11111111L, 11111111L, 11111111L, 11111111L, 11111111L, 22222222L).inOrder();
- assertThat(bundle.getLongArray(GaugeMetricDataConverter.ELAPSED_TIME_NANOS))
+ assertThat(bundle.getLongArray(STATS_BUNDLE_KEY_ELAPSED_TIMESTAMP))
.asList().containsExactly(
12345678L, 12345679L, 23456789L, 34567890L, 34567899L, 445678901L).inOrder();
}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ProcessCpuTimeConverterTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ProcessCpuTimeConverterTest.java
index 75c1bf6f6b..a0faf78427 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ProcessCpuTimeConverterTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ProcessCpuTimeConverterTest.java
@@ -20,6 +20,7 @@ import static com.android.car.telemetry.AtomsProto.ProcessCpuTime.PROCESS_NAME_F
import static com.android.car.telemetry.AtomsProto.ProcessCpuTime.SYSTEM_TIME_MILLIS_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.ProcessCpuTime.UID_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.ProcessCpuTime.USER_TIME_MILLIS_FIELD_NUMBER;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_PREFIX;
import static com.google.common.truth.Truth.assertThat;
@@ -102,16 +103,20 @@ public class ProcessCpuTimeConverterTest {
dimensionsValuesList, HASH_STR_MAP);
assertThat(bundle.size()).isEqualTo(4);
- assertThat(bundle.getIntArray(accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1000, 2000).inOrder();
- assertThat(Arrays.asList(
- bundle.getStringArray(accessorMap.get(PROCESS_NAME_FIELD_NUMBER).getFieldName())))
+ assertThat(Arrays.asList(bundle.getStringArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ PROCESS_NAME_FIELD_NUMBER).getFieldName())))
.containsExactly("process.name.1", "process.name.2").inOrder();
assertThat(bundle.getLongArray(
- accessorMap.get(USER_TIME_MILLIS_FIELD_NUMBER).getFieldName()))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ USER_TIME_MILLIS_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(234L, 345L).inOrder();
assertThat(bundle.getLongArray(
- accessorMap.get(SYSTEM_TIME_MILLIS_FIELD_NUMBER).getFieldName()))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ SYSTEM_TIME_MILLIS_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(111L, 222L).inOrder();
}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ProcessMemoryStateConverterTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ProcessMemoryStateConverterTest.java
index 39fb7725d5..bf82bdae20 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ProcessMemoryStateConverterTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/ProcessMemoryStateConverterTest.java
@@ -24,6 +24,7 @@ import static com.android.car.telemetry.AtomsProto.ProcessMemoryState.PROCESS_NA
import static com.android.car.telemetry.AtomsProto.ProcessMemoryState.RSS_IN_BYTES_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.ProcessMemoryState.SWAP_IN_BYTES_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.ProcessMemoryState.UID_FIELD_NUMBER;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_PREFIX;
import static com.google.common.truth.Truth.assertThat;
@@ -117,24 +118,35 @@ public class ProcessMemoryStateConverterTest {
dimensionsValuesList, HASH_STR_MAP);
assertThat(bundle.size()).isEqualTo(8);
- assertThat(bundle.getIntArray(accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1000, 2000).inOrder();
- assertThat(Arrays.asList(
- bundle.getStringArray(accessorMap.get(PROCESS_NAME_FIELD_NUMBER).getFieldName())))
+ assertThat(Arrays.asList(bundle.getStringArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ PROCESS_NAME_FIELD_NUMBER).getFieldName())))
.containsExactly("process.name.1", "process.name.2").inOrder();
- assertThat(bundle.getIntArray(accessorMap.get(OOM_ADJ_SCORE_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ OOM_ADJ_SCORE_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(100, 200).inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(PAGE_FAULT_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(PAGE_FAULT_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(59L, 99L).inOrder();
assertThat(bundle.getLongArray(
- accessorMap.get(PAGE_MAJOR_FAULT_FIELD_NUMBER).getFieldName()))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ PAGE_MAJOR_FAULT_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(34L, 55L).inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ RSS_IN_BYTES_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(1234L, 2345L).inOrder();
assertThat(bundle.getLongArray(
- accessorMap.get(CACHE_IN_BYTES_FIELD_NUMBER).getFieldName()))
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ CACHE_IN_BYTES_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(234L, 345L).inOrder();
- assertThat(bundle.getLongArray(accessorMap.get(SWAP_IN_BYTES_FIELD_NUMBER).getFieldName()))
+ assertThat(bundle.getLongArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ SWAP_IN_BYTES_FIELD_NUMBER).getFieldName()))
.asList().containsExactly(111L, 222L).inOrder();
}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/WtfOccurredConverterTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/WtfOccurredConverterTest.java
index f0dbdd28dd..c3a4f68d27 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/WtfOccurredConverterTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/publisher/statsconverters/WtfOccurredConverterTest.java
@@ -20,6 +20,7 @@ import static com.android.car.telemetry.AtomsProto.WTFOccurred.ERROR_SOURCE_FIEL
import static com.android.car.telemetry.AtomsProto.WTFOccurred.PROCESS_NAME_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.WTFOccurred.TAG_FIELD_NUMBER;
import static com.android.car.telemetry.AtomsProto.WTFOccurred.UID_FIELD_NUMBER;
+import static com.android.car.telemetry.publisher.Constants.STATS_BUNDLE_KEY_PREFIX;
import static com.google.common.truth.Truth.assertThat;
@@ -76,15 +77,20 @@ public class WtfOccurredConverterTest {
PersistableBundle bundle = mConverter.convert(atomsList, null, null, null);
assertThat(bundle.size()).isEqualTo(4);
- assertThat(bundle.getIntArray(accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
- .asList().containsExactly(1000, 2000).inOrder();
- assertThat(Arrays.asList(
- bundle.getStringArray(accessorMap.get(PROCESS_NAME_FIELD_NUMBER).getFieldName())))
- .containsExactly(PACKAGE_NAME_1, PACKAGE_NAME_2).inOrder();
- assertThat(bundle.getStringArray(accessorMap.get(TAG_FIELD_NUMBER).getFieldName()))
- .asList().containsExactly("tag1", "tag2").inOrder();
- assertThat(bundle.getIntArray(accessorMap.get(ERROR_SOURCE_FIELD_NUMBER).getFieldName()))
- .asList().containsExactly(1, 2).inOrder(); // DATA_APP=1, SYSTEM_APP=2
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(UID_FIELD_NUMBER).getFieldName()))
+ .asList().containsExactly(1000, 2000).inOrder();
+ assertThat(Arrays.asList(bundle.getStringArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ PROCESS_NAME_FIELD_NUMBER).getFieldName())))
+ .containsExactly(PACKAGE_NAME_1, PACKAGE_NAME_2).inOrder();
+ assertThat(bundle.getStringArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(TAG_FIELD_NUMBER).getFieldName()))
+ .asList().containsExactly("tag1", "tag2").inOrder();
+ assertThat(bundle.getIntArray(
+ STATS_BUNDLE_KEY_PREFIX + accessorMap.get(
+ ERROR_SOURCE_FIELD_NUMBER).getFieldName()))
+ .asList().containsExactly(1, 2).inOrder(); // DATA_APP=1, SYSTEM_APP=2
}
@Test
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/sessioncontroller/SessionAnnotationUnitTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/sessioncontroller/SessionAnnotationUnitTest.java
index da5917c530..d1cc98c028 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/sessioncontroller/SessionAnnotationUnitTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/sessioncontroller/SessionAnnotationUnitTest.java
@@ -20,6 +20,8 @@ import static com.google.common.truth.Truth.assertThat;
import android.os.PersistableBundle;
+import com.android.car.telemetry.publisher.Constants;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
@@ -42,17 +44,17 @@ public class SessionAnnotationUnitTest {
sAnnotation.addAnnotationsToBundle(data);
- assertThat(data.getInt(SessionAnnotation.ANNOTATION_BUNDLE_KEY_SESSION_ID)).isEqualTo(
+ assertThat(data.getInt(Constants.ANNOTATION_BUNDLE_KEY_SESSION_ID)).isEqualTo(
SESSION_ID);
- assertThat(data.getInt(SessionAnnotation.ANNOTATION_BUNDLE_KEY_SESSION_STATE)).isEqualTo(
+ assertThat(data.getInt(Constants.ANNOTATION_BUNDLE_KEY_SESSION_STATE)).isEqualTo(
SESSION_STATE);
assertThat(data.getLong(
- SessionAnnotation.ANNOTATION_BUNDLE_KEY_CREATED_AT_SINCE_BOOT_MILLIS)).isEqualTo(
+ Constants.ANNOTATION_BUNDLE_KEY_CREATED_AT_SINCE_BOOT_MILLIS)).isEqualTo(
CREATED_AT_SINCE_BOOT_MILLIS);
assertThat(
- data.getLong(SessionAnnotation.ANNOTATION_BUNDLE_KEY_CREATED_AT_MILLIS)).isEqualTo(
+ data.getLong(Constants.ANNOTATION_BUNDLE_KEY_CREATED_AT_MILLIS)).isEqualTo(
CREATED_AT_MILLIS);
- assertThat(data.getString(SessionAnnotation.ANNOTATION_BUNDLE_KEY_BOOT_REASON)).isEqualTo(
+ assertThat(data.getString(Constants.ANNOTATION_BUNDLE_KEY_BOOT_REASON)).isEqualTo(
BOOT_REASON);
}
}