Search in sources :

Example 6 with InstallerException

use of com.android.internal.os.InstallerConnection.InstallerException in project android_frameworks_base by DirtyUnicorns.

the class Installer method getAppSize.

public void getAppSize(String uuid, String pkgname, int userid, int flags, long ceDataInode, String codePath, PackageStats stats) throws InstallerException {
    final String[] res = mInstaller.execute("get_app_size", uuid, pkgname, userid, flags, ceDataInode, codePath);
    try {
        stats.codeSize += Long.parseLong(res[1]);
        stats.dataSize += Long.parseLong(res[2]);
        stats.cacheSize += Long.parseLong(res[3]);
    } catch (ArrayIndexOutOfBoundsException | NumberFormatException e) {
        throw new InstallerException("Invalid size result: " + Arrays.toString(res));
    }
}
Also used : InstallerException(com.android.internal.os.InstallerConnection.InstallerException)

Example 7 with InstallerException

use of com.android.internal.os.InstallerConnection.InstallerException in project android_frameworks_base by DirtyUnicorns.

the class PackageInstallerSession method destroyInternal.

private void destroyInternal() {
    synchronized (mLock) {
        mSealed = true;
        mDestroyed = true;
        // Force shut down all bridges
        for (FileBridge bridge : mBridges) {
            bridge.forceClose();
        }
    }
    if (stageDir != null) {
        try {
            mPm.mInstaller.rmPackageDir(stageDir.getAbsolutePath());
        } catch (InstallerException ignored) {
        }
    }
    if (stageCid != null) {
        PackageHelper.destroySdDir(stageCid);
    }
}
Also used : FileBridge(android.os.FileBridge) InstallerException(com.android.internal.os.InstallerConnection.InstallerException)

Example 8 with InstallerException

use of com.android.internal.os.InstallerConnection.InstallerException in project android_frameworks_base by DirtyUnicorns.

the class PackageManagerService method prepareAppDataContentsLeafLIF.

private void prepareAppDataContentsLeafLIF(PackageParser.Package pkg, int userId, int flags) {
    final String volumeUuid = pkg.volumeUuid;
    final String packageName = pkg.packageName;
    final ApplicationInfo app = pkg.applicationInfo;
    if ((flags & StorageManager.FLAG_STORAGE_CE) != 0) {
        // this symlink for 64 bit libraries.
        if (app.primaryCpuAbi != null && !VMRuntime.is64BitAbi(app.primaryCpuAbi)) {
            final String nativeLibPath = app.nativeLibraryDir;
            try {
                mInstaller.linkNativeLibraryDirectory(volumeUuid, packageName, nativeLibPath, userId);
            } catch (InstallerException e) {
                Slog.e(TAG, "Failed to link native for " + packageName + ": " + e);
            }
        }
    }
}
Also used : EphemeralApplicationInfo(android.content.pm.EphemeralApplicationInfo) ApplicationInfo(android.content.pm.ApplicationInfo) InstallerException(com.android.internal.os.InstallerConnection.InstallerException)

Example 9 with InstallerException

use of com.android.internal.os.InstallerConnection.InstallerException in project android_frameworks_base by DirtyUnicorns.

the class PackageManagerService method reconcileAppsDataLI.

/**
     * Reconcile all app data on given mounted volume.
     * <p>
     * Destroys app data that isn't expected, either due to uninstallation or
     * reinstallation on another volume.
     * <p>
     * Verifies that directories exist and that ownership and labeling is
     * correct for all installed apps.
     */
private void reconcileAppsDataLI(String volumeUuid, int userId, int flags) {
    Slog.v(TAG, "reconcileAppsData for " + volumeUuid + " u" + userId + " 0x" + Integer.toHexString(flags));
    final File ceDir = Environment.getDataUserCeDirectory(volumeUuid, userId);
    final File deDir = Environment.getDataUserDeDirectory(volumeUuid, userId);
    // have changed since we did our last restorecon
    if ((flags & StorageManager.FLAG_STORAGE_CE) != 0) {
        if (StorageManager.isFileEncryptedNativeOrEmulated() && !StorageManager.isUserKeyUnlocked(userId)) {
            throw new RuntimeException("Yikes, someone asked us to reconcile CE storage while " + userId + " was still locked; this would have caused massive data loss!");
        }
        final File[] files = FileUtils.listFilesOrEmpty(ceDir);
        for (File file : files) {
            final String packageName = file.getName();
            try {
                assertPackageKnownAndInstalled(volumeUuid, packageName, userId);
            } catch (PackageManagerException e) {
                logCriticalInfo(Log.WARN, "Destroying " + file + " due to: " + e);
                try {
                    mInstaller.destroyAppData(volumeUuid, packageName, userId, StorageManager.FLAG_STORAGE_CE, 0);
                } catch (InstallerException e2) {
                    logCriticalInfo(Log.WARN, "Failed to destroy: " + e2);
                }
            }
        }
    }
    if ((flags & StorageManager.FLAG_STORAGE_DE) != 0) {
        final File[] files = FileUtils.listFilesOrEmpty(deDir);
        for (File file : files) {
            final String packageName = file.getName();
            try {
                assertPackageKnownAndInstalled(volumeUuid, packageName, userId);
            } catch (PackageManagerException e) {
                logCriticalInfo(Log.WARN, "Destroying " + file + " due to: " + e);
                try {
                    mInstaller.destroyAppData(volumeUuid, packageName, userId, StorageManager.FLAG_STORAGE_DE, 0);
                } catch (InstallerException e2) {
                    logCriticalInfo(Log.WARN, "Failed to destroy: " + e2);
                }
            }
        }
    }
    // Ensure that data directories are ready to roll for all packages
    // installed for this volume and user
    final List<PackageSetting> packages;
    synchronized (mPackages) {
        packages = mSettings.getVolumePackagesLPr(volumeUuid);
    }
    int preparedCount = 0;
    for (PackageSetting ps : packages) {
        final String packageName = ps.name;
        if (ps.pkg == null) {
            Slog.w(TAG, "Odd, missing scanned package " + packageName);
            // and reconcile again once they're scanned
            continue;
        }
        if (ps.getInstalled(userId)) {
            prepareAppDataLIF(ps.pkg, userId, flags);
            if (maybeMigrateAppDataLIF(ps.pkg, userId)) {
                // We may have just shuffled around app data directories, so
                // prepare them one more time
                prepareAppDataLIF(ps.pkg, userId, flags);
            }
            preparedCount++;
        }
    }
    Slog.v(TAG, "reconcileAppsData finished " + preparedCount + " packages");
}
Also used : InstallerException(com.android.internal.os.InstallerConnection.InstallerException) PackageParser.isApkFile(android.content.pm.PackageParser.isApkFile) File(java.io.File) DexFile(dalvik.system.DexFile) StrictJarFile(android.util.jar.StrictJarFile)

Example 10 with InstallerException

use of com.android.internal.os.InstallerConnection.InstallerException in project android_frameworks_base by AOSPA.

the class Installer method getAppSize.

public void getAppSize(String uuid, String pkgname, int userid, int flags, long ceDataInode, String codePath, PackageStats stats) throws InstallerException {
    final String[] res = mInstaller.execute("get_app_size", uuid, pkgname, userid, flags, ceDataInode, codePath);
    try {
        stats.codeSize += Long.parseLong(res[1]);
        stats.dataSize += Long.parseLong(res[2]);
        stats.cacheSize += Long.parseLong(res[3]);
    } catch (ArrayIndexOutOfBoundsException | NumberFormatException e) {
        throw new InstallerException("Invalid size result: " + Arrays.toString(res));
    }
}
Also used : InstallerException(com.android.internal.os.InstallerConnection.InstallerException)

Aggregations

InstallerException (com.android.internal.os.InstallerConnection.InstallerException)12 FileBridge (android.os.FileBridge)4 ApplicationInfo (android.content.pm.ApplicationInfo)2 EphemeralApplicationInfo (android.content.pm.EphemeralApplicationInfo)2 PendingIntent (android.app.PendingIntent)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 IIntentReceiver (android.content.IIntentReceiver)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 PackageParser.isApkFile (android.content.pm.PackageParser.isApkFile)1 Point (android.graphics.Point)1 Bundle (android.os.Bundle)1 Message (android.os.Message)1 PersistableBundle (android.os.PersistableBundle)1 ArraySet (android.util.ArraySet)1 StrictJarFile (android.util.jar.StrictJarFile)1 DexFile (dalvik.system.DexFile)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1