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

Commit 73fde380 authored by Kyeongkab.Nam's avatar Kyeongkab.Nam
Browse files

Use ParcelFileDescriptor over FileDescriptor

The java.io.FileDescriptor object has a poor definition of ownership,
which can result in obscure use-after-close bugs. Instead, APIs should
return or accept ParcelFileDescriptor instances.

Bug: 130209137
Test: manual
Change-Id: Ifb3dd53dc138ec47f416f2d4b46c4668bc8ee1d8
parent e8bad137
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5473,7 +5473,7 @@ package android.os {
  public class UpdateEngine {
    ctor public UpdateEngine();
    method public void applyPayload(String, long, long, String[]);
    method public void applyPayload(@NonNull java.io.FileDescriptor, long, long, @NonNull String[]);
    method public void applyPayload(@NonNull android.os.ParcelFileDescriptor, long, long, @NonNull String[]);
    method public boolean bind(android.os.UpdateEngineCallback, android.os.Handler);
    method public boolean bind(android.os.UpdateEngineCallback);
    method public void cancel();
+3 −5
Original line number Diff line number Diff line
@@ -22,8 +22,6 @@ import android.os.IUpdateEngine;
import android.os.IUpdateEngineCallback;
import android.os.RemoteException;

import java.io.FileDescriptor;

/**
 * UpdateEngine handles calls to the update engine which takes care of A/B OTA
 * updates. It wraps up the update engine Binder APIs and exposes them as
@@ -315,16 +313,16 @@ public class UpdateEngine {
    }

    /**
     * Applies the payload passed as file descriptor {@code fd} instead of
     * Applies the payload passed as ParcelFileDescriptor {@code pfd} instead of
     * using the {@code file://} scheme.
     *
     * <p>See {@link #applyPayload(String)} for {@code offset}, {@code size} and
     * {@code headerKeyValuePairs} parameters.
     */
    public void applyPayload(@NonNull FileDescriptor fd, long offset, long size,
    public void applyPayload(@NonNull ParcelFileDescriptor pfd, long offset, long size,
            @NonNull String[] headerKeyValuePairs) {
        try {
            mUpdateEngine.applyPayloadFd(fd, offset, size, headerKeyValuePairs);
            mUpdateEngine.applyPayloadFd(pfd, offset, size, headerKeyValuePairs);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }