Loading core/java/android/app/ApplicationPackageManager.java +6 −10 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.ParcelableException; import android.os.PersistableBundle; import android.os.Process; Loading Loading @@ -126,9 +127,6 @@ import dalvik.system.VMRuntime; import libcore.util.EmptyArray; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.lang.ref.WeakReference; Loading Loading @@ -1233,25 +1231,23 @@ public class ApplicationPackageManager extends PackageManager { public PersistableBundle getAppMetadata(@NonNull String packageName) throws NameNotFoundException { PersistableBundle appMetadata = null; String path = null; ParcelFileDescriptor pfd = null; try { path = mPM.getAppMetadataPath(packageName, getUserId()); pfd = mPM.getAppMetadataFd(packageName, getUserId()); } catch (ParcelableException e) { e.maybeRethrow(NameNotFoundException.class); throw new RuntimeException(e); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } if (path != null) { File file = new File(path); try (InputStream inputStream = new FileInputStream(file)) { if (pfd != null) { try (InputStream inputStream = new ParcelFileDescriptor.AutoCloseInputStream(pfd)) { appMetadata = PersistableBundle.readFromStream(inputStream); } catch (FileNotFoundException e) { // ignore and return empty bundle if app metadata does not exist } catch (IOException e) { throw new RuntimeException(e); } } return appMetadata != null ? appMetadata : new PersistableBundle(); } Loading core/java/android/content/pm/IPackageManager.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -159,7 +159,8 @@ interface IPackageManager { */ ParceledListSlice getInstalledPackages(long flags, in int userId); String getAppMetadataPath(String packageName, int userId); @nullable ParcelFileDescriptor getAppMetadataFd(String packageName, int userId); /** * This implements getPackagesHoldingPermissions via a "last returned row" Loading core/java/android/os/incremental/IIncrementalService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ interface IIncrementalService { /** * Creates a file under a storage. */ int makeFile(int storageId, in @utf8InCpp String path, in IncrementalNewFileParams params, in @nullable byte[] content); int makeFile(int storageId, in @utf8InCpp String path, int mode, in IncrementalNewFileParams params, in @nullable byte[] content); /** * Creates a file under a storage. Content of the file is from a range inside another file. Loading core/java/android/os/incremental/IncrementalFileStorages.java +6 −3 Original line number Diff line number Diff line Loading @@ -153,7 +153,8 @@ public final class IncrementalFileStorages { final String apkName = apk.name; final File targetFile = new File(mStageDir, apkName); if (!targetFile.exists()) { mDefaultStorage.makeFile(apkName, apk.size, null, apk.metadata, apk.signature, null); mDefaultStorage.makeFile(apkName, apk.size, 0777, null, apk.metadata, apk.signature, null); } } Loading @@ -176,8 +177,10 @@ public final class IncrementalFileStorages { /** * Creates file in default storage and sets its content. */ public void makeFile(@NonNull String name, @NonNull byte[] content) throws IOException { mDefaultStorage.makeFile(name, content.length, UUID.randomUUID(), null, null, content); public void makeFile(@NonNull String name, @NonNull byte[] content, @NonNull int mode) throws IOException { mDefaultStorage.makeFile(name, content.length, mode, UUID.randomUUID(), null, null, content); } /** Loading core/java/android/os/incremental/IncrementalStorage.java +3 −3 Original line number Diff line number Diff line Loading @@ -173,11 +173,12 @@ public final class IncrementalStorage { * * @param path Relative path of the new file. * @param size Size of the new file in bytes. * @param mode File access permission mode. * @param metadata Metadata bytes. * @param v4signatureBytes Serialized V4SignatureProto. * @param content Optionally set file content. */ public void makeFile(@NonNull String path, long size, @Nullable UUID id, public void makeFile(@NonNull String path, long size, int mode, @Nullable UUID id, @Nullable byte[] metadata, @Nullable byte[] v4signatureBytes, @Nullable byte[] content) throws IOException { try { Loading @@ -190,7 +191,7 @@ public final class IncrementalStorage { params.metadata = (metadata == null ? new byte[0] : metadata); params.fileId = idToBytes(id); params.signature = v4signatureBytes; int res = mService.makeFile(mId, path, params, content); int res = mService.makeFile(mId, path, mode, params, content); if (res != 0) { throw new IOException("makeFile() failed with errno " + -res); } Loading @@ -199,7 +200,6 @@ public final class IncrementalStorage { } } /** * Creates a file in Incremental storage. The content of the file is mapped from a range inside * a source file in the same storage. Loading Loading
core/java/android/app/ApplicationPackageManager.java +6 −10 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.ParcelableException; import android.os.PersistableBundle; import android.os.Process; Loading Loading @@ -126,9 +127,6 @@ import dalvik.system.VMRuntime; import libcore.util.EmptyArray; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.lang.ref.WeakReference; Loading Loading @@ -1233,25 +1231,23 @@ public class ApplicationPackageManager extends PackageManager { public PersistableBundle getAppMetadata(@NonNull String packageName) throws NameNotFoundException { PersistableBundle appMetadata = null; String path = null; ParcelFileDescriptor pfd = null; try { path = mPM.getAppMetadataPath(packageName, getUserId()); pfd = mPM.getAppMetadataFd(packageName, getUserId()); } catch (ParcelableException e) { e.maybeRethrow(NameNotFoundException.class); throw new RuntimeException(e); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } if (path != null) { File file = new File(path); try (InputStream inputStream = new FileInputStream(file)) { if (pfd != null) { try (InputStream inputStream = new ParcelFileDescriptor.AutoCloseInputStream(pfd)) { appMetadata = PersistableBundle.readFromStream(inputStream); } catch (FileNotFoundException e) { // ignore and return empty bundle if app metadata does not exist } catch (IOException e) { throw new RuntimeException(e); } } return appMetadata != null ? appMetadata : new PersistableBundle(); } Loading
core/java/android/content/pm/IPackageManager.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -159,7 +159,8 @@ interface IPackageManager { */ ParceledListSlice getInstalledPackages(long flags, in int userId); String getAppMetadataPath(String packageName, int userId); @nullable ParcelFileDescriptor getAppMetadataFd(String packageName, int userId); /** * This implements getPackagesHoldingPermissions via a "last returned row" Loading
core/java/android/os/incremental/IIncrementalService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ interface IIncrementalService { /** * Creates a file under a storage. */ int makeFile(int storageId, in @utf8InCpp String path, in IncrementalNewFileParams params, in @nullable byte[] content); int makeFile(int storageId, in @utf8InCpp String path, int mode, in IncrementalNewFileParams params, in @nullable byte[] content); /** * Creates a file under a storage. Content of the file is from a range inside another file. Loading
core/java/android/os/incremental/IncrementalFileStorages.java +6 −3 Original line number Diff line number Diff line Loading @@ -153,7 +153,8 @@ public final class IncrementalFileStorages { final String apkName = apk.name; final File targetFile = new File(mStageDir, apkName); if (!targetFile.exists()) { mDefaultStorage.makeFile(apkName, apk.size, null, apk.metadata, apk.signature, null); mDefaultStorage.makeFile(apkName, apk.size, 0777, null, apk.metadata, apk.signature, null); } } Loading @@ -176,8 +177,10 @@ public final class IncrementalFileStorages { /** * Creates file in default storage and sets its content. */ public void makeFile(@NonNull String name, @NonNull byte[] content) throws IOException { mDefaultStorage.makeFile(name, content.length, UUID.randomUUID(), null, null, content); public void makeFile(@NonNull String name, @NonNull byte[] content, @NonNull int mode) throws IOException { mDefaultStorage.makeFile(name, content.length, mode, UUID.randomUUID(), null, null, content); } /** Loading
core/java/android/os/incremental/IncrementalStorage.java +3 −3 Original line number Diff line number Diff line Loading @@ -173,11 +173,12 @@ public final class IncrementalStorage { * * @param path Relative path of the new file. * @param size Size of the new file in bytes. * @param mode File access permission mode. * @param metadata Metadata bytes. * @param v4signatureBytes Serialized V4SignatureProto. * @param content Optionally set file content. */ public void makeFile(@NonNull String path, long size, @Nullable UUID id, public void makeFile(@NonNull String path, long size, int mode, @Nullable UUID id, @Nullable byte[] metadata, @Nullable byte[] v4signatureBytes, @Nullable byte[] content) throws IOException { try { Loading @@ -190,7 +191,7 @@ public final class IncrementalStorage { params.metadata = (metadata == null ? new byte[0] : metadata); params.fileId = idToBytes(id); params.signature = v4signatureBytes; int res = mService.makeFile(mId, path, params, content); int res = mService.makeFile(mId, path, mode, params, content); if (res != 0) { throw new IOException("makeFile() failed with errno " + -res); } Loading @@ -199,7 +200,6 @@ public final class IncrementalStorage { } } /** * Creates a file in Incremental storage. The content of the file is mapped from a range inside * a source file in the same storage. Loading