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

Commit d6720f0b authored by Wei Wang's avatar Wei Wang Committed by Android (Google) Code Review
Browse files

Merge "ContextHubSystemService: Init of ContextHubSystemService in a parallel...

Merge "ContextHubSystemService: Init of ContextHubSystemService in a parallel thread" into oc-dr1-dev
parents 93ea4338 78ca4178
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -16,17 +16,25 @@

package com.android.server;

import com.android.internal.util.ConcurrentUtils;
import com.android.server.location.ContextHubService;
import com.android.server.SystemServerInitThreadPool;
import android.content.Context;
import android.util.Log;

import java.util.concurrent.Future;

class ContextHubSystemService extends SystemService {
    private static final String TAG = "ContextHubSystemService";
    private final ContextHubService mContextHubService;
    private ContextHubService mContextHubService;

    private Future<?> mInit;

    public ContextHubSystemService(Context context) {
        super(context);
        mInit = SystemServerInitThreadPool.get().submit(() -> {
            mContextHubService = new ContextHubService(context);
        }, "Init ContextHubSystemService");
    }

    @Override
@@ -37,6 +45,9 @@ class ContextHubSystemService extends SystemService {
    public void onBootPhase(int phase) {
        if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
            Log.d(TAG, "onBootPhase: PHASE_SYSTEM_SERVICES_READY");
            ConcurrentUtils.waitForFutureNoInterrupt(mInit,
                    "Wait for ContextHubSystemService init");
            mInit = null;
            publishBinderService(Context.CONTEXTHUB_SERVICE, mContextHubService);
        }
    }