SASocket represents an instance of a Service Connection between a Service Provider and a Service Consumer.
Developer Guides
Both Service Provider and Service Consumer applications must declare a subclass of SAAgent. The Service
Connection, represented by this class, is the dialogue between the two SAAgent objects.
The objects of this class are created when a successful Service Connection is established. Both Service Provider
and Service Consumer application must declare a subclass of this class, and implement the Service Connection
related event handling methods: onReceive(int, byte[]), onError(int, String, int), and
onServiceConnectionLost(int).
Both Service Provider and Service Consumer application can simply call send(int, byte[]) to write on a
channel inside the Service Connection. They can also call close() to terminate the Service Connection
with the remote Accessory Peer Agent.
Note: Both Service Provider and Service Consumer application must register a concrete
implementation of this class with SAAgent by passing the name and derived concrete class as the
parameters of SAAgent constructor. An instance of this class is passed to the SAAgent object in
the SAAgent.onServiceConnectionResponse(SAPeerAgent, SASocket, int) callback, once the Service
Connection is established with the remote Accessory Peer Agent. The application must also implement the public
default constructor of this class, as follows:
public YourSubclassExtendsThisClass() {
super("the name of your subclass extends this class");
}
The constructor is dynamically referenced by Samsung Accessory SDK. The application should never call the
constructor.
When you build your application in release mode, you must add several -keep lines in the
ProGuard configuration file of your application to prevent ProGuard from renaming your subclasses of
SAAgent and SASocket. (ProGuard is a tool integrated into the Android build system that
obfuscates the code by renaming its classes and methods.)
For more information about How to configure ProGuard, please visit
the ProGuard page of Android Development
Site.
For more information about using Accessory, please refer to the Accessory Programming Guide.