ANS unit test

Add unit tests for ANS

Bug: 117365779
Test: ran unit test

ANSTests (13 Tests)
------------------
[1/13] com.android.ans.ANSNetworkScanCtlrTest#testStartFastNetworkScan: PASSED (228ms)
[2/13] com.android.ans.ANSNetworkScanCtlrTest#testStartFastNetworkScanFail: PASSED (26ms)
[3/13] com.android.ans.ANSNetworkScanCtlrTest#testStartSlowNetworkScan: PASSED (1ms)
[4/13] com.android.ans.ANSNetworkScanCtlrTest#testStopNetworkScan: PASSED (126ms)
[5/13] com.android.ans.ANSProfileSelectorTest#testStartProfileSelectionSuccess: PASSED (26ms)
[6/13] com.android.ans.ANSProfileSelectorTest#testStartProfileSelectionWithNoOpportunisticSub: PASSED (127ms)
[7/13] com.android.ans.ANSServiceStateEvaluatorTest#testBadService: PASSED (26ms)
[8/13] com.android.ans.ANSServiceStateEvaluatorTest#testStopEvaluation: PASSED (1006ms)
[9/13] com.android.ans.ANSServiceStateMonitorTest#testGoodSignalStrength: PASSED (1ms)
[10/13] com.android.ans.ANSServiceStateMonitorTest#testInService: PASSED (26ms)
[11/13] com.android.ans.ANSServiceStateMonitorTest#testIsFatalFailCause: PASSED (0ms)
[12/13] com.android.ans.ANSServiceStateMonitorTest#testOutOfService: PASSED (1ms)
[13/13] com.android.ans.ANSServiceStateMonitorTest#testbadSignalStrength: PASSED (25ms)

Change-Id: I7e68709b89c0b622b5eb46eb4155779093559e05
Merged-In: I7e68709b89c0b622b5eb46eb4155779093559e05
diff --git a/Android.mk b/Android.mk
index 421de9c..c6b6550 100644
--- a/Android.mk
+++ b/Android.mk
@@ -23,6 +23,7 @@
 LOCAL_PRIVATE_PLATFORM_APIS := true
 LOCAL_PRIVILEGED_MODULE := true
 
+INCLUDED_MAKEFILES := $(LOCAL_PATH)/tests/Android.mk
 LOCAL_JAVA_LIBRARIES := telephony-common
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/src/com/android/ans/ANSNetworkScanCtlr.java b/src/com/android/ans/ANSNetworkScanCtlr.java
index ada86ac..88f9f6c 100644
--- a/src/com/android/ans/ANSNetworkScanCtlr.java
+++ b/src/com/android/ans/ANSNetworkScanCtlr.java
@@ -140,7 +140,7 @@
      */
     public void analyzeScanResults(List<CellInfo> results) {
         /* Inform registrants about availability of network */
-        if (results != null) {
+        if (mIsScanActive && results != null) {
             List<CellInfo> filteredResults = new ArrayList<CellInfo>();
             synchronized (mLock) {
                 for (CellInfo cellInfo : results) {
diff --git a/src/com/android/ans/ANSProfileSelector.java b/src/com/android/ans/ANSProfileSelector.java
index 977ff88..8a7d266 100644
--- a/src/com/android/ans/ANSProfileSelector.java
+++ b/src/com/android/ans/ANSProfileSelector.java
@@ -69,7 +69,8 @@
     @VisibleForTesting
     protected ANSNetworkScanCtlr mNetworkScanCtlr;
 
-    private SubscriptionManager mSubscriptionManager;
+    @VisibleForTesting
+    protected SubscriptionManager mSubscriptionManager;
     private ANSProfileSelectionCallback mProfileSelectionCallback;
     private int mSequenceId;
 
@@ -79,7 +80,8 @@
             "android.intent.action.SUBSCRIPTION_SWITCH_REPLY";
 
     /* service monitor callback will get called for service state change on a particular subId. */
-    private ANSServiceStateMonitor.ANSServiceMonitorCallback mServiceMonitorCallback =
+    @VisibleForTesting
+    protected ANSServiceStateMonitor.ANSServiceMonitorCallback mServiceMonitorCallback =
             new ANSServiceStateMonitor.ANSServiceMonitorCallback() {
                 @Override
                 public void onServiceMonitorUpdate(int subId, int state) {
@@ -93,7 +95,9 @@
                 }
             };
 
-    private SubscriptionManager.OnOpportunisticSubscriptionsChangedListener mProfileChangeListener =
+    @VisibleForTesting
+    protected SubscriptionManager.OnOpportunisticSubscriptionsChangedListener
+            mProfileChangeListener =
             new SubscriptionManager.OnOpportunisticSubscriptionsChangedListener() {
                 @Override
                 public void onOpportunisticSubscriptionsChanged() {
@@ -308,7 +312,6 @@
             mNetworkScanCtlr.startFastNetworkScan(subscriptionInfos);
         } else if (subscriptionInfos.size() == 0) {
             /* check if no profile */
-            log("checkProfileUpdate 0 out");
             mNetworkScanCtlr.stopNetworkScan();
         }
     }
@@ -341,6 +344,7 @@
         }
     }
 
+    @VisibleForTesting
     protected void init(Context c, ANSProfileSelectionCallback profileSelectionCallback) {
         mContext = c;
         mSequenceId = START_SEQUENCE_ID;
diff --git a/src/com/android/ans/ANSServiceStateEvaluator.java b/src/com/android/ans/ANSServiceStateEvaluator.java
index 409428c..e5e1479 100644
--- a/src/com/android/ans/ANSServiceStateEvaluator.java
+++ b/src/com/android/ans/ANSServiceStateEvaluator.java
@@ -153,7 +153,8 @@
     }
 
     /* service monitor callback will get called for service state change on a particular subId. */
-    ANSServiceStateMonitor.ANSServiceMonitorCallback mServiceMonitorCallback =
+    @VisibleForTesting
+    protected ANSServiceStateMonitor.ANSServiceMonitorCallback mServiceMonitorCallback =
             new ANSServiceStateMonitor.ANSServiceMonitorCallback() {
                 @Override
                 public void onServiceMonitorUpdate(int subId, int state) {
@@ -182,6 +183,7 @@
         init(c, serviceEvaluatorCallback);
     }
 
+    @VisibleForTesting
     protected void init(Context c, ANSServiceEvaluatorCallback serviceEvaluatorCallback) {
         mContext = c;
         mServiceEvaluatorCallback = serviceEvaluatorCallback;
diff --git a/src/com/android/ans/ANSServiceStateMonitor.java b/src/com/android/ans/ANSServiceStateMonitor.java
index b1e0b24..89b1253 100644
--- a/src/com/android/ans/ANSServiceStateMonitor.java
+++ b/src/com/android/ans/ANSServiceStateMonitor.java
@@ -226,7 +226,6 @@
             if (mPhoneStateListener != null && subId == mSubId) {
                 return mPhoneStateListener;
             }
-
             mSubId = subId;
             mPhoneStateListener = (PhoneStateListener) new PhoneStateListenerImpl(subId);
         }
diff --git a/tests/Android.mk b/tests/Android.mk
new file mode 100644
index 0000000..abd5ece
--- /dev/null
+++ b/tests/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2018 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := tests
+LOCAL_SRC_FILES := $(call all-java-files-under, src/com/android/ans/)
+
+LOCAL_JAVA_LIBRARIES := android.test.runner \
+                        telephony-common \
+                        android.test.mock \
+                        android.test.base
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+        android-support-test \
+        mockito-target \
+        platform-test-annotations
+
+LOCAL_PACKAGE_NAME := ANSTests
+LOCAL_PRIVATE_PLATFORM_APIS := true
+LOCAL_CERTIFICATE := platform
+LOCAL_INSTRUMENTATION_FOR := ANS
+LOCAL_COMPATIBILITY_SUITE := device-tests
+include $(BUILD_PACKAGE)
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
new file mode 100644
index 0000000..650f4a3
--- /dev/null
+++ b/tests/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 The Android Open Source Project
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.ans.tests">
+
+    <uses-sdk android:minSdkVersion="18" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:targetPackage="com.android.ans"
+        android:label="Tests for ANS">
+    </instrumentation>
+</manifest>
diff --git a/tests/src/com/android/ans/ANSBaseTest.java b/tests/src/com/android/ans/ANSBaseTest.java
new file mode 100644
index 0000000..e1fd946
--- /dev/null
+++ b/tests/src/com/android/ans/ANSBaseTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+package com.android.ans;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.telephony.Rlog;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+import android.test.AndroidTestCase;
+
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+public abstract class ANSBaseTest extends AndroidTestCase {
+    protected TelephonyManager mTelephonyManager;
+    @Mock
+    protected SubscriptionManager mSubscriptionManager;
+    @Mock
+    protected TelephonyManager mMockTelephonyManager;
+    protected Context mContext;
+    protected boolean mReady  = false;
+    private Object mLock = new Object();
+    private static final int MAX_INIT_WAIT_MS = 5000; // 5 seconds
+    private static final String TAG = "ANSBaseTest";
+
+    protected void waitUntilReady() {
+        waitUntilReady(MAX_INIT_WAIT_MS);
+    }
+
+    protected void waitUntilReady(int time) {
+        synchronized (mLock) {
+            if (!mReady) {
+                try {
+                    mLock.wait(time);
+                } catch (InterruptedException ie) {
+                }
+
+                if (!mReady) {
+                    Rlog.d(TAG, "ANS tests failed to set ready state");
+                }
+            }
+        }
+    }
+
+    protected void setReady(boolean ready) {
+        synchronized (mLock) {
+            mReady = ready;
+            mLock.notifyAll();
+        }
+    }
+
+    protected void setUp(String tag) throws Exception {
+        mContext = InstrumentationRegistry.getTargetContext();
+        mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+        MockitoAnnotations.initMocks(this);
+        setReady(false);
+    }
+}
\ No newline at end of file
diff --git a/tests/src/com/android/ans/ANSNetworkScanCtlrTest.java b/tests/src/com/android/ans/ANSNetworkScanCtlrTest.java
new file mode 100644
index 0000000..dc2c202
--- /dev/null
+++ b/tests/src/com/android/ans/ANSNetworkScanCtlrTest.java
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+package com.android.ans;
+
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.*;
+
+import android.os.Looper;
+import android.telephony.CellIdentityLte;
+import android.telephony.CellInfo;
+import android.telephony.CellInfoLte;
+import android.telephony.NetworkScan;
+import android.telephony.SubscriptionInfo;
+import android.telephony.TelephonyManager;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ANSNetworkScanCtlrTest extends ANSBaseTest {
+    private ANSNetworkScanCtlr mANSNetworkScanCtlr;
+    private NetworkScan mNetworkScan;
+    private List<CellInfo> mResults;
+    private int mError;
+    private boolean mCallbackInvoked;
+    private Looper mLooper;
+    private ANSServiceStateMonitor.PhoneStateListenerImpl mPhoneStateListener;
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp("ANSTest");
+        mLooper = null;
+        mNetworkScan = new NetworkScan(1, 1);
+        doReturn(mNetworkScan).when(mMockTelephonyManager).requestNetworkScan(anyObject(), anyObject());
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        if (mLooper != null) {
+            mLooper.quit();
+            mLooper.getThread().join();
+        }
+        super.tearDown();
+    }
+
+    @Test
+    public void testStartFastNetworkScan() {
+        List<SubscriptionInfo> subscriptionInfoList = new ArrayList<SubscriptionInfo>();
+        SubscriptionInfo subscriptionInfo = new SubscriptionInfo(1, "", 1, "TMO", "TMO", 1, 1,
+                "123", 1, null, "310", "210", "", false, null, "1");
+        subscriptionInfoList.add(subscriptionInfo);
+        List<CellInfo> expectedResults = new ArrayList<CellInfo>();
+        CellIdentityLte cellIdentityLte = new CellIdentityLte(310, 210, 1, 1, 1);
+        CellInfoLte cellInfoLte = new CellInfoLte();
+        cellInfoLte.setCellIdentity(cellIdentityLte);
+        expectedResults.add((CellInfo)cellInfoLte);
+        mReady = false;
+
+        // initializing ANSNetworkScanCtlr
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                Looper.prepare();
+                mANSNetworkScanCtlr = new ANSNetworkScanCtlr(mContext, mMockTelephonyManager,
+                        new ANSNetworkScanCtlr.NetworkAvailableCallBack() {
+                        @Override
+                        public void onNetworkAvailability(List<CellInfo> results) {
+                            mResults = results;
+                            setReady(true);
+                        }
+
+                        public void onError(int error) {
+                            setReady(true);
+                        }
+                    });
+
+                mLooper = Looper.myLooper();
+                setReady(true);
+                Looper.loop();
+            }
+        }).start();
+
+        // Wait till initialization is complete.
+        waitUntilReady();
+        mReady = false;
+
+        // Testing startFastNetworkScan, onNetworkAvailability should be called with expectedResults
+        mANSNetworkScanCtlr.startFastNetworkScan(subscriptionInfoList);
+        mANSNetworkScanCtlr.mNetworkScanCallback.onResults(expectedResults);
+        waitUntilReady(100);
+        assertEquals(expectedResults, mResults);
+    }
+
+    @Test
+    public void testStartFastNetworkScanFail() {
+        List<SubscriptionInfo> subscriptionInfoList = new ArrayList<SubscriptionInfo>();
+        SubscriptionInfo subscriptionInfo = new SubscriptionInfo(1, "", 1, "TMO", "TMO", 1, 1,
+                "123", 1, null, "310", "210", "", false, null, "1");
+        subscriptionInfoList.add(subscriptionInfo);
+        List<CellInfo> expectedResults = new ArrayList<CellInfo>();
+        CellIdentityLte cellIdentityLte = new CellIdentityLte(310, 210, 1, 1, 1);
+        CellInfoLte cellInfoLte = new CellInfoLte();
+        cellInfoLte.setCellIdentity(cellIdentityLte);
+        expectedResults.add((CellInfo)cellInfoLte);
+        mReady = false;
+        mError = NetworkScan.SUCCESS;
+
+        // initializing ANSNetworkScanCtlr
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                Looper.prepare();
+                mANSNetworkScanCtlr = new ANSNetworkScanCtlr(mContext, mMockTelephonyManager,
+                        new ANSNetworkScanCtlr.NetworkAvailableCallBack() {
+                        @Override
+                        public void onNetworkAvailability(List<CellInfo> results) {
+                            setReady(true);
+                        }
+
+                        @Override
+                        public void onError(int error) {
+                            mError = error;
+                            setReady(true);
+                        }
+                    });
+
+                mLooper = Looper.myLooper();
+                setReady(true);
+                Looper.loop();
+
+            }
+        }).start();
+
+        // Wait till initialization is complete.
+        waitUntilReady();
+        mReady = false;
+
+        // Testing startFastNetworkScan, onError should be called with ERROR_INVALID_SCAN
+        mANSNetworkScanCtlr.startFastNetworkScan(subscriptionInfoList);
+        mANSNetworkScanCtlr.mNetworkScanCallback.onError(NetworkScan.ERROR_INVALID_SCAN);
+        waitUntilReady(100);
+        assertEquals(NetworkScan.ERROR_INVALID_SCAN, mError);
+    }
+
+    @Test
+    public void testStartSlowNetworkScan() {
+        List<SubscriptionInfo> subscriptionInfoList = new ArrayList<SubscriptionInfo>();
+        SubscriptionInfo subscriptionInfo = new SubscriptionInfo(1, "", 1, "TMO", "TMO", 1, 1,
+                "123", 1, null, "310", "210", "", false, null, "1");
+        subscriptionInfoList.add(subscriptionInfo);
+        List<CellInfo> expectedResults = new ArrayList<CellInfo>();
+        CellIdentityLte cellIdentityLte = new CellIdentityLte(310, 210, 1, 1, 1);
+        CellInfoLte cellInfoLte = new CellInfoLte();
+        cellInfoLte.setCellIdentity(cellIdentityLte);
+        expectedResults.add((CellInfo)cellInfoLte);
+        mReady = false;
+
+        // initializing ANSNetworkScanCtlr
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                Looper.prepare();
+                mANSNetworkScanCtlr = new ANSNetworkScanCtlr(mContext, mMockTelephonyManager,
+                        new ANSNetworkScanCtlr.NetworkAvailableCallBack() {
+                        @Override
+                        public void onNetworkAvailability(List<CellInfo> results) {
+                            mResults = results;
+                            setReady(true);
+                        }
+
+                        public void onError(int error) {
+                            setReady(true);
+                        }
+                    });
+
+                mLooper = Looper.myLooper();
+                setReady(true);
+                Looper.loop();
+
+            }
+        }).start();
+
+        // Wait till initialization is complete.
+        waitUntilReady();
+        mReady = false;
+
+        // Testing startSlowNetworkScan, onNetworkAvailability should be called with expectedResults
+        mANSNetworkScanCtlr.startSlowNetworkScan(subscriptionInfoList);
+        mANSNetworkScanCtlr.mNetworkScanCallback.onResults(expectedResults);
+        waitUntilReady(100);
+        assertEquals(expectedResults, mResults);
+    }
+
+    @Test
+    public void testStopNetworkScan() {
+        List<SubscriptionInfo> subscriptionInfoList = new ArrayList<SubscriptionInfo>();
+        SubscriptionInfo subscriptionInfo = new SubscriptionInfo(1, "", 1, "TMO", "TMO", 1, 1,
+                "123", 1, null, "310", "210", "", false, null, "1");
+        subscriptionInfoList.add(subscriptionInfo);
+        List<CellInfo> expectedResults = new ArrayList<CellInfo>();
+        CellIdentityLte cellIdentityLte = new CellIdentityLte(310, 210, 1, 1, 1);
+        CellInfoLte cellInfoLte = new CellInfoLte();
+        cellInfoLte.setCellIdentity(cellIdentityLte);
+        expectedResults.add((CellInfo)cellInfoLte);
+        mCallbackInvoked = false;
+        mReady = false;
+
+        // initializing ANSNetworkScanCtlr
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                Looper.prepare();
+                mANSNetworkScanCtlr = new ANSNetworkScanCtlr(mContext, mMockTelephonyManager,
+                        new ANSNetworkScanCtlr.NetworkAvailableCallBack() {
+                        @Override
+                        public void onNetworkAvailability(List<CellInfo> results) {
+                            mCallbackInvoked = true;
+                            setReady(true);
+                        }
+
+                        public void onError(int error) {
+                            mCallbackInvoked = true;
+                        }
+                    });
+
+                mLooper = Looper.myLooper();
+                setReady(true);
+                Looper.loop();
+            }
+        }).start();
+
+        // Wait till initialization is complete.
+        waitUntilReady();
+        mReady = false;
+
+        // Testing stopNetworkScan, should not get any callback invocation after stopNetworkScan.
+        mANSNetworkScanCtlr.startSlowNetworkScan(subscriptionInfoList);
+        mANSNetworkScanCtlr.stopNetworkScan();
+        mANSNetworkScanCtlr.mNetworkScanCallback.onResults(expectedResults);
+        waitUntilReady(100);
+        assertFalse(mCallbackInvoked);
+    }
+}
diff --git a/tests/src/com/android/ans/ANSProfileSelectorTest.java b/tests/src/com/android/ans/ANSProfileSelectorTest.java
new file mode 100644
index 0000000..c39b4b4
--- /dev/null
+++ b/tests/src/com/android/ans/ANSProfileSelectorTest.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+package com.android.ans;
+
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.*;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.telephony.CellIdentityLte;
+import android.telephony.CellInfo;
+import android.telephony.CellInfoLte;
+import android.telephony.NetworkScan;
+import android.telephony.Rlog;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ANSProfileSelectorTest extends ANSBaseTest {
+    private MyANSProfileSelector mANSProfileSelector;
+    private boolean testFailed;
+    private boolean mCallbackInvoked;
+    private int mDataSubId;
+    ANSServiceStateMonitor.PhoneStateListenerImpl mPhoneStateListener;
+    @Mock
+    ANSNetworkScanCtlr mANSNetworkScanCtlr;
+    private Looper mLooper;
+    private static final String TAG = "ANSProfileSelectorTest";
+
+    MyANSProfileSelector.ANSProfileSelectionCallback mANSProfileSelectionCallback =
+            new MyANSProfileSelector.ANSProfileSelectionCallback() {
+        public void onProfileSelectionDone(int dataSubId, int voiceSubId) {
+            Rlog.d(TAG, "onProfileSelectionDone " + dataSubId + " " + voiceSubId);
+            mCallbackInvoked = true;
+            setReady(true);
+        }
+    };
+
+    public class MyANSProfileSelector extends ANSProfileSelector {
+        public ANSServiceStateMonitor.ANSServiceMonitorCallback mServiceMonitorCallbackCpy;
+        public SubscriptionManager.OnOpportunisticSubscriptionsChangedListener mProfileChngLstnrCpy;
+        public BroadcastReceiver mProfileSelectorBroadcastReceiverCpy;
+        public ANSNetworkScanCtlr.NetworkAvailableCallBack mNetworkAvailableCallBackCpy;
+
+        public MyANSProfileSelector(Context c,
+                MyANSProfileSelector.ANSProfileSelectionCallback aNSProfileSelectionCallback) {
+            super(c, aNSProfileSelectionCallback);
+        }
+
+        public void triggerProfileUpdate() {
+            mHandler.sendEmptyMessage(1);
+        }
+
+        protected void init(Context c,
+                MyANSProfileSelector.ANSProfileSelectionCallback aNSProfileSelectionCallback) {
+            super.init(c, aNSProfileSelectionCallback);
+            this.mSubscriptionManager = ANSProfileSelectorTest.this.mSubscriptionManager;
+            mServiceMonitorCallbackCpy = mServiceMonitorCallback;
+            mProfileChngLstnrCpy = mProfileChangeListener;
+            mProfileSelectorBroadcastReceiverCpy = mProfileSelectorBroadcastReceiver;
+            mNetworkAvailableCallBackCpy = mNetworkAvailableCallBack;
+            mNetworkScanCtlr = mANSNetworkScanCtlr;
+        }
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp("ANSTest");
+        mLooper = null;
+        MockitoAnnotations.initMocks(this);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+        if (mLooper != null) {
+            mLooper.quit();
+            mLooper.getThread().join();
+        }
+    }
+
+    @Test
+    public void testStartProfileSelectionWithNoOpportunisticSub() {
+        List<CellInfo> results2 = new ArrayList<CellInfo>();
+        CellIdentityLte cellIdentityLte = new CellIdentityLte(310, 210, 1, 1, 1);
+        CellInfoLte cellInfoLte = new CellInfoLte();
+        cellInfoLte.setCellIdentity(cellIdentityLte);
+        results2.add((CellInfo)cellInfoLte);
+
+        mReady = false;
+        mCallbackInvoked = false;
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                Looper.prepare();
+                mANSProfileSelector = new MyANSProfileSelector(mContext,
+                        mANSProfileSelectionCallback);
+                mLooper = Looper.myLooper();
+                setReady(true);
+                Looper.loop();
+            }
+        }).start();
+
+        doReturn(true).when(mANSNetworkScanCtlr).startFastNetworkScan(anyObject());
+        doReturn(null).when(mSubscriptionManager).getOpportunisticSubscriptions(anyInt());
+
+        // Wait till initialization is complete.
+        waitUntilReady();
+        mReady = false;
+
+        // Testing startProfileSelection without any oppotunistic data.
+        // should not get any callback invocation.
+        mANSProfileSelector.startProfileSelection();
+        waitUntilReady(100);
+        assertFalse(mCallbackInvoked);
+    }
+
+    @Test
+    public void testStartProfileSelectionSuccess() {
+        List<SubscriptionInfo> subscriptionInfoList = new ArrayList<SubscriptionInfo>();
+        SubscriptionInfo subscriptionInfo = new SubscriptionInfo(5, "", 1, "TMO", "TMO", 1, 1,
+                "123", 1, null, "310", "210", "", false, null, "1");
+        SubscriptionInfo subscriptionInfo2 = new SubscriptionInfo(5, "", 1, "TMO", "TMO", 1, 1,
+                "123", 1, null, "310", "211", "", false, null, "1");
+        subscriptionInfoList.add(subscriptionInfo);
+
+        List<CellInfo> results2 = new ArrayList<CellInfo>();
+        CellIdentityLte cellIdentityLte = new CellIdentityLte(310, 210, 1, 1, 1);
+        CellInfoLte cellInfoLte = new CellInfoLte();
+        cellInfoLte.setCellIdentity(cellIdentityLte);
+        results2.add((CellInfo)cellInfoLte);
+
+        mReady = false;
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                Looper.prepare();
+                mANSProfileSelector = new MyANSProfileSelector(mContext,
+                        new MyANSProfileSelector.ANSProfileSelectionCallback() {
+                    public void onProfileSelectionDone(int dataSubId, int voiceSubId) {
+                        Rlog.d(TAG, "onProfileSelectionDone " + dataSubId + " " + voiceSubId);
+                        mDataSubId = dataSubId;
+                        setReady(true);
+                    }
+                });
+                mLooper = Looper.myLooper();
+                setReady(true);
+                Looper.loop();
+            }
+        }).start();
+
+        doReturn(subscriptionInfoList).when(mSubscriptionManager).getOpportunisticSubscriptions(anyInt());
+
+        // Wait till initialization is complete.
+        waitUntilReady();
+        mReady = false;
+        mDataSubId = -1;
+
+        // Testing startProfileSelection with oppotunistic sub.
+        // On success onProfileSelectionDone must get invoked.
+        mANSProfileSelector.startProfileSelection();
+        assertFalse(mReady);
+        mANSProfileSelector.mNetworkAvailableCallBackCpy.onNetworkAvailability(results2);
+        Intent callbackIntent = new Intent(MyANSProfileSelector.ACTION_SUB_SWITCH);
+        callbackIntent.putExtra("sequenceId", 1);
+        callbackIntent.putExtra("subId", 5);
+        assertFalse(mReady);
+        mANSProfileSelector.mProfileSelectorBroadcastReceiverCpy.onReceive(mContext, callbackIntent);
+        assertFalse(mReady);
+        mANSProfileSelector.mServiceMonitorCallbackCpy.onServiceMonitorUpdate(5,
+                ANSServiceStateMonitor.SERVICE_STATE_GOOD);
+        waitUntilReady();
+        assertEquals(5, mDataSubId);
+    }
+}
diff --git a/tests/src/com/android/ans/ANSServiceStateEvaluatorTest.java b/tests/src/com/android/ans/ANSServiceStateEvaluatorTest.java
new file mode 100644
index 0000000..d3df264
--- /dev/null
+++ b/tests/src/com/android/ans/ANSServiceStateEvaluatorTest.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+package com.android.ans;
+
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.*;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+
+public class ANSServiceStateEvaluatorTest extends ANSBaseTest {
+    private SSMEvaluator mANSServiceStateEvaluator;
+    private MyANSServiceStateMonitor mVoiceSubMonitor;
+    private MyANSServiceStateMonitor mDataSubMonitor;
+    private int mDataSubId;
+    private int mVoiceSubId;
+    private boolean mCallbackInvoked;
+    private Object mLock2 = new Object();
+    private boolean isNotified = false;
+    private Looper mLooper;
+    ANSServiceStateMonitor.ANSServiceMonitorCallback mANSServiceMonitorCallback;
+    ANSServiceStateMonitor.PhoneStateListenerImpl mPhoneStateListener;
+
+    private class MyANSServiceStateMonitor extends ANSServiceStateMonitor {
+        ANSServiceStateMonitor.ANSServiceMonitorCallback mANSServiceMonitorCallbackOverride;
+        public MyANSServiceStateMonitor(Context c,
+                ANSServiceStateMonitor.ANSServiceMonitorCallback serviceMonitorCallback) {
+            super(c, serviceMonitorCallback);
+            mANSServiceMonitorCallbackOverride = serviceMonitorCallback;
+        }
+    }
+
+    public class MyANSServiceEvaluatorCallback
+            implements ANSServiceStateEvaluator.ANSServiceEvaluatorCallback {
+        public void onBadDataService() {
+            mCallbackInvoked = true;
+            setReady(true);
+        }
+    }
+
+    private class SSMEvaluator extends ANSServiceStateEvaluator {
+        SSMEvaluator(Context c,
+                ANSServiceStateEvaluator.ANSServiceEvaluatorCallback ANSServiceEvaluatorCallback) {
+            super(c, ANSServiceEvaluatorCallback);
+        }
+
+        protected void init(Context c, ANSServiceEvaluatorCallback ANSServiceEvaluatorCallback) {
+            super.init(c, ANSServiceEvaluatorCallback);
+            mANSServiceMonitorCallback = mServiceMonitorCallback;
+        }
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp("ANSTest");
+        mLooper = null;
+        MockitoAnnotations.initMocks(this);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+        if (mLooper != null) {
+            mLooper.quit();
+            mLooper.getThread().join();
+        }
+    }
+
+    @Test
+    public void testBadService() {
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                Looper.prepare();
+                mANSServiceStateEvaluator = new SSMEvaluator(mContext,
+                        new MyANSServiceEvaluatorCallback());
+                mANSServiceStateEvaluator.startEvaluation(5, 6);
+                mLooper = Looper.myLooper();
+                setReady(true);
+                Looper.loop();
+
+            }
+        }).start();
+
+        // Wait till initialization is complete.
+        waitUntilReady();
+        mCallbackInvoked = false;
+
+        // Testing startEvaluation, should get onBadDataService invoked.
+        ((SSMEvaluator)(mANSServiceStateEvaluator)).mDataServiceWaitTimer.onAlarm();
+        mANSServiceMonitorCallback.onServiceMonitorUpdate(6,
+                ANSServiceStateMonitor.SERVICE_STATE_GOOD);
+        mANSServiceMonitorCallback.onServiceMonitorUpdate(5,
+                ANSServiceStateMonitor.SERVICE_STATE_NO_SERVICE);
+        waitUntilReady();
+        assertTrue(mCallbackInvoked);
+    }
+
+
+    @Test
+    public void testStopEvaluation() {
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                Looper.prepare();
+                mANSServiceStateEvaluator = new SSMEvaluator(mContext,
+                        new MyANSServiceEvaluatorCallback());
+                mANSServiceStateEvaluator.startEvaluation(5, 6);
+                mLooper = Looper.myLooper();
+                setReady(true);
+                Looper.loop();
+            }
+        }).start();
+
+        // Wait till initialization is complete.
+        waitUntilReady();
+        mReady = false;
+        mCallbackInvoked = false;
+
+        // Testing stopEvaluation, should not get onBadDataService invoked.
+        ((SSMEvaluator)(mANSServiceStateEvaluator)).mDataServiceWaitTimer.onAlarm();
+        mANSServiceStateEvaluator.stopEvaluation();
+        mANSServiceMonitorCallback.onServiceMonitorUpdate(6,
+                ANSServiceStateMonitor.SERVICE_STATE_GOOD);
+        mANSServiceMonitorCallback.onServiceMonitorUpdate(5,
+                ANSServiceStateMonitor.SERVICE_STATE_NO_SERVICE);
+        waitUntilReady(100);
+        assertFalse(mCallbackInvoked);
+    }
+}
diff --git a/tests/src/com/android/ans/ANSServiceStateMonitorTest.java b/tests/src/com/android/ans/ANSServiceStateMonitorTest.java
new file mode 100644
index 0000000..7c194e7
--- /dev/null
+++ b/tests/src/com/android/ans/ANSServiceStateMonitorTest.java
@@ -0,0 +1,288 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+package com.android.ans;
+
+import static com.android.ans.ANSServiceStateMonitor.SERVICE_STATE_BAD;
+
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.*;
+
+import android.app.AppOpsManager;
+import android.content.Context;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.telephony.Rlog;
+import android.telephony.ServiceState;
+import android.telephony.SignalStrength;
+import android.telephony.SubscriptionInfo;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import com.android.internal.telephony.ISub;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.util.List;
+public class ANSServiceStateMonitorTest extends ANSBaseTest {
+    private static final String TAG = "ANSServiceStateMonitorTest";
+    MyANSServiceStateMonitor mServiceStateMonitor;
+    private boolean mIsCallBackReady;
+    private int mSubId;
+    private int mState;
+    private Looper mLooper;
+
+    private class MyANSServiceStateMonitor extends ANSServiceStateMonitor {
+        public MyANSServiceStateMonitor(Context c,
+                ANSServiceStateMonitor.ANSServiceMonitorCallback serviceMonitorCallback) {
+            super(c, serviceMonitorCallback);
+        }
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp("ANSTest");
+        mLooper = null;
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+        if (mLooper != null) {
+            mLooper.quit();
+            mLooper.getThread().join();
+        }
+
+    }
+
+    @Test @SmallTest
+    public void testIsFatalFailCause() {
+        boolean ret = ANSServiceStateMonitor.isFatalFailCause("INVALID_TRANSACTION_ID");
+        assertFalse(ret);
+
+        ret = ANSServiceStateMonitor.isFatalFailCause("OPERATOR_BARRED");
+        assertTrue(ret);
+    }
+
+
+    @Test
+    public void testOutOfService() {
+        mIsCallBackReady = false;
+        /* service monitor callback will get called for service state change on a particular subId. */
+        ANSServiceStateMonitor.ANSServiceMonitorCallback serviceMonitorCallback =
+                new ANSServiceStateMonitor.ANSServiceMonitorCallback() {
+                    @Override
+                    public void onServiceMonitorUpdate(int subId, int state) {
+                        if (!mIsCallBackReady) {
+                            return;
+                        }
+                        Rlog.d(TAG,"testOutOfService subId: " + subId + " state: "
+                                + ANSServiceStateMonitor.getStateString(state));
+                        mSubId = subId;
+                        mState = state;
+                        setReady(true);
+                    }
+                };
+
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                Looper.prepare();
+                mServiceStateMonitor =
+                        new MyANSServiceStateMonitor(mContext, serviceMonitorCallback);
+                mServiceStateMonitor.startListeningForNetworkConditionChange(10);
+                mServiceStateMonitor.getPhoneStateListener(10);
+                mLooper = Looper.myLooper();
+                setReady(true);
+                Looper.loop();
+
+            }
+        }).start();
+
+        // Wait till initialization is complete.
+        waitUntilReady();
+        mReady = false;
+
+        // Testing out of service, should get onServiceMonitorUpdate invoked
+        // ANSServiceStateMonitor.SERVICE_STATE_NO_SERVICE
+        ServiceState serviceState = new ServiceState();
+        serviceState.setDataRegState(ServiceState.STATE_OUT_OF_SERVICE);
+        mIsCallBackReady = true;
+        mServiceStateMonitor.getPhoneStateListener(10).onServiceStateChanged(serviceState);
+        waitUntilReady();
+        assertEquals(10, mSubId);
+        assertEquals(ANSServiceStateMonitor.SERVICE_STATE_NO_SERVICE, mState);
+    }
+
+    @Test
+    public void testInService() {
+        mIsCallBackReady = false;
+        ANSServiceStateMonitor.ANSServiceMonitorCallback serviceMonitorCallback =
+                new ANSServiceStateMonitor.ANSServiceMonitorCallback() {
+                    @Override
+                    public void onServiceMonitorUpdate(int subId, int state) {
+                        if (!mIsCallBackReady) {
+                            return;
+                        }
+                        Rlog.d(TAG,"testInService subId: " + subId + " state: "
+                                + ANSServiceStateMonitor.getStateString(state));
+                        mSubId = subId;
+                        mState = state;
+                        setReady(true);
+                    }
+                };
+
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                Looper.prepare();
+                mServiceStateMonitor = new MyANSServiceStateMonitor(mContext,
+                        serviceMonitorCallback);
+                mServiceStateMonitor.startListeningForNetworkConditionChange(10);
+                mServiceStateMonitor.getPhoneStateListener(10);
+                mLooper = Looper.myLooper();
+                setReady(true);
+                Looper.loop();
+
+            }
+        }).start();
+
+        // Wait till initialization is complete.
+        waitUntilReady();
+        mReady = false;
+
+        // Testing in good network condition, should get onServiceMonitorUpdate invoked
+        // ANSServiceStateMonitor.SERVICE_STATE_GOOD
+        ServiceState serviceState = new ServiceState();
+        serviceState.setDataRegState(ServiceState.STATE_IN_SERVICE);
+        mIsCallBackReady = true;
+        mServiceStateMonitor.getPhoneStateListener(10).onServiceStateChanged(serviceState);
+        waitUntilReady();
+        assertEquals(10, mSubId);
+        assertEquals(ANSServiceStateMonitor.SERVICE_STATE_GOOD, mState);
+    }
+
+    @Test
+    public void testbadSignalStrength() {
+        mIsCallBackReady = false;
+        ANSServiceStateMonitor.ANSServiceMonitorCallback serviceMonitorCallback =
+                new ANSServiceStateMonitor.ANSServiceMonitorCallback() {
+                    @Override
+                    public void onServiceMonitorUpdate(int subId, int state) {
+                        if (!mIsCallBackReady) {
+                            return;
+                        }
+                        Rlog.d(TAG,"testbadSignalStrength subId: " + subId + " state: "
+                                + ANSServiceStateMonitor.getStateString(state));
+                        mSubId = subId;
+                        mState = state;
+                        setReady(true);
+                    }
+                };
+
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                Looper.prepare();
+                mServiceStateMonitor = new MyANSServiceStateMonitor(mContext,
+                        serviceMonitorCallback);
+                mServiceStateMonitor.startListeningForNetworkConditionChange(10);
+                mServiceStateMonitor.getPhoneStateListener(10);
+                mLooper = Looper.myLooper();
+                setReady(true);
+                Looper.loop();
+
+            }
+        }).start();
+
+        // Wait till initialization is complete.
+        waitUntilReady();
+        mReady = false;
+
+        // Testing bad signal strength, should get onServiceMonitorUpdate invoked
+        // ANSServiceStateMonitor.SERVICE_STATE_BAD
+        SignalStrength signalStrength = new SignalStrength(-1, -1, 0, 0, 0, 0, 0,
+                -140, -140, 0, 0, 0, 0);
+        mServiceStateMonitor.getPhoneStateListener(10).onSignalStrengthsChanged(signalStrength);
+        ServiceState serviceState = new ServiceState();
+        serviceState.setDataRegState(ServiceState.STATE_IN_SERVICE);
+        Rlog.d(TAG, serviceState.toString());
+        mIsCallBackReady = true;
+        mServiceStateMonitor.getPhoneStateListener(10).onServiceStateChanged(serviceState);
+        waitUntilReady();
+        assertEquals(10, mSubId);
+        assertEquals(ANSServiceStateMonitor.SERVICE_STATE_BAD, mState);
+    }
+
+    @Test
+    public void testGoodSignalStrength() {
+        mIsCallBackReady = false;
+        ANSServiceStateMonitor.ANSServiceMonitorCallback serviceMonitorCallback =
+                new ANSServiceStateMonitor.ANSServiceMonitorCallback() {
+                    @Override
+                    public void onServiceMonitorUpdate(int subId, int state) {
+                        Rlog.d(TAG,"testGoodSignalStrength subId: " + subId + " state: "
+                                + ANSServiceStateMonitor.getStateString(state)
+                                + "mIsCallBackReady: " + mIsCallBackReady);
+                        if (!mIsCallBackReady) {
+                            return;
+                        }
+                        mSubId = subId;
+                        mState = state;
+                        setReady(true);
+                    }
+                };
+
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                Looper.prepare();
+                mServiceStateMonitor = new MyANSServiceStateMonitor(mContext,
+                        serviceMonitorCallback);
+                mServiceStateMonitor.startListeningForNetworkConditionChange(10);
+                mServiceStateMonitor.getPhoneStateListener(10);
+                mLooper = Looper.myLooper();
+                setReady(true);
+                Looper.loop();
+
+            }
+        }).start();
+
+        // Wait till initialization is complete.
+        waitUntilReady();
+        mReady = false;
+
+        // Testing good signal strength, should get onServiceMonitorUpdate invoked
+        // ANSServiceStateMonitor.SERVICE_STATE_GOOD
+        SignalStrength signalStrength = new SignalStrength(30, 0, 0, 0, 0, 0, 0, 30,
+                -95, -95, 131, 0, 0);
+        mServiceStateMonitor.getPhoneStateListener(10).onSignalStrengthsChanged(signalStrength);
+        ServiceState serviceState = new ServiceState();
+        serviceState.setDataRegState(ServiceState.STATE_IN_SERVICE);
+        Rlog.d(TAG, serviceState.toString());
+        mIsCallBackReady = true;
+        mServiceStateMonitor.getPhoneStateListener(10).onServiceStateChanged(serviceState);
+        waitUntilReady();
+        assertEquals(10, mSubId);
+        assertEquals(ANSServiceStateMonitor.SERVICE_STATE_GOOD, mState);
+    }
+}