1 /* 2 * Copyright (C) 2016 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.multiuser.cts; 18 19 20 import android.cts.util.SystemUtil; 21 import android.os.UserManager; 22 import android.test.InstrumentationTestCase; 23 import android.util.Log; 24 25 public class SplitSystemUserTest extends InstrumentationTestCase { 26 27 private static final String TAG = SplitSystemUserTest.class.getSimpleName(); 28 testSplitSystemUserIsDisabled()29 public void testSplitSystemUserIsDisabled() throws Exception { 30 // Verify that am get-current-user and UserManager.isSystemUser both return 0 31 String curUser = SystemUtil.runShellCommand(getInstrumentation(), "am get-current-user"); 32 Log.i(TAG, "am get-current-user: " + curUser); 33 assertEquals("Test must be running under user 0", "0", trim(curUser)); 34 UserManager um = getInstrumentation().getContext().getSystemService(UserManager.class); 35 assertTrue("Test must be running under system user", um.isSystemUser()); 36 37 // Check that ro.fw.system_user_split property is not set 38 String splitEnabledStr = trim(SystemUtil.runShellCommand(getInstrumentation(), 39 "getprop ro.fw.system_user_split")); 40 boolean splitEnabled = "y".equals(splitEnabledStr) || "yes".equals(splitEnabledStr) 41 || "1".equals(splitEnabledStr) || "true".equals(splitEnabledStr) 42 || "on".equals(splitEnabledStr); 43 assertFalse("ro.fw.system_user_split must not be enabled", splitEnabled); 44 } 45 trim(String s)46 private static String trim(String s) { 47 return s == null ? null : s.trim(); 48 } 49 } 50