public class MessengerService extends android.app.Service implements RemoteClientListener, DebugListener, MessengerListener
This Service handles the TCP Sockets communication with the remote test controller and forwards all data exchanges with the local test package via the Inter-Process Communication Messenger facilities provided by the Android OS.
Currently, this service is accepting connections on port 2410. Currently, the remote controller server uses port 2411 to contact and attempt a connection to this service. Both sides eventually need to be able to use a broader range of ports to prevent conflicts with other system resources.
When using the Android Emulator, the emulator must be configured to "see" Socket requests on its local port 2410 coming from the controller on port 2411. Do this with the adb forwarding command to the running emulator as follows:
adb forward tcp:2411 tcp:2410
There is an initial handshake or verification that occurs between the remote controller server and this Service to confirm the device port owner is a SAFS TCP Messenger Service.
org.safs.sockets.RemoteClientRunner| Modifier and Type | Field and Description |
|---|---|
(package private) android.os.Messenger |
engineMessenger |
static java.lang.String |
KEY_ENGINE_NAME |
(package private) android.app.NotificationManager |
mNM |
(package private) MessengerHandler |
mServiceHandler |
(package private) android.os.Looper |
mServiceLooper |
static int |
NOTIFICATION_DEFAULT_ID |
static java.lang.CharSequence |
NOTIFICATION_TEXT |
(package private) Message |
safs |
(package private) android.os.Messenger |
serviceMessenger |
static java.lang.String |
TAG |
(package private) RemoteClientRunner |
tcpServer |
START_CONTINUATION_MASK, START_FLAG_REDELIVERY, START_FLAG_RETRY, START_NOT_STICKY, START_REDELIVER_INTENT, START_STICKY, START_STICKY_COMPATIBILITY, STOP_FOREGROUND_DETACH, STOP_FOREGROUND_REMOVEACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, FINGERPRINT_SERVICE, HARDWARE_PROPERTIES_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_STATS_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, PRINT_SERVICE, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, SYSTEM_HEALTH_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE| Constructor and Description |
|---|
MessengerService() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
debug(java.lang.String text) |
java.lang.String |
getListenerName()
Unique name to identify the listener.
|
void |
onAllParcelsHaveBeenHandled(java.lang.String messageID) |
android.os.IBinder |
onBind(android.content.Intent intent)
Capture the Message handler for the test package that is binding with the Service.
|
void |
onCreate() |
void |
onDestroy()
Cancel any Notification we have as we die and shutdown our SocketServer.
|
void |
onEngineDebug(java.lang.String message) |
void |
onEngineException(java.lang.String message) |
void |
onEngineMessage(java.lang.String message) |
void |
onEngineReady() |
void |
onEngineRegistered(android.os.Messenger messenger) |
void |
onEngineResult(int statuscode,
java.lang.String statusinfo) |
void |
onEngineResultProps(char[] props) |
void |
onEngineRunning() |
void |
onEngineShutdown(int cause) |
void |
onEngineUnRegistered() |
void |
onMessengerDebug(java.lang.String message) |
void |
onParcelHasBeenHandled(java.lang.String messageID,
int index) |
void |
onReceiveConnection()
Called when a 2-way sockets connection has been established.
|
void |
onReceiveDebug(java.lang.String text)
A remote client has sent a Debug message to be logged by the listener.
|
void |
onReceiveDispatchFile(java.lang.String filepath) |
void |
onReceiveDispatchProps(char[] props) |
void |
onReceiveLocalShutdown(int cause)
The service has shutdown.
|
void |
onReceiveMessage(java.lang.String message) |
void |
onReceiveRemoteShutdown(int cause)
The controller has requested a shutdown.
|
int |
onStartCommand(android.content.Intent intent,
int flags,
int startId)
Automatically called when the Service is being started up--usually from the test package engine
requesting to bind with the Service.
|
protected void |
sendIPCMessage(int what) |
protected void |
sendIPCMessage(int what,
char[] props) |
protected void |
sendIPCMessage(int what,
java.lang.String msgobj) |
protected void |
sendServiceParcelAcknowledge(java.lang.String messageID,
int index) |
protected void |
sendTCPMessage(java.lang.String message) |
dump, getApplication, onConfigurationChanged, onLowMemory, onRebind, onStart, onTaskRemoved, onTrimMemory, onUnbind, startForeground, stopForeground, stopForeground, stopSelf, stopSelf, stopSelfResultattachBaseContext, bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDataDir, getDir, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSystemService, getSystemServiceName, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isDeviceProtectedStorage, isRestricted, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivity, startActivity, startInstrumentation, startIntentSender, startIntentSender, startService, stopService, unbindService, unregisterReceiverpublic static final java.lang.String TAG
public static final java.lang.String KEY_ENGINE_NAME
public static final java.lang.CharSequence NOTIFICATION_TEXT
public static final int NOTIFICATION_DEFAULT_ID
android.app.NotificationManager mNM
RemoteClientRunner tcpServer
android.os.Looper mServiceLooper
MessengerHandler mServiceHandler
android.os.Messenger serviceMessenger
android.os.Messenger engineMessenger
Message safs
protected void debug(java.lang.String text)
public void onReceiveDebug(java.lang.String text)
DebugListeneronReceiveDebug in interface DebugListenerpublic void onCreate()
onCreate in class android.app.ServiceService.onBind(android.content.Intent)public int onStartCommand(android.content.Intent intent,
int flags,
int startId)
onStartCommand in class android.app.Servicepublic android.os.IBinder onBind(android.content.Intent intent)
onBind in class android.app.ServiceService.onBind(android.content.Intent)public void onDestroy()
onDestroy in class android.app.ServiceService.onDestroy()protected void sendTCPMessage(java.lang.String message)
public java.lang.String getListenerName()
NamedListenergetListenerName in interface NamedListenerpublic void onMessengerDebug(java.lang.String message)
onMessengerDebug in interface MessengerListenerpublic void onEngineDebug(java.lang.String message)
onEngineDebug in interface MessengerListenerpublic void onEngineException(java.lang.String message)
onEngineException in interface MessengerListenerpublic void onEngineMessage(java.lang.String message)
onEngineMessage in interface MessengerListenerpublic void onEngineResult(int statuscode,
java.lang.String statusinfo)
onEngineResult in interface MessengerListenerpublic void onEngineResultProps(char[] props)
onEngineResultProps in interface MessengerListenerpublic void onEngineShutdown(int cause)
onEngineShutdown in interface MessengerListenerpublic void onEngineReady()
onEngineReady in interface MessengerListenerpublic void onEngineRegistered(android.os.Messenger messenger)
onEngineRegistered in interface MessengerListenerpublic void onEngineUnRegistered()
onEngineUnRegistered in interface MessengerListenerpublic void onEngineRunning()
onEngineRunning in interface MessengerListenerprotected void sendIPCMessage(int what)
protected void sendServiceParcelAcknowledge(java.lang.String messageID,
int index)
protected void sendIPCMessage(int what,
java.lang.String msgobj)
protected void sendIPCMessage(int what,
char[] props)
public void onReceiveDispatchFile(java.lang.String filepath)
onReceiveDispatchFile in interface RemoteClientListenerpublic void onReceiveDispatchProps(char[] props)
onReceiveDispatchProps in interface RemoteClientListenerpublic void onReceiveMessage(java.lang.String message)
onReceiveMessage in interface RemoteClientListenerpublic void onReceiveConnection()
ConnectionListeneronReceiveConnection in interface ConnectionListenerpublic void onReceiveRemoteShutdown(int cause)
onReceiveRemoteShutdown in interface ConnectionListenercause - is used to indicate whether the shutdown is due to normal
or abnormal circumstances.SocketProtocol.STATUS_SHUTDOWN_NORMAL,
SocketProtocol.STATUS_SHUTDOWN_REMOTE_CLIENTpublic void onReceiveLocalShutdown(int cause)
onReceiveLocalShutdown in interface ConnectionListenercause - is used to indicate whether the shutdown is due to normal
or abnormal circumstances.SocketProtocol.STATUS_SHUTDOWN_NORMAL,
SocketProtocol.STATUS_SHUTDOWN_REMOTE_CLIENTpublic void onAllParcelsHaveBeenHandled(java.lang.String messageID)
onAllParcelsHaveBeenHandled in interface MultipleParcelListenerpublic void onParcelHasBeenHandled(java.lang.String messageID,
int index)
onParcelHasBeenHandled in interface MultipleParcelListenerCopyright © SAS Institute. All Rights Reserved.