FileDocCategorySizeDatePackage
Installer.javaAPI DocAndroid 5.1 API11942Thu Mar 12 22:22:42 GMT 2015com.android.server.pm

Installer

public final class Installer extends com.android.server.SystemService

Fields Summary
private static final String
TAG
private final com.android.internal.os.InstallerConnection
mInstaller
Constructors Summary
public Installer(android.content.Context context)


       
        super(context);
        mInstaller = new InstallerConnection();
    
Methods Summary
public intclearUserData(java.lang.String name, int userId)

        StringBuilder builder = new StringBuilder("rmuserdata");
        builder.append(' ");
        builder.append(name);
        builder.append(' ");
        builder.append(userId);
        return mInstaller.execute(builder.toString());
    
public intcreateUserConfig(int userId)

        StringBuilder builder = new StringBuilder("mkuserconfig");
        builder.append(' ");
        builder.append(userId);
        return mInstaller.execute(builder.toString());
    
public intcreateUserData(java.lang.String name, int uid, int userId, java.lang.String seinfo)

        StringBuilder builder = new StringBuilder("mkuserdata");
        builder.append(' ");
        builder.append(name);
        builder.append(' ");
        builder.append(uid);
        builder.append(' ");
        builder.append(userId);
        builder.append(' ");
        builder.append(seinfo != null ? seinfo : "!");
        return mInstaller.execute(builder.toString());
    
public intdeleteCacheFiles(java.lang.String name, int userId)

        StringBuilder builder = new StringBuilder("rmcache");
        builder.append(' ");
        builder.append(name);
        builder.append(' ");
        builder.append(userId);
        return mInstaller.execute(builder.toString());
    
public intdeleteCodeCacheFiles(java.lang.String name, int userId)

        StringBuilder builder = new StringBuilder("rmcodecache");
        builder.append(' ");
        builder.append(name);
        builder.append(' ");
        builder.append(userId);
        return mInstaller.execute(builder.toString());
    
public intdexopt(java.lang.String apkPath, int uid, boolean isPublic, java.lang.String instructionSet)

        if (!isValidInstructionSet(instructionSet)) {
            Slog.e(TAG, "Invalid instruction set: " + instructionSet);
            return -1;
        }

        return mInstaller.dexopt(apkPath, uid, isPublic, instructionSet);
    
public intdexopt(java.lang.String apkPath, int uid, boolean isPublic, java.lang.String pkgName, java.lang.String instructionSet, boolean vmSafeMode)

        if (!isValidInstructionSet(instructionSet)) {
            Slog.e(TAG, "Invalid instruction set: " + instructionSet);
            return -1;
        }

        return mInstaller.dexopt(apkPath, uid, isPublic, pkgName, instructionSet, vmSafeMode);
    
public intfixUid(java.lang.String name, int uid, int gid)

        StringBuilder builder = new StringBuilder("fixuid");
        builder.append(' ");
        builder.append(name);
        builder.append(' ");
        builder.append(uid);
        builder.append(' ");
        builder.append(gid);
        return mInstaller.execute(builder.toString());
    
public intfreeCache(long freeStorageSize)

        StringBuilder builder = new StringBuilder("freecache");
        builder.append(' ");
        builder.append(String.valueOf(freeStorageSize));
        return mInstaller.execute(builder.toString());
    
public intgetSizeInfo(java.lang.String pkgName, int persona, java.lang.String apkPath, java.lang.String libDirPath, java.lang.String fwdLockApkPath, java.lang.String asecPath, java.lang.String[] instructionSets, android.content.pm.PackageStats pStats)

        for (String instructionSet : instructionSets) {
            if (!isValidInstructionSet(instructionSet)) {
                Slog.e(TAG, "Invalid instruction set: " + instructionSet);
                return -1;
            }
        }

        StringBuilder builder = new StringBuilder("getsize");
        builder.append(' ");
        builder.append(pkgName);
        builder.append(' ");
        builder.append(persona);
        builder.append(' ");
        builder.append(apkPath);
        builder.append(' ");
        // TODO: Extend getSizeInfo to look at the full subdirectory tree,
        // not just the first level.
        builder.append(libDirPath != null ? libDirPath : "!");
        builder.append(' ");
        builder.append(fwdLockApkPath != null ? fwdLockApkPath : "!");
        builder.append(' ");
        builder.append(asecPath != null ? asecPath : "!");
        builder.append(' ");
        // TODO: Extend getSizeInfo to look at *all* instrution sets, not
        // just the primary.
        builder.append(instructionSets[0]);

        String s = mInstaller.transact(builder.toString());
        String res[] = s.split(" ");

        if ((res == null) || (res.length != 5)) {
            return -1;
        }
        try {
            pStats.codeSize = Long.parseLong(res[1]);
            pStats.dataSize = Long.parseLong(res[2]);
            pStats.cacheSize = Long.parseLong(res[3]);
            pStats.externalCodeSize = Long.parseLong(res[4]);
            return Integer.parseInt(res[0]);
        } catch (NumberFormatException e) {
            return -1;
        }
    
public intidmap(java.lang.String targetApkPath, java.lang.String overlayApkPath, int uid)

        StringBuilder builder = new StringBuilder("idmap");
        builder.append(' ");
        builder.append(targetApkPath);
        builder.append(' ");
        builder.append(overlayApkPath);
        builder.append(' ");
        builder.append(uid);
        return mInstaller.execute(builder.toString());
    
public intinstall(java.lang.String name, int uid, int gid, java.lang.String seinfo)

        StringBuilder builder = new StringBuilder("install");
        builder.append(' ");
        builder.append(name);
        builder.append(' ");
        builder.append(uid);
        builder.append(' ");
        builder.append(gid);
        builder.append(' ");
        builder.append(seinfo != null ? seinfo : "!");
        return mInstaller.execute(builder.toString());
    
private static booleanisValidInstructionSet(java.lang.String instructionSet)
Returns true iff. {@code instructionSet} is a valid instruction set.

        if (instructionSet == null) {
            return false;
        }

        for (String abi : Build.SUPPORTED_ABIS) {
            if (instructionSet.equals(VMRuntime.getInstructionSet(abi))) {
                return true;
            }
        }

        return false;
    
public intlinkNativeLibraryDirectory(java.lang.String dataPath, java.lang.String nativeLibPath32, int userId)
Links the 32 bit native library directory in an application's data directory to the real location for backward compatibility. Note that no such symlink is created for 64 bit shared libraries.

return
-1 on error

        if (dataPath == null) {
            Slog.e(TAG, "linkNativeLibraryDirectory dataPath is null");
            return -1;
        } else if (nativeLibPath32 == null) {
            Slog.e(TAG, "linkNativeLibraryDirectory nativeLibPath is null");
            return -1;
        }

        StringBuilder builder = new StringBuilder("linklib ");
        builder.append(dataPath);
        builder.append(' ");
        builder.append(nativeLibPath32);
        builder.append(' ");
        builder.append(userId);

        return mInstaller.execute(builder.toString());
    
public intmarkBootComplete(java.lang.String instructionSet)

        if (!isValidInstructionSet(instructionSet)) {
            Slog.e(TAG, "Invalid instruction set: " + instructionSet);
            return -1;
        }

        StringBuilder builder = new StringBuilder("markbootcomplete");
        builder.append(' ");
        builder.append(instructionSet);
        return mInstaller.execute(builder.toString());
    
public intmoveFiles()

        return mInstaller.execute("movefiles");
    
public intmovedex(java.lang.String srcPath, java.lang.String dstPath, java.lang.String instructionSet)

        if (!isValidInstructionSet(instructionSet)) {
            Slog.e(TAG, "Invalid instruction set: " + instructionSet);
            return -1;
        }

        StringBuilder builder = new StringBuilder("movedex");
        builder.append(' ");
        builder.append(srcPath);
        builder.append(' ");
        builder.append(dstPath);
        builder.append(' ");
        builder.append(instructionSet);
        return mInstaller.execute(builder.toString());
    
public voidonStart()

        Slog.i(TAG, "Waiting for installd to be ready.");
        ping();
    
public intpatchoat(java.lang.String apkPath, int uid, boolean isPublic, java.lang.String pkgName, java.lang.String instructionSet)

        if (!isValidInstructionSet(instructionSet)) {
            Slog.e(TAG, "Invalid instruction set: " + instructionSet);
            return -1;
        }

        return mInstaller.patchoat(apkPath, uid, isPublic, pkgName, instructionSet);
    
public intpatchoat(java.lang.String apkPath, int uid, boolean isPublic, java.lang.String instructionSet)

        if (!isValidInstructionSet(instructionSet)) {
            Slog.e(TAG, "Invalid instruction set: " + instructionSet);
            return -1;
        }

        return mInstaller.patchoat(apkPath, uid, isPublic, instructionSet);
    
public booleanping()

        if (mInstaller.execute("ping") < 0) {
            return false;
        } else {
            return true;
        }
    
public intremove(java.lang.String name, int userId)

        StringBuilder builder = new StringBuilder("remove");
        builder.append(' ");
        builder.append(name);
        builder.append(' ");
        builder.append(userId);
        return mInstaller.execute(builder.toString());
    
public intremoveUserDataDirs(int userId)

        StringBuilder builder = new StringBuilder("rmuser");
        builder.append(' ");
        builder.append(userId);
        return mInstaller.execute(builder.toString());
    
public intrename(java.lang.String oldname, java.lang.String newname)

        StringBuilder builder = new StringBuilder("rename");
        builder.append(' ");
        builder.append(oldname);
        builder.append(' ");
        builder.append(newname);
        return mInstaller.execute(builder.toString());
    
public booleanrestoreconData(java.lang.String pkgName, java.lang.String seinfo, int uid)

        StringBuilder builder = new StringBuilder("restorecondata");
        builder.append(' ");
        builder.append(pkgName);
        builder.append(' ");
        builder.append(seinfo != null ? seinfo : "!");
        builder.append(' ");
        builder.append(uid);
        return (mInstaller.execute(builder.toString()) == 0);
    
public intrmdex(java.lang.String codePath, java.lang.String instructionSet)

        if (!isValidInstructionSet(instructionSet)) {
            Slog.e(TAG, "Invalid instruction set: " + instructionSet);
            return -1;
        }

        StringBuilder builder = new StringBuilder("rmdex");
        builder.append(' ");
        builder.append(codePath);
        builder.append(' ");
        builder.append(instructionSet);
        return mInstaller.execute(builder.toString());