Use ParcelFileDescriptor when calling ART commands.

This change is required by API guidelines.

Bug: 235330409
Test: adb shell pm art get-optimization-status com.google.android.youtube
Change-Id: I857ba31c7ba96df8641e3c7927e8a7eb1e7af1d0
This commit is contained in:
Jiakai Zhang
2022-06-10 20:30:35 +01:00
parent 81a01e9d1d
commit 1ad432e5da

View File

@@ -3414,9 +3414,14 @@ class PackageManagerShellCommand extends ShellCommand {
// Remove the first arg "art" and forward to ART module.
String[] args = getAllArgs();
args = Arrays.copyOfRange(args, 1, args.length);
return LocalManagerRegistry.getManagerOrThrow(ArtManagerLocal.class)
.handleShellCommand(getTarget(), getInFileDescriptor(), getOutFileDescriptor(),
getErrFileDescriptor(), args);
try (var in = ParcelFileDescriptor.dup(getInFileDescriptor());
var out = ParcelFileDescriptor.dup(getOutFileDescriptor());
var err = ParcelFileDescriptor.dup(getErrFileDescriptor())) {
return LocalManagerRegistry.getManagerOrThrow(ArtManagerLocal.class)
.handleShellCommand(getTarget(), in, out, err, args);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
private static String checkAbiArgument(String abi) {