1 //******************************************************************
3 // Copyright 2015 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 /// @file PluginManager.java
23 /// @brief After installing a plug-in in a directory, each plug-in can be managed by this class.
25 package org.iotivity.service.ppm;
27 import android.content.Context;
28 import android.util.Log;
30 public class PluginManager {
33 * Start plug-ins by key-value pair.
35 * @param key - key information of the plug-in to be started.
36 * @param value - value information of the plug-in to be started.
37 * @return int - 1 on success or 0 on failure.
39 public int startPlugins(String key, String value) {
40 LogEx("startPlugins() Called.");
41 return jniStartPlugins(key, value);
45 * Stop plug-ins by key-value pair.
47 * @param key - key information of the plug-in to be stopped.
48 * @param value - value information of the plug-in to be stopped.
49 * @return int - 1 on success or 0 on failure.
51 public int stopPlugins(String key, String value) {
52 LogEx("stopPlugins() Called.");
53 return jniStopPlugins(key, value);
57 * Rescan for plug-ins in the registered directory and install plug-ins.
60 * @return int - 1 on success or 0 on failure.
62 public int rescanPlugin() {
63 LogEx("rescanPlugin() Called.");
64 return jniRescanPlugin();
68 * Get list of plug-ins.
71 * @return Plugin[] - Plug-in array.
73 public Plugin[] getPlugins() {
74 LogEx("getPlugins() Called.");
75 return jniGetPlugins();
79 * Get state of the plug-in.
81 * @param pluginID - ID of the plug-in to get state.
82 * @return String - state of the plug-in.
84 public String getState(String plugID) {
85 LogEx("getState() Called.");
86 return jniGetState(plugID);
89 public PluginManager(Context ctx) {
90 LogEx("PluginManager() Called.");
91 FelixManager.getInstance(ctx);
92 System.loadLibrary("PluginManager");
95 private static final String LOG_TAG = "PPMSampleApp : PluginManager";
97 private native int jniStartPlugins(String key, String value);
99 private native int jniStopPlugins(String key, String value);
101 private native int jniRescanPlugin();
103 private native Plugin[] jniGetPlugins();
105 private native String jniGetState(String plugID);
107 private static void LogEx(String info) {
108 Log.d(LOG_TAG, info);