FileDocCategorySizeDatePackage
SerialService.javaAPI DocAndroid 5.1 API2140Thu Mar 12 22:22:42 GMT 2015com.android.server

SerialService

public class SerialService extends ISerialManager.Stub

Fields Summary
private final android.content.Context
mContext
private final String[]
mSerialPorts
Constructors Summary
public SerialService(android.content.Context context)

        mContext = context;
        mSerialPorts = context.getResources().getStringArray(
                com.android.internal.R.array.config_serialPorts);
    
Methods Summary
public java.lang.String[]getSerialPorts()

        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.SERIAL_PORT, null);

        ArrayList<String> ports = new ArrayList<String>();
        for (int i = 0; i < mSerialPorts.length; i++) {
            String path = mSerialPorts[i];
            if (new File(path).exists()) {
                ports.add(path);
            }
        }
        String[] result = new String[ports.size()];
        ports.toArray(result);
        return result;
    
private native android.os.ParcelFileDescriptornative_open(java.lang.String path)

public android.os.ParcelFileDescriptoropenSerialPort(java.lang.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);