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.cellbroadcastreceiver.compliancetests; 18 19 import org.json.JSONException; 20 import org.json.JSONObject; 21 22 public class CellBroadcastSettingTestConfig implements ITestConfig { 23 private static final String SETTING_TOGGLE_AVAIL = "toggle_avail"; 24 private static final String SETTING_DEFAULT_VALUE = "default_value"; 25 private static final String SETTING_SUMMARY = "summary"; 26 27 public boolean mIsToggleAvailability = true; 28 public boolean mExpectedSwitchValue; 29 public String mSummary; 30 CellBroadcastSettingTestConfig(JSONObject settingsForCarrier, String settingName)31 public CellBroadcastSettingTestConfig(JSONObject settingsForCarrier, String settingName) 32 throws JSONException { 33 JSONObject object = settingsForCarrier.getJSONObject(settingName); 34 String toggleAvail = object.getString(SETTING_TOGGLE_AVAIL); 35 String defaultToggle = object.getString(SETTING_DEFAULT_VALUE); 36 if (toggleAvail != null && toggleAvail.equals("false")) { 37 mIsToggleAvailability = false; 38 } 39 mExpectedSwitchValue = defaultToggle != null && defaultToggle.equals("true"); 40 mSummary = getObjectString(object, SETTING_SUMMARY); 41 } 42 } 43