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 android.provider; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 22 import android.annotation.SystemService; 23 import android.os.RemoteException; 24 import android.provider.aidl.IDeviceConfigManager; 25 26 import java.util.HashMap; 27 import java.util.Map; 28 29 /** 30 * @hide 31 */ 32 @SystemService(DeviceConfig.SERVICE_NAME) 33 public class DeviceConfigManager { 34 35 private IDeviceConfigManager mService; 36 DeviceConfigManager(@onNull IDeviceConfigManager service)37 public DeviceConfigManager(@NonNull IDeviceConfigManager service) { 38 mService = service; 39 } 40 41 @NonNull getProperties(@onNull String namespace, @NonNull String... names)42 public DeviceConfig.Properties getProperties(@NonNull String namespace, 43 @NonNull String... names) { 44 try { 45 Map<String, String> map = mService.getProperties(namespace, names); 46 return new DeviceConfig.Properties(namespace, map); 47 } catch (RemoteException e) { 48 throw e.rethrowFromSystemServer(); 49 } 50 } 51 setProperties(@onNull String namespace, @NonNull Map<String, String> values)52 public boolean setProperties(@NonNull String namespace, @NonNull Map<String, String> values) { 53 try { 54 return mService.setProperties(namespace, values); 55 } catch (RemoteException e) { 56 throw e.rethrowFromSystemServer(); 57 } 58 } 59 setProperty(@onNull String namespace, @NonNull String name, @Nullable String value, boolean makeDefault)60 public boolean setProperty(@NonNull String namespace, @NonNull String name, 61 @Nullable String value, boolean makeDefault) { 62 try { 63 return mService.setProperty(namespace, name, value, makeDefault); 64 } catch (RemoteException e) { 65 throw e.rethrowFromSystemServer(); 66 } 67 } 68 deleteProperty(@onNull String namespace, @NonNull String name)69 public boolean deleteProperty(@NonNull String namespace, @NonNull String name) { 70 try { 71 return mService.deleteProperty(namespace, name); 72 } catch (RemoteException e) { 73 throw e.rethrowFromSystemServer(); 74 } 75 } 76 } 77