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

Commit fc990b40 authored by Jason Parks's avatar Jason Parks Committed by Android (Google) Code Review
Browse files

Merge "Create a stub for SupervisionService." into main

parents da0d38eb 8beaf2ce
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ aconfig_declarations_group {
        "android.app.flags-aconfig-java",
        "android.app.ondeviceintelligence-aconfig-java",
        "android.app.smartspace.flags-aconfig-java",
        "android.app.supervision.flags-aconfig-java",
        "android.app.usage.flags-aconfig-java",
        "android.app.wearable.flags-aconfig-java",
        "android.appwidget.flags-aconfig-java",
@@ -1212,6 +1213,21 @@ java_aconfig_library {
    defaults: ["framework-minus-apex-aconfig-java-defaults"],
}

// Supervision
aconfig_declarations {
    name: "android.app.supervision.flags-aconfig",
    exportable: true,
    package: "android.app.supervision.flags",
    container: "system",
    srcs: ["core/java/android/app/supervision/flags.aconfig"],
}

java_aconfig_library {
    name: "android.app.supervision.flags-aconfig-java",
    aconfig_declarations: "android.app.supervision.flags-aconfig",
    defaults: ["framework-minus-apex-aconfig-java-defaults"],
}

// SurfaceFlinger
java_aconfig_library {
    name: "surfaceflinger_flags_java_lib",
+17 −0
Original line number Diff line number Diff line
@@ -48,6 +48,8 @@ import android.app.sdksandbox.SdkSandboxManagerFrameworkInitializer;
import android.app.search.SearchUiManager;
import android.app.slice.SliceManager;
import android.app.smartspace.SmartspaceManager;
import android.app.supervision.ISupervisionManager;
import android.app.supervision.SupervisionManager;
import android.app.time.TimeManager;
import android.app.timedetector.TimeDetector;
import android.app.timedetector.TimeDetectorImpl;
@@ -1703,6 +1705,21 @@ public final class SystemServiceRegistry {
                        return new E2eeContactKeysManager(ctx);
                    }});

        registerService(Context.SUPERVISION_SERVICE, SupervisionManager.class,
                new CachedServiceFetcher<>() {
                    @Override
                    public SupervisionManager createService(ContextImpl ctx)
                            throws ServiceNotFoundException {
                        if (!android.app.supervision.flags.Flags.supervisionApi()) {
                            throw new ServiceNotFoundException(
                                    "SupervisionManager is not supported");
                        }
                        IBinder iBinder = ServiceManager.getServiceOrThrow(
                                Context.SUPERVISION_SERVICE);
                        ISupervisionManager service = ISupervisionManager.Stub.asInterface(iBinder);
                        return new SupervisionManager(ctx, service);
                    }
                });
        // DO NOT do a flag check like this unless the flag is read-only.
        // (because this code is executed during preload in zygote.)
        // If the flag is mutable, the check should be inside CachedServiceFetcher.
+25 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2024, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app.supervision;

/**
 * Internal IPC interface to the supervision service.
 * {@hide}
 */
interface ISupervisionManager {
    boolean isSupervisionEnabled();
}
+57 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app.supervision;

import android.annotation.SystemService;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.os.RemoteException;

/**
 * Service for handling parental supervision.
 *
 * @hide
 */
@SystemService(Context.SUPERVISION_SERVICE)
public class SupervisionManager {
    private final Context mContext;
    private final ISupervisionManager mService;

    /**
     * @hide
     */
    @UnsupportedAppUsage
    public SupervisionManager(Context context, ISupervisionManager service) {
        mContext = context;
        mService = service;
    }

    /**
     * Returns whether the device is supervised.
     *
     * @hide
     */
    public boolean isSupervisionEnabled() {
        try {
            return mService.isSupervisionEnabled();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }


}
+10 −0
Original line number Diff line number Diff line
package: "android.app.supervision.flags"
container: "system"

flag {
  name: "supervision_api"
  is_exported: true
  namespace: "supervision"
  description: "Flag to enable the SupervisionService"
  bug: "340351729"
}
 No newline at end of file
Loading