Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d3626bd authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Add logging code for Context Hub restart

Bug: 194287570
Test: statsd_testdrive
Change-Id: Ib3231d2b2ca94a9d844d8711841ef489375f4667
parent ab13590c
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @hide
@@ -146,6 +147,8 @@ public class ContextHubService extends IContextHubService.Stub {

    private final SensorPrivacyManagerInternal mSensorPrivacyManagerInternal;

    private final Map<Integer, AtomicLong> mLastRestartTimestampMap = new HashMap<>();

    /**
     * Class extending the callback to register with a Context Hub.
     */
@@ -223,6 +226,9 @@ public class ContextHubService extends IContextHubService.Stub {

        HashMap<Integer, IContextHubClient> defaultClientMap = new HashMap<>();
        for (int contextHubId : mContextHubIdToInfoMap.keySet()) {
            mLastRestartTimestampMap.put(contextHubId,
                    new AtomicLong(SystemClock.elapsedRealtimeNanos()));

            ContextHubInfo contextHubInfo = mContextHubIdToInfoMap.get(contextHubId);
            IContextHubClient client = mClientManager.registerClient(
                    contextHubInfo, createDefaultClientCallback(contextHubId),
@@ -700,6 +706,12 @@ public class ContextHubService extends IContextHubService.Stub {
     */
    private void handleHubEventCallback(int contextHubId, int eventType) {
        if (eventType == CONTEXT_HUB_EVENT_RESTARTED) {
            long now = SystemClock.elapsedRealtimeNanos();
            long lastRestartTimeNs = mLastRestartTimestampMap.get(contextHubId).getAndSet(now);
            ContextHubStatsLog.write(
                    ContextHubStatsLog.CONTEXT_HUB_RESTARTED, now - lastRestartTimeNs,
                    contextHubId);

            sendLocationSettingUpdate();
            sendWifiSettingUpdate(true /* forceUpdate */);
            sendAirplaneModeSettingUpdate();