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

Commit c88b3ce7 authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Guard Context Hub Service on Context Hub feature

Also adds annotation to require the feature.

Bug: 147677675
Test: Compile and flash, verify Context Hub Service is not found if the
feature flag is not defined
Change-Id: Ia718c76ec4308274dc66cfe975e762997e3539ca
parent 351e3b36
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresFeature;
import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
@@ -26,6 +27,7 @@ import android.annotation.SystemService;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.Looper;
@@ -50,6 +52,7 @@ import java.util.concurrent.Executor;
 */
@SystemApi
@SystemService(Context.CONTEXTHUB_SERVICE)
@RequiresFeature(PackageManager.FEATURE_CONTEXTHUB)
public final class ContextHubManager {
    private static final String TAG = "ContextHubManager";

+5 −3
Original line number Diff line number Diff line
@@ -1724,9 +1724,11 @@ public final class SystemServer {
            mSystemServiceManager.startService(SensorNotificationService.class);
            t.traceEnd();

            if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_CONTEXTHUB)) {
                t.traceBegin("StartContextHubSystemService");
                mSystemServiceManager.startService(ContextHubSystemService.class);
                t.traceEnd();
            }

            t.traceBegin("StartDiskStatsService");
            try {