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

Commit 95f9f999 authored by Kangping Dong's avatar Kangping Dong Committed by Automerger Merge Worker
Browse files

Merge "Fix getting CONTEXTHUB_SERVICE throws ServiceNotFoundException" into main am: a61f0505

parents fda185b8 a61f0505
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ import android.hardware.iris.IrisManager;
import android.hardware.lights.LightsManager;
import android.hardware.lights.SystemLightsManager;
import android.hardware.location.ContextHubManager;
import android.hardware.location.IContextHubService;
import android.hardware.radio.RadioManager;
import android.hardware.usb.IUsbManager;
import android.hardware.usb.UsbManager;
@@ -1125,7 +1126,11 @@ public final class SystemServiceRegistry {
                new CachedServiceFetcher<ContextHubManager>() {
            @Override
            public ContextHubManager createService(ContextImpl ctx) throws ServiceNotFoundException {
                return new ContextHubManager(ctx.getOuterContext(),
                IBinder b = ServiceManager.getService(Context.CONTEXTHUB_SERVICE);
                if (b == null) {
                    return null;
                }
                return new ContextHubManager(IContextHubService.Stub.asInterface(b),
                        ctx.mMainThread.getHandler().getLooper());
            }});

+7 −5
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package android.hardware.location;

import static java.util.Objects.requireNonNull;

import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -1111,12 +1113,12 @@ public final class ContextHubManager {
        }
    };

    /** @throws ServiceNotFoundException
     * @hide */
    public ContextHubManager(Context context, Looper mainLooper) throws ServiceNotFoundException {
    /** @hide */
    public ContextHubManager(@NonNull IContextHubService service, @NonNull Looper mainLooper) {
        requireNonNull(service, "service cannot be null");
        requireNonNull(mainLooper, "mainLooper cannot be null");
        mService = service;
        mMainLooper = mainLooper;
        mService = IContextHubService.Stub.asInterface(
                ServiceManager.getServiceOrThrow(Context.CONTEXTHUB_SERVICE));
        try {
            mService.registerCallback(mClientCallback);
        } catch (RemoteException e) {