From fd6e03e567532290d8a62a49fc83bc289adcaebd Mon Sep 17 00:00:00 2001 From: Eric Jeong Date: Wed, 29 Apr 2020 11:51:23 -0700 Subject: [PATCH] Skip managed profile user test when the target is automotive - In Auto, some targets don't support FEATURE_MANAGED_USERS. - The others support the feature, but it is reserved for passenger user. So, creating another managed profile user is not possible. - So, it would be needed to skip tests which temporarily creates a managed user in UserManagerTest.java. - The correction condition to skip the tests in automotive is 1) not headless system user mode OR 2) not passenger enabled. - Knowing whether passenger is enabled needs a dependency to car service, which is not recommended. And, so far, all automotive targets use headless system user. This CL checks 1) condition. Bug: 148540026 Test: atest FrameworksServicesTests: com.android.server.pm.UserManagerTest Change-Id: I3fe028cc2d9b430546ed02c2fc2e50da870bef58 --- .../src/com/android/server/pm/UserManagerTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java index bec37e929a806..6b3ee5adfc328 100644 --- a/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java @@ -802,6 +802,7 @@ public final class UserManagerTest { @Test public void testCreateProfile_withContextUserId() throws Exception { + assumeManagedUsersSupported(); final int primaryUserId = mUserManager.getPrimaryUser().id; UserInfo userProfile = createProfileForUser("Managed 1", @@ -820,6 +821,7 @@ public final class UserManagerTest { @Test public void testSetUserName_withContextUserId() throws Exception { + assumeManagedUsersSupported(); final int primaryUserId = mUserManager.getPrimaryUser().id; UserInfo userInfo1 = createProfileForUser("Managed 1", @@ -855,6 +857,7 @@ public final class UserManagerTest { @Test public void testGetUserIcon_withContextUserId() throws Exception { + assumeManagedUsersSupported(); final int primaryUserId = mUserManager.getPrimaryUser().id; UserInfo userInfo1 = createProfileForUser("Managed 1", @@ -975,8 +978,11 @@ public final class UserManagerTest { } private void assumeManagedUsersSupported() { + // In Automotive, if headless system user is enabled, a managed user cannot be created + // under a primary user. assumeTrue("device doesn't support managed users", - mPackageManager.hasSystemFeature(PackageManager.FEATURE_MANAGED_USERS)); + mPackageManager.hasSystemFeature(PackageManager.FEATURE_MANAGED_USERS) + && (!isAutomotive() || !UserManager.isHeadlessSystemUserMode())); } private boolean isAutomotive() {