use of com.lody.virtual.os.VUserInfo in project VirtualApp by asLody.
the class VUserManagerService method fallbackToSingleUserLocked.
private void fallbackToSingleUserLocked() {
// Create the primary user
VUserInfo primary = new VUserInfo(0, mContext.getResources().getString(R.string.owner_name), null, VUserInfo.FLAG_ADMIN | VUserInfo.FLAG_PRIMARY | VUserInfo.FLAG_INITIALIZED);
mUsers.put(0, primary);
mNextSerialNumber = MIN_USER_ID;
updateUserIdsLocked();
writeUserListLocked();
writeUserLocked(primary);
}
use of com.lody.virtual.os.VUserInfo in project VirtualApp by asLody.
the class VUserManagerService method readUserListLocked.
private void readUserListLocked() {
mGuestEnabled = false;
if (!mUserListFile.exists()) {
fallbackToSingleUserLocked();
return;
}
FileInputStream fis = null;
AtomicFile userListFile = new AtomicFile(mUserListFile);
try {
fis = userListFile.openRead();
XmlPullParser parser = Xml.newPullParser();
parser.setInput(fis, null);
int type;
while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) {
;
}
if (type != XmlPullParser.START_TAG) {
VLog.e(LOG_TAG, "Unable to read user list");
fallbackToSingleUserLocked();
return;
}
mNextSerialNumber = -1;
if (parser.getName().equals(TAG_USERS)) {
String lastSerialNumber = parser.getAttributeValue(null, ATTR_NEXT_SERIAL_NO);
if (lastSerialNumber != null) {
mNextSerialNumber = Integer.parseInt(lastSerialNumber);
}
String versionNumber = parser.getAttributeValue(null, ATTR_USER_VERSION);
if (versionNumber != null) {
mUserVersion = Integer.parseInt(versionNumber);
}
}
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) {
if (type == XmlPullParser.START_TAG && parser.getName().equals(TAG_USER)) {
String id = parser.getAttributeValue(null, ATTR_ID);
VUserInfo user = readUser(Integer.parseInt(id));
if (user != null) {
mUsers.put(user.id, user);
if (user.isGuest()) {
mGuestEnabled = true;
}
if (mNextSerialNumber < 0 || mNextSerialNumber <= user.id) {
mNextSerialNumber = user.id + 1;
}
}
}
}
updateUserIdsLocked();
upgradeIfNecessary();
} catch (IOException ioe) {
fallbackToSingleUserLocked();
} catch (XmlPullParserException pe) {
fallbackToSingleUserLocked();
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
use of com.lody.virtual.os.VUserInfo in project VirtualApp by asLody.
the class VUserManagerService method setUserIcon.
@Override
public void setUserIcon(int userId, Bitmap bitmap) {
checkManageUsersPermission("update users");
synchronized (mPackagesLock) {
VUserInfo info = mUsers.get(userId);
if (info == null || info.partial) {
VLog.w(LOG_TAG, "setUserIcon: unknown user #" + userId);
return;
}
writeBitmapLocked(info, bitmap);
writeUserLocked(info);
}
sendUserInfoChangedBroadcast(userId);
}
use of com.lody.virtual.os.VUserInfo in project VirtualApp by asLody.
the class VUserManagerService method makeInitialized.
public void makeInitialized(int userId) {
checkManageUsersPermission("makeInitialized");
synchronized (mPackagesLock) {
VUserInfo info = mUsers.get(userId);
if (info == null || info.partial) {
VLog.w(LOG_TAG, "makeInitialized: unknown user #" + userId);
}
if ((info.flags & VUserInfo.FLAG_INITIALIZED) == 0) {
info.flags |= VUserInfo.FLAG_INITIALIZED;
writeUserLocked(info);
}
}
}
use of com.lody.virtual.os.VUserInfo in project VirtualApp by asLody.
the class VUserManagerService method setUserName.
@Override
public void setUserName(int userId, String name) {
checkManageUsersPermission("rename users");
boolean changed = false;
synchronized (mPackagesLock) {
VUserInfo info = mUsers.get(userId);
if (info == null || info.partial) {
VLog.w(LOG_TAG, "setUserName: unknown user #" + userId);
return;
}
if (name != null && !name.equals(info.name)) {
info.name = name;
writeUserLocked(info);
changed = true;
}
}
if (changed) {
sendUserInfoChangedBroadcast(userId);
}
}
Aggregations