2 * //******************************************************************
\r
4 * // Copyright 2015 Intel Corporation.
\r
6 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
8 * // Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * // you may not use this file except in compliance with the License.
\r
10 * // You may obtain a copy of the License at
\r
12 * // http://www.apache.org/licenses/LICENSE-2.0
\r
14 * // Unless required by applicable law or agreed to in writing, software
\r
15 * // distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * // See the License for the specific language governing permissions and
\r
18 * // limitations under the License.
\r
20 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
23 package org.iotivity.ca;
\r
25 import android.content.BroadcastReceiver;
\r
26 import android.content.Context;
\r
27 import android.content.Intent;
\r
28 import android.content.IntentFilter;
\r
29 import android.net.ConnectivityManager;
\r
30 import android.net.NetworkInfo;
\r
31 import android.net.wifi.WifiManager;
\r
33 public class CaIpInterface {
\r
34 private static Context mContext;
\r
36 private CaIpInterface(Context context) {
\r
38 registerIpStateReceiver();
\r
41 private void registerIpStateReceiver() {
\r
42 IntentFilter intentFilter = new IntentFilter();
\r
43 intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
\r
44 intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
\r
46 mContext.registerReceiver(mReceiver, intentFilter);
\r
49 private static BroadcastReceiver mReceiver = new BroadcastReceiver() {
\r
51 public void onReceive(Context context, Intent intent) {
\r
52 if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
\r
53 WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) {
\r
55 } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
\r
56 ConnectivityManager manager = (ConnectivityManager)
\r
57 mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
\r
58 NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
\r
60 if(nwInfo.isConnected()) {
\r
67 private native static void stateEnabled();
\r
69 private native static void stateDisabled();
\r