1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.pm; 18 19 import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE; 20 21 import com.android.internal.annotations.VisibleForTesting; 22 import com.android.server.pm.pkg.AndroidPackage; 23 import com.android.server.pm.pkg.PackageStateInternal; 24 25 @VisibleForTesting(visibility = PRIVATE) 26 interface FeatureConfig { 27 28 /** Called when the system is ready and components can be queried. */ onSystemReady()29 void onSystemReady(); 30 31 /** @return true if we should filter apps at all. */ isGloballyEnabled()32 boolean isGloballyEnabled(); 33 34 /** @return true if the feature is enabled for the given package. */ packageIsEnabled(AndroidPackage pkg)35 boolean packageIsEnabled(AndroidPackage pkg); 36 37 /** @return true if debug logging is enabled for the given package. */ isLoggingEnabled(int appId)38 boolean isLoggingEnabled(int appId); 39 40 /** 41 * Turns on logging for the given appId 42 * 43 * @param enable true if logging should be enabled, false if disabled. 44 */ enableLogging(int appId, boolean enable)45 void enableLogging(int appId, boolean enable); 46 47 /** 48 * Initializes the package enablement state for the given package. This gives opportunity 49 * to do any expensive operations ahead of the actual checks. 50 * 51 * @param removed true if adding, false if removing 52 */ updatePackageState(PackageStateInternal setting, boolean removed)53 void updatePackageState(PackageStateInternal setting, boolean removed); 54 snapshot()55 FeatureConfig snapshot(); 56 } 57