summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTa-wei Yen <twyen@google.com>2016-03-15 13:45:05 -0700
committerTa-wei Yen <twyen@google.com>2016-03-15 22:32:40 +0000
commite80368d449950c0d13ba78f5b8fa6eb62eafa384 (patch)
tree3e72c9722fcad7e9306aa0a12feeb04fe9f603c4 /tests
parentf1a5805b871d7292fb0d9c30b3aac5dad5da953b (diff)
downloadandroid_packages_services_Telephony-e80368d449950c0d13ba78f5b8fa6eb62eafa384.tar.gz
android_packages_services_Telephony-e80368d449950c0d13ba78f5b8fa6eb62eafa384.tar.bz2
android_packages_services_Telephony-e80368d449950c0d13ba78f5b8fa6eb62eafa384.zip
DO NOT MERGE Defer VVM activation/deactivation until device is unlocked.
VVM activation/deactivation requires voicemail status table update and sending SMS which is not available if the device is locked. The activation/deactivation also requires the subId of the SIM card, which is enumerated when the SIM loads, with the possibility of the device still being locked. This CL checks if the device is locked when SimChangeReceiver is triggered. If so, the subId will be stored by DeferredSimChangeProcessor and resent to SimChangeReceiver after the device is unlocked. VVM SYNC SMS could also be received when the device is locked. The SMS will simply be ignored, as a full sync will always be performed when the device in unlocked. Bug:27534089 Bug:26261432 Change-Id: I9a966e5b1b880a764e4ca6b18e77796a88496043 (cherry picked from commit 0d515a7e18ce04c42df7acb3160529d56cfebd80)
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/phone/vvm/omtp/OmtpBootCompletedReceiverTests.java90
1 files changed, 90 insertions, 0 deletions
diff --git a/tests/src/com/android/phone/vvm/omtp/OmtpBootCompletedReceiverTests.java b/tests/src/com/android/phone/vvm/omtp/OmtpBootCompletedReceiverTests.java
new file mode 100644
index 000000000..a2d247a0c
--- /dev/null
+++ b/tests/src/com/android/phone/vvm/omtp/OmtpBootCompletedReceiverTests.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2016 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.phone.vvm.omtp;
+
+import android.content.Context;
+import android.content.Intent;
+import android.preference.PreferenceManager;
+import android.test.AndroidTestCase;
+import android.util.ArraySet;
+
+import com.android.phone.vvm.omtp.OmtpBootCompletedReceiver.SubIdProcessor;
+
+import java.util.Set;
+
+public class OmtpBootCompletedReceiverTests extends AndroidTestCase {
+ OmtpBootCompletedReceiver mReceiver = new OmtpBootCompletedReceiver();
+ @Override
+ public void setUp() {
+ }
+
+ @Override
+ public void tearDown() {
+ PreferenceManager
+ .getDefaultSharedPreferences(getContext().createDeviceEncryptedStorageContext())
+ .edit().clear().apply();
+ }
+
+ public void testReadWriteList() {
+ readWriteList(new int[] {1});
+ }
+
+ public void testReadWriteList_Multiple() {
+ readWriteList(new int[] {1, 2});
+ }
+
+ public void testReadWriteList_Duplicate() {
+ readWriteList(new int[] {1, 1});
+ }
+
+ private void readWriteList(int[] values) {
+ for (int value : values) {
+ OmtpBootCompletedReceiver.addDeferredSubId(getContext(), value);
+ }
+ TestSubIdProcessor processor = new TestSubIdProcessor(values);
+ mReceiver.setSubIdProcessorForTest(processor);
+ Intent intent = new Intent(Intent.ACTION_BOOT_COMPLETED);
+ mReceiver.onReceive(getContext(), intent);
+ processor.assertMatch();
+ // after onReceive() is called the list should be empty
+ TestSubIdProcessor emptyProcessor = new TestSubIdProcessor(new int[] {});
+ mReceiver.setSubIdProcessorForTest(processor);
+ mReceiver.onReceive(getContext(), intent);
+ processor.assertMatch();
+ }
+
+ private static class TestSubIdProcessor implements SubIdProcessor {
+ private final Set<Integer> mExpectedSubIds;
+
+ public TestSubIdProcessor(int[] expectedSubIds) {
+ mExpectedSubIds = new ArraySet<>();
+ for(int subId : expectedSubIds){
+ mExpectedSubIds.add(subId);
+ }
+ }
+
+ @Override
+ public void process(Context context, int subId){
+ assertTrue(mExpectedSubIds.contains(subId));
+ mExpectedSubIds.remove(subId);
+ }
+
+ public void assertMatch(){
+ assertTrue(mExpectedSubIds.isEmpty());
+ }
+ }
+}