summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbkchoi <bkchoi@google.com>2023-12-08 23:32:00 +0000
committerbkchoi <bkchoi@google.com>2023-12-08 23:34:43 +0000
commit45b5a722f269a12a479533b72f2fe72b0fd34f22 (patch)
tree54328b3e970d1fa0834205417461549fcb86f2e7
parenta13cb93f10c38c6581f49214e8763f019ef1cbbe (diff)
downloadCluster-45b5a722f269a12a479533b72f2fe72b0fd34f22.tar.gz
Show the heartbeat sent in ClusterHomeActivityLightMode.
This is to visualize the heartbeat sent in the sample cluster app. Bug: 302368365 Test: manual Change-Id: I893fc92803a3da2a7e34a51979d81d54924e6857
-rw-r--r--ClusterHomeSample/src/com/android/car/cluster/home/ClusterHomeActivityLightMode.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/ClusterHomeSample/src/com/android/car/cluster/home/ClusterHomeActivityLightMode.java b/ClusterHomeSample/src/com/android/car/cluster/home/ClusterHomeActivityLightMode.java
index a2462d0..0240339 100644
--- a/ClusterHomeSample/src/com/android/car/cluster/home/ClusterHomeActivityLightMode.java
+++ b/ClusterHomeSample/src/com/android/car/cluster/home/ClusterHomeActivityLightMode.java
@@ -20,6 +20,7 @@ import android.car.Car;
import android.car.cluster.ClusterHomeManager;
import android.os.Bundle;
import android.util.Log;
+import android.widget.TextView;
public class ClusterHomeActivityLightMode extends ClusterHomeActivity {
@@ -27,6 +28,8 @@ public class ClusterHomeActivityLightMode extends ClusterHomeActivity {
private static final long HEARTBEAT_INTERVAL_MS = 1000; // 1 second interval.
private ClusterHomeManager mClusterHomeManager;
+ private TextView mTextView;
+ private String mText;
private final Runnable mSendHeartbeatsRunnable = () -> sendHeartbeats();
@@ -45,6 +48,9 @@ public class ClusterHomeActivityLightMode extends ClusterHomeActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ mTextView = findViewById(R.id.text);
+ mText = getResources().getString(R.string.cluster_home_text);
+
Car car = Car.createCar(getApplicationContext());
mClusterHomeManager = (ClusterHomeManager) car.getCarManager(ClusterHomeManager.class);
}
@@ -69,7 +75,9 @@ public class ClusterHomeActivityLightMode extends ClusterHomeActivity {
}
private void sendHeartbeats() {
- mClusterHomeManager.sendHeartbeat(System.nanoTime(), /* appMetadata= */ null);
+ long nanoTime = System.nanoTime();
+ mClusterHomeManager.sendHeartbeat(nanoTime, /* appMetadata= */ null);
+ mTextView.setText(mText + "\nHeartbeat sent: " + nanoTime);
getMainThreadHandler().postDelayed(mSendHeartbeatsRunnable, HEARTBEAT_INTERVAL_MS);
}