Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 207f1d30 authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi Committed by Android (Google) Code Review
Browse files

Merge changes I668e8664,Ia44f7e45 into rvc-dev

* changes:
  [incfs] Fix a crash in worker thread calling JNI
  [incfs] Make native library extraction async
parents 2f601f4d 86321400
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -109,4 +109,9 @@ interface IIncrementalService {
     * Setting up native library directories and extract native libs onto a storage.
     * Setting up native library directories and extract native libs onto a storage.
     */
     */
    boolean configureNativeBinaries(int storageId, in @utf8InCpp String apkFullPath, in @utf8InCpp String libDirRelativePath, in @utf8InCpp String abi);
    boolean configureNativeBinaries(int storageId, in @utf8InCpp String apkFullPath, in @utf8InCpp String libDirRelativePath, in @utf8InCpp String abi);

    /**
     * Waits until all native library extraction is done for the storage
     */
    boolean waitForNativeBinariesExtraction(int storageId);
}
}
+14 −0
Original line number Original line Diff line number Diff line
@@ -480,4 +480,18 @@ public final class IncrementalStorage {
            return false;
            return false;
        }
        }
    }
    }

    /**
     * Waits for all native binary extraction operations to complete on the storage.
     *
     * @return Success of not.
     */
    public boolean waitForNativeBinariesExtraction() {
        try {
            return mService.waitForNativeBinariesExtraction(mId);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
            return false;
        }
    }
}
}
+15 −1
Original line number Original line Diff line number Diff line
@@ -26,7 +26,6 @@ import static android.system.OsConstants.S_IXGRP;
import static android.system.OsConstants.S_IXOTH;
import static android.system.OsConstants.S_IXOTH;


import android.content.Context;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.pm.PackageParser;
import android.content.pm.PackageParser;
import android.content.pm.PackageParser.PackageLite;
import android.content.pm.PackageParser.PackageLite;
@@ -40,6 +39,7 @@ import android.os.incremental.IncrementalManager;
import android.os.incremental.IncrementalStorage;
import android.os.incremental.IncrementalStorage;
import android.system.ErrnoException;
import android.system.ErrnoException;
import android.system.Os;
import android.system.Os;
import android.util.ArraySet;
import android.util.Slog;
import android.util.Slog;


import dalvik.system.CloseGuard;
import dalvik.system.CloseGuard;
@@ -545,4 +545,18 @@ public class NativeLibraryHelper {
        }
        }
        return false;
        return false;
    }
    }

    /**
     * Wait for all native library extraction to complete for the passed storages.
     *
     * @param incrementalStorages A list of the storages to wait for.
     */
    public static void waitForNativeBinariesExtraction(
            ArraySet<IncrementalStorage> incrementalStorages) {
        for (int i = 0; i < incrementalStorages.size(); ++i) {
            IncrementalStorage storage = incrementalStorages.valueAtUnchecked(i);
            storage.waitForNativeBinariesExtraction();
        }
    }

}
}
+11 −0
Original line number Original line Diff line number Diff line
@@ -263,6 +263,7 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManager;
import android.os.UserManagerInternal;
import android.os.UserManagerInternal;
import android.os.incremental.IncrementalManager;
import android.os.incremental.IncrementalManager;
import android.os.incremental.IncrementalStorage;
import android.os.storage.DiskInfo;
import android.os.storage.DiskInfo;
import android.os.storage.IStorageManager;
import android.os.storage.IStorageManager;
import android.os.storage.StorageEventListener;
import android.os.storage.StorageEventListener;
@@ -16596,6 +16597,7 @@ public class PackageManagerService extends IPackageManager.Stub
     * locks on {@link #mLock}.
     * locks on {@link #mLock}.
     */
     */
    private void executePostCommitSteps(CommitRequest commitRequest) {
    private void executePostCommitSteps(CommitRequest commitRequest) {
        final ArraySet<IncrementalStorage> incrementalStorages = new ArraySet<>();
        for (ReconciledPackage reconciledPkg : commitRequest.reconciledPackages.values()) {
        for (ReconciledPackage reconciledPkg : commitRequest.reconciledPackages.values()) {
            final boolean instantApp = ((reconciledPkg.scanResult.request.scanFlags
            final boolean instantApp = ((reconciledPkg.scanResult.request.scanFlags
                            & PackageManagerService.SCAN_AS_INSTANT_APP) != 0);
                            & PackageManagerService.SCAN_AS_INSTANT_APP) != 0);
@@ -16603,6 +16605,14 @@ public class PackageManagerService extends IPackageManager.Stub
            final String packageName = pkg.getPackageName();
            final String packageName = pkg.getPackageName();
            final boolean onIncremental = mIncrementalManager != null
            final boolean onIncremental = mIncrementalManager != null
                    && isIncrementalPath(pkg.getCodePath());
                    && isIncrementalPath(pkg.getCodePath());
            if (onIncremental) {
                IncrementalStorage storage = mIncrementalManager.openStorage(pkg.getCodePath());
                if (storage == null) {
                    throw new IllegalArgumentException(
                            "Install: null storage for incremental package " + packageName);
                }
                incrementalStorages.add(storage);
            }
            prepareAppDataAfterInstallLIF(pkg);
            prepareAppDataAfterInstallLIF(pkg);
            if (reconciledPkg.prepareResult.clearCodeCache) {
            if (reconciledPkg.prepareResult.clearCodeCache) {
                clearAppDataLIF(pkg, UserHandle.USER_ALL, FLAG_STORAGE_DE | FLAG_STORAGE_CE
                clearAppDataLIF(pkg, UserHandle.USER_ALL, FLAG_STORAGE_DE | FLAG_STORAGE_CE
@@ -16700,6 +16710,7 @@ public class PackageManagerService extends IPackageManager.Stub
            notifyPackageChangeObserversOnUpdate(reconciledPkg);
            notifyPackageChangeObserversOnUpdate(reconciledPkg);
        }
        }
        NativeLibraryHelper.waitForNativeBinariesExtraction(incrementalStorages);
    }
    }
    private void notifyPackageChangeObserversOnUpdate(ReconciledPackage reconciledPkg) {
    private void notifyPackageChangeObserversOnUpdate(ReconciledPackage reconciledPkg) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -135,7 +135,7 @@ static void android_server_SystemServer_spawnFdLeakCheckThread(JNIEnv*, jobject)


static jlong android_server_SystemServer_startIncrementalService(JNIEnv* env, jclass klass,
static jlong android_server_SystemServer_startIncrementalService(JNIEnv* env, jclass klass,
                                                                 jobject self) {
                                                                 jobject self) {
    return Incremental_IncrementalService_Start();
    return Incremental_IncrementalService_Start(env);
}
}


static void android_server_SystemServer_setIncrementalServiceSystemReady(JNIEnv* env, jclass klass,
static void android_server_SystemServer_setIncrementalServiceSystemReady(JNIEnv* env, jclass klass,
Loading