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 package com.android.settings.development.graphicsdriver; 17 18 import android.os.SystemProperties; 19 20 import androidx.annotation.NonNull; 21 import androidx.annotation.Nullable; 22 /** 23 * Wrapper interface to access {@link SystemProperties}. 24 * 25 * @hide 26 */ 27 interface GraphicsDriverSystemPropertiesWrapper { 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 * Set the value for the given {@code key} to {@code val}. 40 * 41 * @throws IllegalArgumentException if the {@code val} exceeds 91 characters 42 * @throws RuntimeException if the property cannot be set, for example, if it was blocked by 43 * SELinux. libc will log the underlying reason. 44 */ set(@onNull String key, @Nullable String val)45 void set(@NonNull String key, @Nullable String val); 46 47 /** 48 * Get the boolean value for the given {@code key}. 49 * 50 * @param key the key to lookup 51 * @param def the default value in case the property is not set or empty 52 * @return if the {@code key} isn't found, return {@code def}. 53 */ getBoolean(@onNull String key, @NonNull boolean def)54 boolean getBoolean(@NonNull String key, @NonNull boolean def); 55 } 56