Search in sources :

Example 6 with VUserInfo

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);
}
Also used : VUserInfo(com.lody.virtual.os.VUserInfo)

Example 7 with VUserInfo

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();
            }
        }
    }
}
Also used : AtomicFile(com.lody.virtual.helper.utils.AtomicFile) XmlPullParser(org.xmlpull.v1.XmlPullParser) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) VUserInfo(com.lody.virtual.os.VUserInfo)

Example 8 with VUserInfo

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);
}
Also used : VUserInfo(com.lody.virtual.os.VUserInfo)

Example 9 with VUserInfo

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);
        }
    }
}
Also used : VUserInfo(com.lody.virtual.os.VUserInfo)

Example 10 with VUserInfo

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);
    }
}
Also used : VUserInfo(com.lody.virtual.os.VUserInfo)

Aggregations

VUserInfo (com.lody.virtual.os.VUserInfo)12 AtomicFile (com.lody.virtual.helper.utils.AtomicFile)4 IOException (java.io.IOException)4 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 XmlPullParser (org.xmlpull.v1.XmlPullParser)2 Activity (android.app.Activity)1 IStopUserCallback (android.app.IStopUserCallback)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 VirtualCore (com.lody.virtual.client.core.VirtualCore)1 FastXmlSerializer (com.lody.virtual.helper.utils.FastXmlSerializer)1 VUserManager (com.lody.virtual.os.VUserManager)1 InstallResult (com.lody.virtual.remote.InstallResult)1 InstalledAppInfo (com.lody.virtual.remote.InstalledAppInfo)1 VCommends (io.virtualapp.VCommends)1 VUiKit (io.virtualapp.abs.ui.VUiKit)1 AppData (io.virtualapp.home.models.AppData)1 AppInfoLite (io.virtualapp.home.models.AppInfoLite)1