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

Commit 72208bf0 authored by Lei Ju's avatar Lei Ju Committed by Android Build Coastguard Worker
Browse files

ContextHubService: Reconnect host endpoints after HAL is restarted

Test: Observed the change via adb shell dumpsys and logcat
Flag: android.chre.flags.reconnect_host_endpoints_after_hal_restart
Bug: 348253728
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:5262ed83a9456bd05ac1c7041b4963bbbf4c105d)
Merged-In: I4ecc107cf7775f2cc502d5a94c614dd7e67c7cc6
Change-Id: I4ecc107cf7775f2cc502d5a94c614dd7e67c7cc6
parent e62f4bcf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1126,7 +1126,7 @@ public class ContextHubClientBroker extends IContextHubClient.Stub
        }
    }

    private void sendHostEndpointConnectedEvent() {
    void sendHostEndpointConnectedEvent() {
        HostEndpointInfo info = new HostEndpointInfo();
        info.hostEndpointId = (char) mHostEndPointId;
        info.packageName = mPackage;
+7 −2
Original line number Diff line number Diff line
@@ -242,10 +242,14 @@ public class ContextHubService extends IContextHubService.Stub {

        @Override
        public void handleServiceRestart() {
            Log.i(TAG, "Starting Context Hub Service restart");
            Log.i(TAG, "Recovering from Context Hub HAL restart...");
            initExistingCallbacks();
            resetSettings();
            Log.i(TAG, "Finished Context Hub Service restart");
            if (Flags.reconnectHostEndpointsAfterHalRestart()) {
                mClientManager.forEachClientOfHub(mContextHubId,
                        ContextHubClientBroker::sendHostEndpointConnectedEvent);
            }
            Log.i(TAG, "Finished recovering from Context Hub HAL restart");
        }

        @Override
@@ -536,6 +540,7 @@ public class ContextHubService extends IContextHubService.Stub {
        for (int contextHubId : mContextHubIdToInfoMap.keySet()) {
            try {
                mContextHubWrapper.registerExistingCallback(contextHubId);
                Log.i(TAG, "Re-registered callback to context hub " + contextHubId);
            } catch (RemoteException e) {
                Log.e(TAG, "RemoteException while registering existing service callback for hub "
                        + "(ID = " + contextHubId + ")", e);