Loading Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,7 @@ LOCAL_SRC_FILES += \ core/java/android/content/pm/IPackageMoveObserver.aidl \ core/java/android/content/pm/IPackageStatsObserver.aidl \ core/java/android/database/IContentObserver.aidl \ core/java/android/hardware/ISerialManager.aidl \ core/java/android/hardware/usb/IUsbManager.aidl \ core/java/android/net/IConnectivityManager.aidl \ core/java/android/net/INetworkManagementEventObserver.aidl \ Loading core/java/android/app/ContextImpl.java +8 −0 Original line number Diff line number Diff line Loading @@ -42,7 +42,9 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.hardware.ISerialManager; import android.hardware.SensorManager; import android.hardware.SerialManager; import android.hardware.usb.IUsbManager; import android.hardware.usb.UsbManager; import android.location.CountryDetector; Loading Loading @@ -428,6 +430,12 @@ class ContextImpl extends Context { return new UsbManager(ctx, IUsbManager.Stub.asInterface(b)); }}); registerService(SERIAL_SERVICE, new ServiceFetcher() { public Object createService(ContextImpl ctx) { IBinder b = ServiceManager.getService(SERIAL_SERVICE); return new SerialManager(ctx, ISerialManager.Stub.asInterface(b)); }}); registerService(VIBRATOR_SERVICE, new ServiceFetcher() { public Object createService(ContextImpl ctx) { return new Vibrator(); Loading core/java/android/content/Context.java +11 −0 Original line number Diff line number Diff line Loading @@ -1788,6 +1788,17 @@ public abstract class Context { */ public static final String USB_SERVICE = "usb"; /** * Use with {@link #getSystemService} to retrieve a {@link * android.hardware.SerialManager} for access to serial ports. * * @see #getSystemService * @see android.harware.SerialManager * * @hide */ public static final String SERIAL_SERVICE = "serial"; /** * Determine whether the given permission is allowed for a particular * process and user ID running in the system. Loading core/java/android/hardware/ISerialManager.aidl 0 → 100644 +29 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 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; import android.os.ParcelFileDescriptor; /** @hide */ interface ISerialManager { /* Returns a list of all available serial ports */ String[] getSerialPorts(); /* Returns a file descriptor for the serial port. */ ParcelFileDescriptor openSerialPort(String name); } core/java/android/hardware/SerialManager.java 0 → 100644 +88 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 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; import android.app.PendingIntent; import android.content.Context; import android.os.Bundle; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.SystemProperties; import android.util.Log; import java.io.IOException; import java.util.HashMap; /** * @hide */ public class SerialManager { private static final String TAG = "SerialManager"; private final Context mContext; private final ISerialManager mService; /** * {@hide} */ public SerialManager(Context context, ISerialManager service) { mContext = context; mService = service; } /** * Returns a string array containing the names of available serial ports * * @return names of available serial ports */ public String[] getSerialPorts() { try { return mService.getSerialPorts(); } catch (RemoteException e) { Log.e(TAG, "RemoteException in getSerialPorts", e); return null; } } /** * Opens and returns the {@link android.hardware.SerialPort} with the given name. * The speed of the serial port must be one of: * 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, * 19200, 38400, 57600, 115200, 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, * 1500000, 2000000, 2500000, 3000000, 3500000 or 4000000 * * @param name of the serial port * @param speed at which to open the serial port * @return the serial port */ public SerialPort openSerialPort(String name, int speed) throws IOException { try { ParcelFileDescriptor pfd = mService.openSerialPort(name); if (pfd != null) { SerialPort port = new SerialPort(name); port.open(pfd, speed); return port; } else { throw new IOException("Could not open serial port " + name); } } catch (RemoteException e) { Log.e(TAG, "exception in UsbManager.openDevice", e); } return null; } } Loading
Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,7 @@ LOCAL_SRC_FILES += \ core/java/android/content/pm/IPackageMoveObserver.aidl \ core/java/android/content/pm/IPackageStatsObserver.aidl \ core/java/android/database/IContentObserver.aidl \ core/java/android/hardware/ISerialManager.aidl \ core/java/android/hardware/usb/IUsbManager.aidl \ core/java/android/net/IConnectivityManager.aidl \ core/java/android/net/INetworkManagementEventObserver.aidl \ Loading
core/java/android/app/ContextImpl.java +8 −0 Original line number Diff line number Diff line Loading @@ -42,7 +42,9 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.hardware.ISerialManager; import android.hardware.SensorManager; import android.hardware.SerialManager; import android.hardware.usb.IUsbManager; import android.hardware.usb.UsbManager; import android.location.CountryDetector; Loading Loading @@ -428,6 +430,12 @@ class ContextImpl extends Context { return new UsbManager(ctx, IUsbManager.Stub.asInterface(b)); }}); registerService(SERIAL_SERVICE, new ServiceFetcher() { public Object createService(ContextImpl ctx) { IBinder b = ServiceManager.getService(SERIAL_SERVICE); return new SerialManager(ctx, ISerialManager.Stub.asInterface(b)); }}); registerService(VIBRATOR_SERVICE, new ServiceFetcher() { public Object createService(ContextImpl ctx) { return new Vibrator(); Loading
core/java/android/content/Context.java +11 −0 Original line number Diff line number Diff line Loading @@ -1788,6 +1788,17 @@ public abstract class Context { */ public static final String USB_SERVICE = "usb"; /** * Use with {@link #getSystemService} to retrieve a {@link * android.hardware.SerialManager} for access to serial ports. * * @see #getSystemService * @see android.harware.SerialManager * * @hide */ public static final String SERIAL_SERVICE = "serial"; /** * Determine whether the given permission is allowed for a particular * process and user ID running in the system. Loading
core/java/android/hardware/ISerialManager.aidl 0 → 100644 +29 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 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; import android.os.ParcelFileDescriptor; /** @hide */ interface ISerialManager { /* Returns a list of all available serial ports */ String[] getSerialPorts(); /* Returns a file descriptor for the serial port. */ ParcelFileDescriptor openSerialPort(String name); }
core/java/android/hardware/SerialManager.java 0 → 100644 +88 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 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; import android.app.PendingIntent; import android.content.Context; import android.os.Bundle; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.SystemProperties; import android.util.Log; import java.io.IOException; import java.util.HashMap; /** * @hide */ public class SerialManager { private static final String TAG = "SerialManager"; private final Context mContext; private final ISerialManager mService; /** * {@hide} */ public SerialManager(Context context, ISerialManager service) { mContext = context; mService = service; } /** * Returns a string array containing the names of available serial ports * * @return names of available serial ports */ public String[] getSerialPorts() { try { return mService.getSerialPorts(); } catch (RemoteException e) { Log.e(TAG, "RemoteException in getSerialPorts", e); return null; } } /** * Opens and returns the {@link android.hardware.SerialPort} with the given name. * The speed of the serial port must be one of: * 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, * 19200, 38400, 57600, 115200, 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, * 1500000, 2000000, 2500000, 3000000, 3500000 or 4000000 * * @param name of the serial port * @param speed at which to open the serial port * @return the serial port */ public SerialPort openSerialPort(String name, int speed) throws IOException { try { ParcelFileDescriptor pfd = mService.openSerialPort(name); if (pfd != null) { SerialPort port = new SerialPort(name); port.open(pfd, speed); return port; } else { throw new IOException("Could not open serial port " + name); } } catch (RemoteException e) { Log.e(TAG, "exception in UsbManager.openDevice", e); } return null; } }