1 //******************************************************************
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 package org.iotivity.service.ns.consumer;
23 import android.util.Log;
24 import org.iotivity.service.ns.common.*;
25 import java.util.Vector;
28 * @class ConsumerService
29 * @brief This class provides a set of Java APIs for Notification Consumer.
31 public class ConsumerService
33 private static final String LOG_TAG = "ConsumerService";
37 System.loadLibrary("gnustl_shared");
38 System.loadLibrary("oc_logger");
39 System.loadLibrary("connectivity_abstraction");
40 System.loadLibrary("ca-interface");
41 System.loadLibrary("octbstack");
42 System.loadLibrary("oc");
43 System.loadLibrary("ocstack-jni");
44 System.loadLibrary("notification_consumer");
45 System.loadLibrary("notification_consumer_wrapper");
46 System.loadLibrary("notification_consumer_jni");
56 private Response(int type)
61 public int getResponseType()
67 private static ConsumerService instance;
70 instance = new ConsumerService();
72 public static ConsumerService getInstance()
77 public ConsumerService()
79 Log.i (LOG_TAG, "ConsumerService()");
83 OnProviderDiscoveredListner onProviderDiscoveredListner,
84 OnProviderChangedListener onProviderChangedListener
87 nativeStart(onProviderDiscoveredListner, onProviderChangedListener);
90 public void Stop() throws NSException
95 public void EnableRemoteService(String serverAddress) throws NSException
97 nativeEnableRemoteService(serverAddress);
100 public void RescanProvider() throws NSException
102 nativeRescanProvider();
105 public Provider GetProvider(String providerId) throws NSException
107 return nativeGetProvider(providerId);
110 public Message GetMessage(long messageId) throws NSException
112 return nativeGetMessage(messageId);
115 public interface OnProviderDiscoveredListner
117 public void onProviderDiscovered(Provider provider);
120 public interface OnProviderChangedListener
122 public void onProviderChanged(Provider provider , Response response);
125 private native void nativeStart (
126 OnProviderDiscoveredListner onProviderDiscoveredListner,
127 OnProviderChangedListener onProviderChangedListener
128 ) throws NSException;
130 private native void nativeStop() throws NSException;
131 private native void nativeEnableRemoteService(String serverAddress) throws NSException;
132 private native void nativeRescanProvider() throws NSException;
133 private native Provider nativeGetProvider(String providerId) throws NSException;
134 private native Message nativeGetMessage(long messageId) throws NSException;