Search in sources :

Example 1 with InstallerException

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

the class PackageManagerService method prepareAppDataLeafLIF.

private void prepareAppDataLeafLIF(PackageParser.Package pkg, int userId, int flags) {
    if (DEBUG_APP_DATA) {
        Slog.v(TAG, "prepareAppData for " + pkg.packageName + " u" + userId + " 0x" + Integer.toHexString(flags));
    }
    final String volumeUuid = pkg.volumeUuid;
    final String packageName = pkg.packageName;
    final ApplicationInfo app = pkg.applicationInfo;
    final int appId = UserHandle.getAppId(app.uid);
    Preconditions.checkNotNull(app.seinfo);
    try {
        mInstaller.createAppData(volumeUuid, packageName, userId, flags, appId, app.seinfo, app.targetSdkVersion);
    } catch (InstallerException e) {
        if (app.isSystemApp()) {
            logCriticalInfo(Log.ERROR, "Failed to create app data for " + packageName + ", but trying to recover: " + e);
            destroyAppDataLeafLIF(pkg, userId, flags);
            try {
                mInstaller.createAppData(volumeUuid, packageName, userId, flags, appId, app.seinfo, app.targetSdkVersion);
                logCriticalInfo(Log.DEBUG, "Recovery succeeded!");
            } catch (InstallerException e2) {
                logCriticalInfo(Log.DEBUG, "Recovery failed!");
            }
        } else {
            Slog.e(TAG, "Failed to create app data for " + packageName + ": " + e);
        }
    }
    if ((flags & StorageManager.FLAG_STORAGE_CE) != 0) {
        try {
            // CE storage is unlocked right now, so read out the inode and
            // remember for use later when it's locked
            // TODO: mark this structure as dirty so we persist it!
            final long ceDataInode = mInstaller.getAppDataInode(volumeUuid, packageName, userId, StorageManager.FLAG_STORAGE_CE);
            synchronized (mPackages) {
                final PackageSetting ps = mSettings.mPackages.get(packageName);
                if (ps != null) {
                    ps.setCeDataInode(ceDataInode, userId);
                }
            }
        } catch (InstallerException e) {
            Slog.e(TAG, "Failed to find inode for " + packageName + ": " + e);
        }
    }
    prepareAppDataContentsLeafLIF(pkg, userId, flags);
}
Also used : EphemeralApplicationInfo(android.content.pm.EphemeralApplicationInfo) ApplicationInfo(android.content.pm.ApplicationInfo) InstallerException(com.android.internal.os.InstallerConnection.InstallerException)

Example 2 with InstallerException

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

the class ActivityManagerService method finishBooting.

final void finishBooting() {
    synchronized (this) {
        if (!mBootAnimationComplete) {
            mCallFinishBooting = true;
            return;
        }
        mCallFinishBooting = false;
    }
    ArraySet<String> completedIsas = new ArraySet<String>();
    for (String abi : Build.SUPPORTED_ABIS) {
        Process.establishZygoteConnectionForAbi(abi);
        final String instructionSet = VMRuntime.getInstructionSet(abi);
        if (!completedIsas.contains(instructionSet)) {
            try {
                mInstaller.markBootComplete(VMRuntime.getInstructionSet(abi));
            } catch (InstallerException e) {
                Slog.w(TAG, "Unable to mark boot complete for abi: " + abi + " (" + e.getMessage() + ")");
            }
            completedIsas.add(instructionSet);
        }
    }
    IntentFilter pkgFilter = new IntentFilter();
    pkgFilter.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART);
    pkgFilter.addDataScheme("package");
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String[] pkgs = intent.getStringArrayExtra(Intent.EXTRA_PACKAGES);
            if (pkgs != null) {
                for (String pkg : pkgs) {
                    synchronized (ActivityManagerService.this) {
                        if (forceStopPackageLocked(pkg, -1, false, false, false, false, false, 0, "query restart")) {
                            setResultCode(Activity.RESULT_OK);
                            return;
                        }
                    }
                }
            }
        }
    }, pkgFilter);
    IntentFilter dumpheapFilter = new IntentFilter();
    dumpheapFilter.addAction(DumpHeapActivity.ACTION_DELETE_DUMPHEAP);
    mContext.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getBooleanExtra(DumpHeapActivity.EXTRA_DELAY_DELETE, false)) {
                mHandler.sendEmptyMessageDelayed(POST_DUMP_HEAP_NOTIFICATION_MSG, 5 * 60 * 1000);
            } else {
                mHandler.sendEmptyMessage(POST_DUMP_HEAP_NOTIFICATION_MSG);
            }
        }
    }, dumpheapFilter);
    // Let system services know.
    mSystemServiceManager.startBootPhase(SystemService.PHASE_BOOT_COMPLETED);
    synchronized (this) {
        // Ensure that any processes we had put on hold are now started
        // up.
        final int NP = mProcessesOnHold.size();
        if (NP > 0) {
            ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>(mProcessesOnHold);
            for (int ip = 0; ip < NP; ip++) {
                if (DEBUG_PROCESSES)
                    Slog.v(TAG_PROCESSES, "Starting process on hold: " + procs.get(ip));
                startProcessLocked(procs.get(ip), "on-hold", null);
            }
        }
        if (mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
            // Start looking for apps that are abusing wake locks.
            Message nmsg = mHandler.obtainMessage(CHECK_EXCESSIVE_WAKE_LOCKS_MSG);
            mHandler.sendMessageDelayed(nmsg, POWER_CHECK_DELAY);
            // Tell anyone interested that we are done booting!
            SystemProperties.set("sys.boot_completed", "1");
            // And trigger dev.bootcomplete if we are not showing encryption progress
            if (!"trigger_restart_min_framework".equals(SystemProperties.get("vold.decrypt")) || "".equals(SystemProperties.get("vold.encrypt_progress"))) {
                SystemProperties.set("dev.bootcomplete", "1");
            }
            mUserController.sendBootCompletedLocked(new IIntentReceiver.Stub() {

                @Override
                public void performReceive(Intent intent, int resultCode, String data, Bundle extras, boolean ordered, boolean sticky, int sendingUser) {
                    synchronized (ActivityManagerService.this) {
                        requestPssAllProcsLocked(SystemClock.uptimeMillis(), true, false);
                    }
                }
            });
            scheduleStartProfilesLocked();
        }
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) ArraySet(android.util.ArraySet) Message(android.os.Message) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) ArrayList(java.util.ArrayList) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) Point(android.graphics.Point) IIntentReceiver(android.content.IIntentReceiver) InstallerException(com.android.internal.os.InstallerConnection.InstallerException)

Example 3 with InstallerException

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

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 4 with InstallerException

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

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 5 with InstallerException

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

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