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

Commit 73c5d230 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add logging code for Context Hub restart"

parents 18de170f 0d3626bd
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();