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

Commit 80248d44 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

SerialManager: Only allow opening files that are whitelisted serial port devices



Bug: 7367956

Change-Id: I82fd8d2694dda89332497d9eded5445a0262e12b
Signed-off-by: default avatarMike Lockwood <lockwood@google.com>
parent 3b8ee168
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -51,8 +51,13 @@ public class SerialService extends ISerialManager.Stub {

    public ParcelFileDescriptor openSerialPort(String path) {
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.SERIAL_PORT, null);
        for (int i = 0; i < mSerialPorts.length; i++) {
            if (mSerialPorts[i].equals(path)) {
                return native_open(path);
            }
        }
        throw new IllegalArgumentException("Invalid serial port " + path);
    }

    private native ParcelFileDescriptor native_open(String path);
}