Disable add accounts for user 0.
Bug: 79535560
Test: Unit test
Change-Id: Ib0f04ee28829c60e46fbc378b04917a04a52c5ae
diff --git a/service/src/com/android/car/user/CarUserService.java b/service/src/com/android/car/user/CarUserService.java
index b80d2d3..a666210 100644
--- a/service/src/com/android/car/user/CarUserService.java
+++ b/service/src/com/android/car/user/CarUserService.java
@@ -23,6 +23,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.UserInfo;
+import android.os.UserManager;
import android.util.Log;
import com.android.car.CarServiceBase;
@@ -88,6 +89,10 @@
if (intent.getAction() == Intent.ACTION_LOCKED_BOOT_COMPLETED) {
if (mCarUserManagerHelper.getAllUsers().size() == 0) {
+ // Disable adding accounts for user 0.
+ mCarUserManagerHelper.setUserRestriction(mCarUserManagerHelper.getSystemUserInfo(),
+ UserManager.DISALLOW_MODIFY_ACCOUNTS, true);
+ // On very first boot, create an admin user and switch to that user.
UserInfo admin = mCarUserManagerHelper.createNewAdminUser(OWNER_NAME);
mCarUserManagerHelper.switchToUser(admin);
} else {