Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / resource / csdk / connectivity / samples / android / sample_service / src / org / iotivity / service / RMInterface.java
1 package org.iotivity.service;
2
3 import android.content.Context;
4
5 public class RMInterface {
6
7     static {
8         // Load RI JNI interface
9         System.loadLibrary("RMInterface");
10     }
11
12     private org.iotivity.service.MainActivity mResponseListener = null;
13
14     public native void setNativeResponseListener(Object listener);
15
16     public native void RMInitialize(Context context);
17
18     public native void RMTerminate();
19
20     public native void RMStartListeningServer();
21
22     public native void RMStartDiscoveryServer();
23
24     public native void RMRegisterHandler();
25
26     public native void RMFindResource(String uri);
27
28     public native void RMSendRequest(String uri, String payload,
29             int selectedNetwork, int isSecured, int msgType);
30
31     public native void RMSendReqestToAll(String uri, int selectedNetwork);
32
33     public native void RMSendResponse(int selectedNetwork, int isSecured,
34             int msgType, int responseValue);
35
36     public native void RMAdvertiseResource(String advertiseResource);
37
38     public native void RMSendNotification(String uri, String payload,
39             int selectedNetwork, int isSecured, int msgType, int responseValue);
40
41     public native void RMSelectNetwork(int interestedNetwork);
42
43     public native void RMUnSelectNetwork(int uninterestedNetwork);
44
45     public native void RMGetNetworkInfomation();
46
47     public native void RMHandleRequestResponse();
48
49     public void setResponseListener(org.iotivity.service.MainActivity listener) {
50         mResponseListener = listener;
51         setNativeResponseListener(this);
52     }
53
54     private void OnResponseReceived(String subject, String receivedData) {
55         if (null != mResponseListener) {
56             mResponseListener.OnResponseReceived(subject, receivedData);
57         }
58     }
59
60 }