Loading services/core/java/com/android/server/pm/StagingManager.java +8 −8 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.ParcelableException; import android.os.PowerManager; import android.os.RemoteException; import android.os.ServiceManager; Loading Loading @@ -414,29 +415,28 @@ public class StagingManager { } else { params.installFlags |= PackageManager.INSTALL_DISABLE_VERIFICATION; } try { int apkSessionId = mPi.createSession( params, originalSession.getInstallerPackageName(), 0 /* UserHandle.SYSTEM */); PackageInstallerSession apkSession = mPi.getSession(apkSessionId); try { apkSession.open(); for (String apkFilePath : apkFilePaths) { File apkFile = new File(apkFilePath); ParcelFileDescriptor pfd = ParcelFileDescriptor.open(apkFile, ParcelFileDescriptor.MODE_READ_ONLY); long sizeBytes = pfd.getStatSize(); long sizeBytes = (pfd == null) ? -1 : pfd.getStatSize(); if (sizeBytes < 0) { Slog.e(TAG, "Unable to get size of: " + apkFilePath); return null; } apkSession.write(apkFile.getName(), 0, sizeBytes, pfd); } } catch (IOException e) { return apkSession; } catch (IOException | ParcelableException e) { Slog.e(TAG, "Failure to install APK staged session " + originalSession.sessionId, e); return null; } return apkSession; } private boolean commitApkSession(@NonNull PackageInstallerSession apkSession, Loading Loading
services/core/java/com/android/server/pm/StagingManager.java +8 −8 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.ParcelableException; import android.os.PowerManager; import android.os.RemoteException; import android.os.ServiceManager; Loading Loading @@ -414,29 +415,28 @@ public class StagingManager { } else { params.installFlags |= PackageManager.INSTALL_DISABLE_VERIFICATION; } try { int apkSessionId = mPi.createSession( params, originalSession.getInstallerPackageName(), 0 /* UserHandle.SYSTEM */); PackageInstallerSession apkSession = mPi.getSession(apkSessionId); try { apkSession.open(); for (String apkFilePath : apkFilePaths) { File apkFile = new File(apkFilePath); ParcelFileDescriptor pfd = ParcelFileDescriptor.open(apkFile, ParcelFileDescriptor.MODE_READ_ONLY); long sizeBytes = pfd.getStatSize(); long sizeBytes = (pfd == null) ? -1 : pfd.getStatSize(); if (sizeBytes < 0) { Slog.e(TAG, "Unable to get size of: " + apkFilePath); return null; } apkSession.write(apkFile.getName(), 0, sizeBytes, pfd); } } catch (IOException e) { return apkSession; } catch (IOException | ParcelableException e) { Slog.e(TAG, "Failure to install APK staged session " + originalSession.sessionId, e); return null; } return apkSession; } private boolean commitApkSession(@NonNull PackageInstallerSession apkSession, Loading