Checking for storage space before adding user
If storage space is low, trying to create a user results in a crash. Adding a check to abort user creation and log a warning in such a case. Bug: 30270050 Change-Id: I121119aed340c7be337b2147c4386c9bb9f8ffdc
This commit is contained in:
@@ -95,7 +95,7 @@ import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.am.UserState;
|
||||
|
||||
import com.android.server.storage.DeviceStorageMonitorInternal;
|
||||
import libcore.io.IoUtils;
|
||||
import libcore.util.Objects;
|
||||
|
||||
@@ -2184,6 +2184,12 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
Log.w(LOG_TAG, "Cannot add user. DISALLOW_ADD_USER is enabled.");
|
||||
return null;
|
||||
}
|
||||
DeviceStorageMonitorInternal dsm = LocalServices
|
||||
.getService(DeviceStorageMonitorInternal.class);
|
||||
if (dsm.isMemoryLow()) {
|
||||
Log.w(LOG_TAG, "Cannot add user. Not enough space on disk.");
|
||||
return null;
|
||||
}
|
||||
return createUserInternalUnchecked(name, flags, parentId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user