Loading core/java/android/hardware/serial/ISerialManager.aidl 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.serial; import android.hardware.serial.SerialPortInfo; import android.hardware.serial.ISerialPortListener; import android.hardware.serial.ISerialPortResponseCallback; /** @hide */ interface ISerialManager { /** Returns a list of all available serial ports */ List<SerialPortInfo> getSerialPorts(); /** Registers a listener to monitor serial port connections and disconnections. */ void registerSerialPortListener(in ISerialPortListener listener); /** Unregisters a listener to monitor serial port connections and disconnections. */ void unregisterSerialPortListener(in ISerialPortListener listener); /** Requests opening a file descriptor for the serial port. */ void requestOpen(in String portName, in int flags, in ISerialPortResponseCallback callback); } core/java/android/hardware/serial/ISerialPortListener.aidl 0 → 100644 +29 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.serial; import android.hardware.serial.SerialPortInfo; /** * Listener to monitor serial port connections and disconnections. * * @hide */ oneway interface ISerialPortListener { void onSerialPortConnected(in SerialPortInfo port); void onSerialPortDisconnected(in SerialPortInfo port); } core/java/android/hardware/serial/ISerialPortResponseCallback.aidl 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.serial; import android.hardware.serial.SerialPortInfo; import android.os.ParcelFileDescriptor; /** * Interface for getting a response to ISerialManager.requestOpen(). * * @hide */ oneway interface ISerialPortResponseCallback { /** Error codes for {@link #onError}. */ @Backing(type="int") enum ErrorCode { // IOException while reading the list of derial drivers ERROR_READING_DRIVERS = 0, // Serial port with the given name does not exist. ERROR_PORT_NOT_FOUND = 1, // ErrnoException while opening the serial port. ERROR_OPENING_PORT = 2, } /** * Called when the serial port has been opened successfully. * * @param port The port * @param fileDescriptor The file descriptor of the pseudo-file. */ void onResult(in SerialPortInfo port, in ParcelFileDescriptor fileDescriptor); /** * Called when the serial port opening failed. * * @param errorCode The error code indicating the type of error that occurred. * @param errno The errno from ErrnoException in case of ERROR_OPENING_PORT. * @param message Additional text information about the error. */ void onError(in ErrorCode errorCode, in int errno, in String message); } core/java/android/hardware/serial/SerialPortInfo.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.serial; parcelable SerialPortInfo; core/java/android/hardware/serial/SerialPortInfo.java 0 → 100644 +91 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.serial; import android.annotation.NonNull; import android.os.Parcel; import android.os.Parcelable; /** * A class containing Serial port info. * * @hide */ public class SerialPortInfo implements Parcelable { private final @NonNull String mName; private final int mVendorId; private final int mProductId; public SerialPortInfo(@NonNull String name, int vendorId, int productId) { mName = name; mVendorId = vendorId; mProductId = productId; } /** * Get the device name. It is the dev node name under /dev, e.g. ttyUSB0, ttyACM1. */ public @NonNull String getName() { return mName; } /** * Return the vendor ID of this serial port if it is a USB device. Otherwise, it * returns {@link SerialPort#INVALID_ID}. */ public int getVendorId() { return mVendorId; } /** * Return the product ID of this serial port if it is a USB device. Otherwise, it * returns {@link SerialPort#INVALID_ID}. */ public int getProductId() { return mProductId; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(@NonNull Parcel parcel, int flags) { parcel.writeString8(mName); parcel.writeInt(mVendorId); parcel.writeInt(mProductId); } public static final @NonNull Creator<SerialPortInfo> CREATOR = new Creator<>() { @Override public SerialPortInfo createFromParcel(Parcel in) { String name = in.readString8(); int vendorId = in.readInt(); int productId = in.readInt(); return new SerialPortInfo(name, vendorId, productId); } @Override public SerialPortInfo[] newArray(int size) { return new SerialPortInfo[size]; } }; } Loading
core/java/android/hardware/serial/ISerialManager.aidl 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.serial; import android.hardware.serial.SerialPortInfo; import android.hardware.serial.ISerialPortListener; import android.hardware.serial.ISerialPortResponseCallback; /** @hide */ interface ISerialManager { /** Returns a list of all available serial ports */ List<SerialPortInfo> getSerialPorts(); /** Registers a listener to monitor serial port connections and disconnections. */ void registerSerialPortListener(in ISerialPortListener listener); /** Unregisters a listener to monitor serial port connections and disconnections. */ void unregisterSerialPortListener(in ISerialPortListener listener); /** Requests opening a file descriptor for the serial port. */ void requestOpen(in String portName, in int flags, in ISerialPortResponseCallback callback); }
core/java/android/hardware/serial/ISerialPortListener.aidl 0 → 100644 +29 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.serial; import android.hardware.serial.SerialPortInfo; /** * Listener to monitor serial port connections and disconnections. * * @hide */ oneway interface ISerialPortListener { void onSerialPortConnected(in SerialPortInfo port); void onSerialPortDisconnected(in SerialPortInfo port); }
core/java/android/hardware/serial/ISerialPortResponseCallback.aidl 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.serial; import android.hardware.serial.SerialPortInfo; import android.os.ParcelFileDescriptor; /** * Interface for getting a response to ISerialManager.requestOpen(). * * @hide */ oneway interface ISerialPortResponseCallback { /** Error codes for {@link #onError}. */ @Backing(type="int") enum ErrorCode { // IOException while reading the list of derial drivers ERROR_READING_DRIVERS = 0, // Serial port with the given name does not exist. ERROR_PORT_NOT_FOUND = 1, // ErrnoException while opening the serial port. ERROR_OPENING_PORT = 2, } /** * Called when the serial port has been opened successfully. * * @param port The port * @param fileDescriptor The file descriptor of the pseudo-file. */ void onResult(in SerialPortInfo port, in ParcelFileDescriptor fileDescriptor); /** * Called when the serial port opening failed. * * @param errorCode The error code indicating the type of error that occurred. * @param errno The errno from ErrnoException in case of ERROR_OPENING_PORT. * @param message Additional text information about the error. */ void onError(in ErrorCode errorCode, in int errno, in String message); }
core/java/android/hardware/serial/SerialPortInfo.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.serial; parcelable SerialPortInfo;
core/java/android/hardware/serial/SerialPortInfo.java 0 → 100644 +91 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.serial; import android.annotation.NonNull; import android.os.Parcel; import android.os.Parcelable; /** * A class containing Serial port info. * * @hide */ public class SerialPortInfo implements Parcelable { private final @NonNull String mName; private final int mVendorId; private final int mProductId; public SerialPortInfo(@NonNull String name, int vendorId, int productId) { mName = name; mVendorId = vendorId; mProductId = productId; } /** * Get the device name. It is the dev node name under /dev, e.g. ttyUSB0, ttyACM1. */ public @NonNull String getName() { return mName; } /** * Return the vendor ID of this serial port if it is a USB device. Otherwise, it * returns {@link SerialPort#INVALID_ID}. */ public int getVendorId() { return mVendorId; } /** * Return the product ID of this serial port if it is a USB device. Otherwise, it * returns {@link SerialPort#INVALID_ID}. */ public int getProductId() { return mProductId; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(@NonNull Parcel parcel, int flags) { parcel.writeString8(mName); parcel.writeInt(mVendorId); parcel.writeInt(mProductId); } public static final @NonNull Creator<SerialPortInfo> CREATOR = new Creator<>() { @Override public SerialPortInfo createFromParcel(Parcel in) { String name = in.readString8(); int vendorId = in.readInt(); int productId = in.readInt(); return new SerialPortInfo(name, vendorId, productId); } @Override public SerialPortInfo[] newArray(int size) { return new SerialPortInfo[size]; } }; }