Skip to content

Instantly share code, notes, and snippets.

@fritz-gerneth
Created January 6, 2012 11:03
Show Gist options
  • Save fritz-gerneth/1570128 to your computer and use it in GitHub Desktop.
Save fritz-gerneth/1570128 to your computer and use it in GitHub Desktop.
import android.os.Bundle;
import android.os.RemoteException;
/**
* The common interface for all connections. This interface only states that
* this object is a connection at all.
*
* @author Fritz Gerneth
*
*/
public interface IConnection extends android.os.IInterface
{
/**
* This interface is used by the actual implementation.
* <br /><br />
* <b>DO NOT USE THIS INTERFACE</b>. Classes implementing this interface do <b>not behave</b> like other
* classes implementing the IConnection interface.
* <br />
* If Java would know protected static interfaces, this would be protected
* (and will be as soon as it is possible).
*
* @author Fritz Gerneth
*/
static interface Implementation extends IConnection
{
/**
* Constants required by IPC
*/
static final int TRANSACTION_onSend = android.os.IBinder.FIRST_CALL_TRANSACTION + 0;
static final int TRANSACTION_setCallbackStatus = android.os.IBinder.FIRST_CALL_TRANSACTION + 1;
static final String DESCRIPTOR = "com.agc.core.cal.IConnection";
public void setCallbackStatus(IConnection callback, boolean enabled) throws android.os.RemoteException;
public void send(int command, Bundle extra, int source) throws android.os.RemoteException;
}
/**
* The uni-directional connection interface for sending messages.
* <br /><br />
* This interface is used by connection clients to send messages to the server.
* Compared to Android-IPC this is a proxy object.
*
* @author Fritz Gerneth
*/
static interface SimplexProducer extends IConnection
{
public void send(int code) throws RemoteException;
public void send(int code, int source) throws RemoteException;
public void send(int code, android.os.Bundle extra) throws RemoteException;
}
/**
* The uni-directional connection interface for receiving messages.
* <br /><br />
* This interface is used by connection servers to receive messages from the server.
* Compared to Android-IPC this is a stub object.
*
* @author Fritz Gerneth
*/
static interface SimplexConsumer extends IConnection
{
public void registerReceiver(IMessageListener listener);
public void unregisterReceiver(IMessageListener listener);
}
/**
* The bi-directional connection interface for sending and receiving messages.
* <br /><br />
* This interface is used by both, clients and servers to communicate in both
* directions.
* Compared to Android-IPC this is a proxy (for sending messages) and a stub
* (for receiving messages) combined.
*
* @author Fritz Gerneth
*
*/
static interface Duplex extends IConnection.SimplexProducer, IConnection.SimplexConsumer
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment