Add Android Notification APIs for Consumer service
[platform/upstream/iotivity.git] / service / notification / android / notification-service / src / main / java / org / iotivity / service / ns / consumer / NSProvider.java
1 //******************************************************************
2 //
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 package org.iotivity.service.ns.consumer;
22
23 import android.util.Log;
24
25 public class NSProvider {
26
27     private static final String LOG_TAG = "ConsumerService_NSProvider";
28
29     String providerId                = null;
30
31     private long mNativeHandle       = 0;
32
33     public NSProvider(String providerId, long mNativeHandle) {
34         Log.i (LOG_TAG, "NSProvider()");
35
36         this.providerId = providerId;
37
38         this.mNativeHandle = mNativeHandle;
39     }
40
41     private native void Subscribe(long provider) throws NSException;
42     private native void Unsubscribe(long provider) throws NSException;
43     private native void SendSyncInfo(String providerId, long messageId, int syncType) throws NSException;
44     public native void SetListener(
45         ConsumerService.OnMessageReceivedListner onMessageReceivedListner,
46         ConsumerService.OnSyncInfoReceivedListner onSyncInfoReceivedListner
47         ) throws NSException;
48
49     public String getProviderId () {
50         return providerId ;
51     }
52
53     public void Subscribe() throws NSException {
54         this.Subscribe(mNativeHandle);
55     }
56
57     public void Unsubscribe() throws NSException {
58         this.Unsubscribe(mNativeHandle);
59     }
60
61     public void SendSyncInfo(long messageId, int syncType) throws NSException {
62         this.SendSyncInfo(this.providerId, messageId, syncType);
63     }
64 }