1 /* 2 * Copyright (C) 2023 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.app; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.os.SystemProperties; 22 /** 23 * Wrapper interface to access {@link SystemProperties}. 24 * 25 * @hide 26 */ 27 interface GameManagerServiceSystemPropertiesWrapper { 28 /** 29 * Get the String value for the given {@code key}. 30 * 31 * @param key the key to lookup 32 * @param def the default value in case the property is not set or empty 33 * @return if the {@code key} isn't found, return {@code def} if it isn't null, or an empty 34 * string otherwise 35 */ 36 @NonNull get(@onNull String key, @Nullable String def)37 String get(@NonNull String key, @Nullable String def); 38 /** 39 * Get the Boolean value for the given {@code key}. 40 * 41 * @param key the key to lookup 42 * @param def the default value in case the property is not set or empty 43 * @return if the {@code key} isn't found, return {@code def} if it isn't null, not parsable 44 * or an empty string otherwise 45 */ 46 @NonNull getBoolean(@onNull String key, boolean def)47 boolean getBoolean(@NonNull String key, boolean def); 48 49 /** 50 * Get the Integer value for the given {@code key}. 51 * 52 * @param key the key to lookup 53 * @param def the default value in case the property is not set or empty 54 * @return if the {@code key} isn't found, return {@code def} if it isn't null, not parsable 55 * or an empty string otherwise 56 */ 57 @NonNull getInt(@onNull String key, int def)58 int getInt(@NonNull String key, int def); 59 /** 60 * Set the value for the given {@code key} to {@code val}. 61 * 62 * @throws IllegalArgumentException if the {@code val} exceeds 91 characters 63 * @throws RuntimeException if the property cannot be set, for example, if it was blocked by 64 * SELinux. libc will log the underlying reason. 65 */ set(@onNull String key, @Nullable String val)66 void set(@NonNull String key, @Nullable String val); 67 } 68