1 /* 2 * Copyright (C) 2021 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 android.multiuser.cts; 17 18 import static com.android.compatibility.common.util.SystemUtil.runShellCommand; 19 20 import android.app.Instrumentation; 21 22 import java.io.IOException; 23 24 final class TestingUtils { 25 getBooleanProperty(Instrumentation instrumentation, String property)26 public static boolean getBooleanProperty(Instrumentation instrumentation, String property) 27 throws IOException { 28 String value = trim(runShellCommand(instrumentation, "getprop " + property)); 29 return "y".equals(value) || "yes".equals(value) || "1".equals(value) || "true".equals(value) 30 || "on".equals(value); 31 } 32 trim(String s)33 private static String trim(String s) { 34 return s == null ? null : s.trim(); 35 } 36 TestingUtils()37 private TestingUtils() { 38 throw new UnsupportedOperationException("contains only static methods"); 39 } 40 } 41