diff options
author | Wink Saville <wink@google.com> | 2012-11-16 17:51:57 -0800 |
---|---|---|
committer | Wink Saville <wink@google.com> | 2012-11-16 17:51:57 -0800 |
commit | d008821aacac55a7d4717fb52b85ab5590be30eb (patch) | |
tree | 9921642e8f34afc0225862fef1eebd3f1d00849c | |
parent | fa4fd4721082689c4b276f67b845e7be249cb8da (diff) | |
download | android_frameworks_opt_telephony-d008821aacac55a7d4717fb52b85ab5590be30eb.tar.gz android_frameworks_opt_telephony-d008821aacac55a7d4717fb52b85ab5590be30eb.tar.bz2 android_frameworks_opt_telephony-d008821aacac55a7d4717fb52b85ab5590be30eb.zip |
Remove mockril.
Mock ril isn't being used and the V8 library is being removed,
so mockril is being removed.
Change-Id: I76238bd97ff82072786e05a275bd90102c02f391
10 files changed, 0 insertions, 1074 deletions
diff --git a/mockril/Android.mk b/mockril/Android.mk deleted file mode 100644 index 3778a5814..000000000 --- a/mockril/Android.mk +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (C) 2010 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. -# -# -ifneq ($(TARGET_BUILD_PDK),true) - -LOCAL_PATH:=$(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_JAVA_LIBRARIES := core framework - -LOCAL_STATIC_JAVA_LIBRARIES := librilproto-java - -LOCAL_MODULE := mockrilcontroller - -include $(BUILD_STATIC_JAVA_LIBRARY) - -endif # !PDK
\ No newline at end of file diff --git a/mockril/src/com/android/internal/telephony/mockril/MockRilController.java b/mockril/src/com/android/internal/telephony/mockril/MockRilController.java deleted file mode 100644 index 0e75c7248..000000000 --- a/mockril/src/com/android/internal/telephony/mockril/MockRilController.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (C) 2010, 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.internal.telephony.mockril; - -import android.os.Bundle; -import android.util.Log; - -import com.android.internal.communication.MsgHeader; -import com.android.internal.communication.Msg; -import com.android.internal.telephony.RilChannel; -import com.android.internal.telephony.ril_proto.RilCtrlCmds; -import com.android.internal.telephony.ril_proto.RilCmds; -import com.google.protobuf.micro.MessageMicro; - -import java.io.IOException; - -/** - * Contain a list of commands to control Mock RIL. Before using these commands the devices - * needs to be set with Mock RIL. Refer to hardware/ril/mockril/README.txt for details. - * - */ -public class MockRilController { - private static final String TAG = "MockRILController"; - private RilChannel mRilChannel = null; - private Msg mMessage = null; - - public MockRilController() throws IOException { - mRilChannel = RilChannel.makeRilChannel(); - } - - /** - * Close the channel after the communication is done. - * This method has to be called after the test is finished. - */ - public void closeChannel() { - mRilChannel.close(); - } - - /** - * Send commands and return true on success - * @param cmd for MsgHeader - * @param token for MsgHeader - * @param status for MsgHeader - * @param pbData for Msg data - * @return true if command is sent successfully, false if it fails - */ - private boolean sendCtrlCommand(int cmd, long token, int status, MessageMicro pbData) { - try { - Msg.send(mRilChannel, cmd, token, status, pbData); - } catch (IOException e) { - Log.v(TAG, "send command : %d failed: " + e.getStackTrace()); - return false; - } - return true; - } - - /** - * Get control response - * @return Msg if response is received, else return null. - */ - private Msg getCtrlResponse() { - Msg response = null; - try { - response = Msg.recv(mRilChannel); - } catch (IOException e) { - Log.v(TAG, "receive response for getRadioState() error: " + e.getStackTrace()); - return null; - } - return response; - } - - /** - * @return the radio state if it is valid, otherwise return -1 - */ - public int getRadioState() { - if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_GET_RADIO_STATE, 0, 0, null)) { - return -1; - } - Msg response = getCtrlResponse(); - if (response == null) { - Log.v(TAG, "failed to get response"); - return -1; - } - response.printHeader(TAG); - RilCtrlCmds.CtrlRspRadioState resp = - response.getDataAs(RilCtrlCmds.CtrlRspRadioState.class); - int state = resp.getState(); - if ((state >= RilCmds.RADIOSTATE_OFF) && (state <= RilCmds.RADIOSTATE_NV_READY)) - return state; - else - return -1; - } - - /** - * Set the radio state of mock ril to the given state - * @param state for given radio state - * @return true if the state is set successful, false if it fails - */ - public boolean setRadioState(int state) { - RilCtrlCmds.CtrlReqRadioState req = new RilCtrlCmds.CtrlReqRadioState(); - if (state < 0 || state > RilCmds.RADIOSTATE_NV_READY) { - Log.v(TAG, "the give radio state is not valid."); - return false; - } - req.setState(state); - if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_RADIO_STATE, 0, 0, req)) { - Log.v(TAG, "send set radio state request failed."); - return false; - } - Msg response = getCtrlResponse(); - if (response == null) { - Log.v(TAG, "failed to get response for setRadioState"); - return false; - } - response.printHeader(TAG); - RilCtrlCmds.CtrlRspRadioState resp = - response.getDataAs(RilCtrlCmds.CtrlRspRadioState.class); - int curstate = resp.getState(); - return curstate == state; - } - - /** - * Start an incoming call for the given phone number - * - * @param phoneNumber is the number to show as incoming call - * @return true if the incoming call is started successfully, false if it fails. - */ - public boolean startIncomingCall(String phoneNumber) { - RilCtrlCmds.CtrlReqSetMTCall req = new RilCtrlCmds.CtrlReqSetMTCall(); - - req.setPhoneNumber(phoneNumber); - if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_MT_CALL, 0, 0, req)) { - Log.v(TAG, "send CMD_SET_MT_CALL request failed"); - return false; - } - return true; - } - - /** - * Hang up a connection remotelly for the given call fail cause - * - * @param connectionID is the connection to be hung up - * @param failCause is the call fail cause defined in ril.h - * @return true if the hangup is successful, false if it fails - */ - public boolean hangupRemote(int connectionId, int failCause) { - RilCtrlCmds.CtrlHangupConnRemote req = new RilCtrlCmds.CtrlHangupConnRemote(); - req.setConnectionId(connectionId); - req.setCallFailCause(failCause); - - if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_HANGUP_CONN_REMOTE, 0, 0, req)) { - Log.v(TAG, "send CTRL_CMD_HANGUP_CONN_REMOTE request failed"); - return false; - } - return true; - } - - /** - * Set call transition flag to the Mock Ril - * - * @param flag is a boolean value for the call transiton flag - * true: call transition: dialing->alert, alert->active is controlled - * false: call transition is automatically handled by Mock Ril - * @return true if the request is successful, false if it failed to set the flag - */ - public boolean setCallTransitionFlag(boolean flag) { - RilCtrlCmds.CtrlSetCallTransitionFlag req = new RilCtrlCmds.CtrlSetCallTransitionFlag(); - - req.setFlag(flag); - - if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_CALL_TRANSITION_FLAG, 0, 0, req)) { - Log.v(TAG, "send CTRL_CMD_SET_CALL_TRANSITION_FLAG request failed"); - return false; - } - return true; - } - - /** - * Set the dialing call to alert if the call transition flag is true - * - * @return true if the call transition is successful, false if it fails - */ - public boolean setDialCallToAlert() { - if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_CALL_ALERT, 0, 0, null)) { - Log.v(TAG, "send CTRL_CMD_SET_CALL_ALERT request failed"); - return false; - } - return true; - } - - /** - * Set the alert call to active if the call transition flag is true - * - * @return true if the call transition is successful, false if it fails - */ - public boolean setAlertCallToActive() { - if (!sendCtrlCommand(RilCtrlCmds.CTRL_CMD_SET_CALL_ACTIVE, 0, 0, null)) { - Log.v(TAG, "send CTRL_CMD_SET_CALL_ACTIVE request failed"); - return false; - } - return true; - } -} diff --git a/tests/telephonymockriltests/Android.mk b/tests/telephonymockriltests/Android.mk deleted file mode 100644 index 9731d0d00..000000000 --- a/tests/telephonymockriltests/Android.mk +++ /dev/null @@ -1,14 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -LOCAL_SRC_FILES := $(call all-subdir-java-files) - -LOCAL_STATIC_JAVA_LIBRARIES := mockrilcontroller - -LOCAL_JAVA_LIBRARIES := android.test.runner - -LOCAL_PACKAGE_NAME := TelephonyMockRilTests - -include $(BUILD_PACKAGE) diff --git a/tests/telephonymockriltests/AndroidManifest.xml b/tests/telephonymockriltests/AndroidManifest.xml deleted file mode 100644 index 63f44a2d8..000000000 --- a/tests/telephonymockriltests/AndroidManifest.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<!-- Copyright (C) 2009 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.telephonymockriltests"> - - <application> - <uses-library android:name="android.test.runner" /> - <activity android:label="TelephonyMockRilTest" - android:name="TelephonyMockRilTest"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER"/> - </intent-filter> - </activity> - </application> - - <instrumentation android:name=".TelephonyMockTestRunner" - android:targetPackage="com.android.telephonymockriltests" - android:label="Test runner for Telephony Tests Using Mock RIL" - /> - - <uses-permission android:name="android.permission.READ_PHONE_STATE" /> - <uses-permission android:name="android.permission.INTERNET" /> - -</manifest> diff --git a/tests/telephonymockriltests/src/com/android/telephonymockriltests/TelephonyMockTestRunner.java b/tests/telephonymockriltests/src/com/android/telephonymockriltests/TelephonyMockTestRunner.java deleted file mode 100644 index 78ee73809..000000000 --- a/tests/telephonymockriltests/src/com/android/telephonymockriltests/TelephonyMockTestRunner.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2010, 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.telephonymockriltests; - -import android.os.Bundle; -import android.test.InstrumentationTestRunner; -import android.test.InstrumentationTestSuite; -import com.android.internal.telephony.mockril.MockRilController; -import android.util.Log; - -import com.android.telephonymockriltests.functional.SimpleTestUsingMockRil; - -import java.io.IOException; -import junit.framework.TestSuite; -import junit.framework.TestCase; - -/** - * Test runner for telephony tests that using Mock RIL - * - */ -public class TelephonyMockTestRunner extends InstrumentationTestRunner { - private static final String TAG="TelephonyMockTestRunner"; - public MockRilController mController; - - @Override - public TestSuite getAllTests() { - TestSuite suite = new InstrumentationTestSuite(this); - suite.addTestSuite(SimpleTestUsingMockRil.class); - return suite; - } - - @Override - public void onCreate(Bundle icicle) { - try { - mController = new MockRilController(); - } catch (IOException e) { - e.printStackTrace(); - TestCase.assertTrue("Create Mock RIl Controller failed", false); - } - TestCase.assertNotNull(mController); - super.onCreate(icicle); - } - - @Override - public void finish(int resultCode, Bundle results) { - if (mController != null) - mController.closeChannel(); - super.finish(resultCode, results); - } -} diff --git a/tests/telephonymockriltests/src/com/android/telephonymockriltests/functional/SimpleTestUsingMockRil.java b/tests/telephonymockriltests/src/com/android/telephonymockriltests/functional/SimpleTestUsingMockRil.java deleted file mode 100644 index 3ea1cf20a..000000000 --- a/tests/telephonymockriltests/src/com/android/telephonymockriltests/functional/SimpleTestUsingMockRil.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2010 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.telephonymockriltests.functional; - -import com.android.internal.telephony.mockril.MockRilController; -import android.test.InstrumentationTestCase; -import android.util.Log; - -import com.android.telephonymockriltests.TelephonyMockTestRunner; - -/** - * A simple test that using Mock RIL Controller - */ -public class SimpleTestUsingMockRil extends InstrumentationTestCase { - private static final String TAG = "SimpleTestUsingMockRil"; - private MockRilController mMockRilCtrl = null; - private TelephonyMockTestRunner mRunner; - - @Override - public void setUp() throws Exception { - super.setUp(); - mRunner = (TelephonyMockTestRunner)getInstrumentation(); - mMockRilCtrl = mRunner.mController; - assertNotNull(mMockRilCtrl); - } - - /** - * Get the current radio state of RIL - */ - public void testGetRadioState() { - int state = mMockRilCtrl.getRadioState(); - Log.v(TAG, "testGetRadioState: " + state); - assertTrue(state >= 0 && state <= 9); - } - - /** - * Set the current radio state of RIL - * and verify the radio state is set correctly - */ - public void testSetRadioState() { - for (int state = 0; state <= 9; state++) { - Log.v(TAG, "set radio state to be " + state); - assertTrue("set radio state: " + state + " failed.", - mMockRilCtrl.setRadioState(state)); - } - assertFalse("use an invalid radio state", mMockRilCtrl.setRadioState(-1)); - assertFalse("the radio state doesn't exist", mMockRilCtrl.setRadioState(10)); - } -} diff --git a/tests/telephonytests/AndroidManifest.xml b/tests/telephonytests/AndroidManifest.xml index ba1d95745..eaf17bdd9 100644 --- a/tests/telephonytests/AndroidManifest.xml +++ b/tests/telephonytests/AndroidManifest.xml @@ -33,11 +33,6 @@ android:label="Frameworks Telephony Tests"> </instrumentation> - <instrumentation android:name=".TelephonyMockRilTestRunner" - android:targetPackage="com.android.frameworks.telephonytests" - android:label="Test Runner for Mock Ril Tests" - /> - <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> diff --git a/tests/telephonytests/src/com/android/frameworks/telephonytests/TelephonyMockRilTestRunner.java b/tests/telephonytests/src/com/android/frameworks/telephonytests/TelephonyMockRilTestRunner.java deleted file mode 100644 index 9192f572f..000000000 --- a/tests/telephonytests/src/com/android/frameworks/telephonytests/TelephonyMockRilTestRunner.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2010, 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.frameworks.telephonytests; - -import android.os.Bundle; - -import android.test.InstrumentationTestRunner; -import android.test.InstrumentationTestSuite; -import android.util.Log; - -import java.io.IOException; - -import com.android.internal.telephony.RilChannel; -import com.android.internal.telephony.mockril.MockRilTest; - -import junit.framework.TestSuite; - -public class TelephonyMockRilTestRunner extends InstrumentationTestRunner { - - public RilChannel mMockRilChannel; - - @Override - public TestSuite getAllTests() { - log("getAllTests E"); - TestSuite suite = new InstrumentationTestSuite(this); - suite.addTestSuite(MockRilTest.class); - log("getAllTests X"); - return suite; - } - - @Override - public ClassLoader getLoader() { - log("getLoader EX"); - return TelephonyMockRilTestRunner.class.getClassLoader(); - } - - @Override - public void onCreate(Bundle icicle) { - log("onCreate E"); - try { - mMockRilChannel = RilChannel.makeRilChannel(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - log("onCreate X"); - - super.onCreate(icicle); - } - - @Override - public void onDestroy() { - // I've not seen this called - log("onDestroy EX"); - super.onDestroy(); - } - - @Override - public void onStart() { - // Called when the instrumentation thread is started. - // At the moment we don't need the thread so return - // which will shut down this unused thread. - log("onStart EX"); - super.onStart(); - } - - @Override - public void finish(int resultCode, Bundle results) { - // Called when complete so I ask the mMockRilChannel to quit. - log("finish E"); - mMockRilChannel.close(); - log("finish X"); - super.finish(resultCode, results); - } - - private void log(String s) { - Log.e("TelephonyMockRilTestRunner", s); - } -} diff --git a/tests/telephonytests/src/com/android/internal/telephony/CallerInfoTest.java b/tests/telephonytests/src/com/android/internal/telephony/CallerInfoTest.java deleted file mode 100644 index 1e5dafb3d..000000000 --- a/tests/telephonytests/src/com/android/internal/telephony/CallerInfoTest.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (C) 2009 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.internal.telephony; - -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; - -import android.content.ContentResolver; -import android.content.Context; -import android.content.res.Resources; -import com.android.internal.telephony.CallerInfo; -import com.android.internal.telephony.CallerInfoAsyncQuery; -import android.util.Log; -import android.os.Looper; -import android.test.ActivityInstrumentationTestCase; -import android.util.StringBuilderPrinter; - -/* - * Check the CallerInfo utility class works as expected. - * - */ - -public class CallerInfoTest extends AndroidTestCase { - private CallerInfo mInfo; - private Context mContext; - - private static final String kEmergencyNumber = "Emergency Number"; - private static final int kToken = 0xdeadbeef; - private static final String TAG = "CallerInfoUnitTest"; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mContext = new MockContext(); - mInfo = new CallerInfo(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - /** - * Checks the caller info instance is flagged as an emergency if - * the number is an emergency one. There is no test for the - * contact based constructors because emergency number are not in - * the contact DB. - */ - @SmallTest - public void testEmergencyIsProperlySet() throws Exception { - assertFalse(mInfo.isEmergencyNumber()); - - mInfo = CallerInfo.getCallerInfo(mContext, "911"); - assertIsValidEmergencyCallerInfo(); - - mInfo = CallerInfo.getCallerInfo(mContext, "tel:911"); - assertIsValidEmergencyCallerInfo(); - - - // This one hits the content resolver. - mInfo = CallerInfo.getCallerInfo(mContext, "18001234567"); - assertFalse(mInfo.isEmergencyNumber()); - } - - /** - * Same as testEmergencyIsProperlySet but uses the async query api. - */ - @SmallTest - public void testEmergencyIsProperlySetUsingAsyncQuery() throws Exception { - QueryRunner query; - - query = new QueryRunner("911"); - query.runAndCheckCompletion(); - assertIsValidEmergencyCallerInfo(); - - query = new QueryRunner("tel:911"); - query.runAndCheckCompletion(); - assertIsValidEmergencyCallerInfo(); - - query = new QueryRunner("18001234567"); - query.runAndCheckCompletion(); - assertFalse(mInfo.isEmergencyNumber()); - } - - /** - * For emergency caller info, phoneNumber should be set to the - * string emergency_call_dialog_number_for_display and the - * photoResource should be set to the picture_emergency drawable. - */ - @SmallTest - public void testEmergencyNumberAndPhotoAreSet() throws Exception { - mInfo = CallerInfo.getCallerInfo(mContext, "911"); - - assertIsValidEmergencyCallerInfo(); - } - - // TODO: Add more tests: - /** - * Check if the voice mail number cannot be retrieved that the - * original phone number is preserved. - */ - /** - * Check the markAs* methods work. - */ - - - // - // Helpers - // - - // Partial implementation of MockResources. - public class MockResources extends android.test.mock.MockResources - { - @Override - public String getString(int resId) throws Resources.NotFoundException { - switch (resId) { - case com.android.internal.R.string.emergency_call_dialog_number_for_display: - return kEmergencyNumber; - default: - throw new UnsupportedOperationException("Missing handling for resid " + resId); - } - } - } - - // Partial implementation of MockContext. - public class MockContext extends android.test.mock.MockContext { - private ContentResolver mResolver; - private Resources mResources; - - public MockContext() { - mResolver = new android.test.mock.MockContentResolver(); - mResources = new MockResources(); - } - - @Override - public ContentResolver getContentResolver() { - return mResolver; - } - - @Override - public Resources getResources() { - return mResources; - } - } - - /** - * Class to run a CallerInfoAsyncQuery in a separate thread, with - * its own Looper. We cannot use the main Looper because on the - * 1st quit the thread is maked dead, ie no further test can use - * it. Also there is not way to inject a Looper instance in the - * query, so we have to use a thread with its own looper. - */ - private class QueryRunner extends Thread - implements CallerInfoAsyncQuery.OnQueryCompleteListener { - private Looper mLooper; - private String mNumber; - private boolean mAsyncCompleted; - - public QueryRunner(String number) { - super(); - mNumber = number; - } - - // Run the query in the thread, wait for completion. - public void runAndCheckCompletion() throws InterruptedException { - start(); - join(); - assertTrue(mAsyncCompleted); - } - - @Override - public void run() { - Looper.prepare(); - mLooper = Looper.myLooper(); - mAsyncCompleted = false; - // The query will pick the thread local looper we've just prepared. - CallerInfoAsyncQuery.startQuery(kToken, mContext, mNumber, this, null); - mLooper.loop(); - } - - // Quit the Looper on the 1st callback - // (EVENT_EMERGENCY_NUMBER). There is another message - // (EVENT_END_OF_QUEUE) that will never be delivered because - // the test has exited. The corresponding stack trace - // "Handler{xxxxx} sending message to a Handler on a dead - // thread" can be ignored. - public void onQueryComplete(int token, Object cookie, CallerInfo info) { - mAsyncCompleted = true; - mInfo = info; - mLooper.quit(); - } - } - - /** - * Fail if mInfo does not contain a valid emergency CallerInfo instance. - */ - private void assertIsValidEmergencyCallerInfo() throws Exception { - assertTrue(mInfo.isEmergencyNumber()); - - // For emergency caller info, phoneNumber should be set to the - // string emergency_call_dialog_number_for_display and the - // photoResource should be set to the picture_emergency drawable. - assertEquals(kEmergencyNumber, mInfo.phoneNumber); - assertEquals(com.android.internal.R.drawable.picture_emergency, mInfo.photoResource); - - // The name should be null - assertNull(mInfo.name); - assertEquals(0, mInfo.namePresentation); - assertNull(mInfo.cnapName); - assertEquals(0, mInfo.numberPresentation); - - assertFalse(mInfo.contactExists); - assertEquals(0, mInfo.person_id); - assertFalse(mInfo.needUpdate); - assertNull(mInfo.contactRefUri); - - assertNull(mInfo.phoneLabel); - assertEquals(0, mInfo.numberType); - assertNull(mInfo.numberLabel); - - assertNull(mInfo.contactRingtoneUri); - assertFalse(mInfo.shouldSendToVoicemail); - - assertNull(mInfo.cachedPhoto); - assertFalse(mInfo.isCachedPhotoCurrent); - } -} diff --git a/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java b/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java deleted file mode 100644 index 3149ee15e..000000000 --- a/tests/telephonytests/src/com/android/internal/telephony/mockril/MockRilTest.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (C) 2010 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.internal.telephony.mockril; - -import android.util.Log; -import android.test.InstrumentationTestCase; - -import java.io.IOException; -import java.nio.ByteBuffer; - -import com.android.internal.communication.MsgHeader; -import com.android.internal.communication.Msg; -import com.android.internal.telephony.RilChannel; -import com.android.internal.telephony.ril_proto.RilCtrlCmds; -import com.android.internal.telephony.ril_proto.RilCmds; - -import com.android.frameworks.telephonytests.TelephonyMockRilTestRunner; -import com.google.protobuf.micro.InvalidProtocolBufferMicroException; - -// Test suite for test ril -public class MockRilTest extends InstrumentationTestCase { - private static final String TAG = "MockRilTest"; - - RilChannel mMockRilChannel; - TelephonyMockRilTestRunner mRunner; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mRunner = (TelephonyMockRilTestRunner)getInstrumentation(); - mMockRilChannel = mRunner.mMockRilChannel; - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - static void log(String s) { - Log.v(TAG, s); - } - - /** - * Test Case 1: Test protobuf serialization and deserialization - * @throws InvalidProtocolBufferMicroException - */ - public void testProtobufSerDes() throws InvalidProtocolBufferMicroException { - log("testProtobufSerdes E"); - - RilCtrlCmds.CtrlRspRadioState rs = new RilCtrlCmds.CtrlRspRadioState(); - assertTrue(String.format("expected rs.state == 0 was %d", rs.getState()), - rs.getState() == 0); - rs.setState(1); - assertTrue(String.format("expected rs.state == 1 was %d", rs.getState()), - rs.getState() == 1); - - byte[] rs_ser = rs.toByteArray(); - RilCtrlCmds.CtrlRspRadioState rsNew = RilCtrlCmds.CtrlRspRadioState.parseFrom(rs_ser); - assertTrue(String.format("expected rsNew.state == 1 was %d", rs.getState()), - rs.getState() == 1); - - log("testProtobufSerdes X"); - } - - /** - * Test case 2: Test echo command works using writeMsg & readMsg - */ - public void testEchoMsg() throws IOException { - log("testEchoMsg E"); - - MsgHeader mh = new MsgHeader(); - mh.setCmd(0); - mh.setToken(1); - mh.setStatus(2); - ByteBuffer data = ByteBuffer.allocate(3); - data.put((byte)3); - data.put((byte)4); - data.put((byte)5); - Msg.send(mMockRilChannel, mh, data); - - Msg respMsg = Msg.recv(mMockRilChannel); - assertTrue(String.format("expected mhd.header.cmd == 0 was %d",respMsg.getCmd()), - respMsg.getCmd() == 0); - assertTrue(String.format("expected mhd.header.token == 1 was %d",respMsg.getToken()), - respMsg.getToken() == 1); - assertTrue(String.format("expected mhd.header.status == 2 was %d", respMsg.getStatus()), - respMsg.getStatus() == 2); - assertTrue(String.format("expected mhd.data[0] == 3 was %d", respMsg.getData(0)), - respMsg.getData(0) == 3); - assertTrue(String.format("expected mhd.data[1] == 4 was %d", respMsg.getData(1)), - respMsg.getData(1) == 4); - assertTrue(String.format("expected mhd.data[2] == 5 was %d", respMsg.getData(2)), - respMsg.getData(2) == 5); - - log("testEchoMsg X"); - } - - /** - * Test case 3: Test get as - */ - public void testGetAs() { - log("testGetAs E"); - - // Use a message header as the protobuf data content - MsgHeader mh = new MsgHeader(); - mh.setCmd(12345); - mh.setToken(9876); - mh.setStatus(7654); - mh.setLengthData(4321); - byte[] data = mh.toByteArray(); - MsgHeader mhResult = Msg.getAs(MsgHeader.class, data); - - assertTrue(String.format("expected cmd == 12345 was %d", mhResult.getCmd()), - mhResult.getCmd() == 12345); - assertTrue(String.format("expected token == 9876 was %d", mhResult.getToken()), - mhResult.getToken() == 9876); - assertTrue(String.format("expected status == 7654 was %d", mhResult.getStatus()), - mhResult.getStatus() == 7654); - assertTrue(String.format("expected lengthData == 4321 was %d", mhResult.getLengthData()), - mhResult.getLengthData() == 4321); - - Msg msg = Msg.obtain(); - msg.setData(ByteBuffer.wrap(data)); - - mhResult = msg.getDataAs(MsgHeader.class); - - assertTrue(String.format("expected cmd == 12345 was %d", mhResult.getCmd()), - mhResult.getCmd() == 12345); - assertTrue(String.format("expected token == 9876 was %d", mhResult.getToken()), - mhResult.getToken() == 9876); - assertTrue(String.format("expected status == 7654 was %d", mhResult.getStatus()), - mhResult.getStatus() == 7654); - assertTrue(String.format("expected lengthData == 4321 was %d", mhResult.getLengthData()), - mhResult.getLengthData() == 4321); - - log("testGetAs X"); - } - - /** - * Test case 3: test get radio state - */ - public void testGetRadioState() throws IOException { - log("testGetRadioState E"); - - Msg.send(mMockRilChannel, 1, 9876, 0, null); - - Msg resp = Msg.recv(mMockRilChannel); - //resp.printHeader("testGetRadioState"); - - assertTrue(String.format("expected cmd == 1 was %d", resp.getCmd()), - resp.getCmd() == 1); - assertTrue(String.format("expected token == 9876 was %d", resp.getToken()), - resp.getToken() == 9876); - assertTrue(String.format("expected status == 0 was %d", resp.getStatus()), - resp.getStatus() == 0); - - RilCtrlCmds.CtrlRspRadioState rsp = resp.getDataAs(RilCtrlCmds.CtrlRspRadioState.class); - - int state = rsp.getState(); - log("testGetRadioState state=" + state); - assertTrue(String.format("expected RadioState >= 0 && RadioState <= 9 was %d", state), - ((state >= 0) && (state <= 9))); - - log("testGetRadioState X"); - } - - /** - * Test case 5: test set radio state - */ - public void testSetRadioState() throws IOException { - log("testSetRadioState E"); - - RilCtrlCmds.CtrlReqRadioState cmdrs = new RilCtrlCmds.CtrlReqRadioState(); - assertEquals(0, cmdrs.getState()); - - cmdrs.setState(RilCmds.RADIOSTATE_SIM_NOT_READY); - assertEquals(2, cmdrs.getState()); - - Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_SET_RADIO_STATE, 0, 0, cmdrs); - - Msg resp = Msg.recv(mMockRilChannel); - log("get response status :" + resp.getStatus()); - log("get response for command: " + resp.getCmd()); - log("get command token: " + resp.getToken()); - - RilCtrlCmds.CtrlRspRadioState rsp = resp.getDataAs(RilCtrlCmds.CtrlRspRadioState.class); - - int state = rsp.getState(); - log("get response for testSetRadioState: " + state); - assertTrue(RilCmds.RADIOSTATE_SIM_NOT_READY == state); - } - - /** - * Test case 6: test start incoming call and hangup it. - */ - public void testStartIncomingCallAndHangup() throws IOException { - log("testStartIncomingCallAndHangup"); - RilCtrlCmds.CtrlReqSetMTCall cmd = new RilCtrlCmds.CtrlReqSetMTCall(); - String incomingCall = "6502889108"; - // set the MT call - cmd.setPhoneNumber(incomingCall); - Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_SET_MT_CALL, 0, 0, cmd); - // get response - Msg resp = Msg.recv(mMockRilChannel); - log("Get response status: " + resp.getStatus()); - assertTrue("The ril is not in a proper state to set MT calls.", - resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); - - // allow the incoming call alerting for some time - try { - Thread.sleep(5000); - } catch (InterruptedException e) {} - - // we are playing a trick to assume the current is 1 - RilCtrlCmds.CtrlHangupConnRemote hangupCmd = new RilCtrlCmds.CtrlHangupConnRemote(); - hangupCmd.setConnectionId(1); - hangupCmd.setCallFailCause(16); // normal hangup - Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_HANGUP_CONN_REMOTE, 0, 0, hangupCmd); - - // get response - resp = Msg.recv(mMockRilChannel); - log("Get response for hangup connection: " + resp.getStatus()); - assertTrue("CTRL_CMD_HANGUP_CONN_REMOTE failed", - resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); - } - - /** - * Test case 7: test set call transition flag - */ - public void testSetCallTransitionFlag() throws IOException { - log("testSetCallTransitionFlag"); - // Set flag to true: - RilCtrlCmds.CtrlSetCallTransitionFlag cmd = new RilCtrlCmds.CtrlSetCallTransitionFlag(); - cmd.setFlag(true); - Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_SET_CALL_TRANSITION_FLAG, 0, 0, cmd); - - Msg resp = Msg.recv(mMockRilChannel); - log("Get response status: " + resp.getStatus()); - assertTrue("Set call transition flag failed", - resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); - - // add a dialing call - RilCtrlCmds.CtrlReqAddDialingCall cmdDialCall = new RilCtrlCmds.CtrlReqAddDialingCall(); - String phoneNumber = "5102345678"; - cmdDialCall.setPhoneNumber(phoneNumber); - Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_ADD_DIALING_CALL, 0, 0, cmdDialCall); - resp = Msg.recv(mMockRilChannel); - log("Get response status for adding a dialing call: " + resp.getStatus()); - assertTrue("add dialing call failed", - resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); - try { - Thread.sleep(5000); - } catch (InterruptedException e) {} - - // send command to force call state change - Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_SET_CALL_ALERT, 0, 0, null); - resp = Msg.recv(mMockRilChannel); - log("Get response status: " + resp.getStatus()); - assertTrue("Set call alert failed", - resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); - - try { - Thread.sleep(2000); - } catch (InterruptedException e) {} - - // send command to force call state change - Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_SET_CALL_ACTIVE, 0, 0, null); - resp = Msg.recv(mMockRilChannel); - log("Get response status: " + resp.getStatus()); - assertTrue("Set call active failed", - resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); - - // hangup the active all remotely - RilCtrlCmds.CtrlHangupConnRemote hangupCmd = new RilCtrlCmds.CtrlHangupConnRemote(); - hangupCmd.setConnectionId(1); - hangupCmd.setCallFailCause(16); // normal hangup - Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_HANGUP_CONN_REMOTE, 0, 0, hangupCmd); - resp = Msg.recv(mMockRilChannel); - log("Get response for hangup connection: " + resp.getStatus()); - assertTrue("CTRL_CMD_HANGUP_CONN_REMOTE failed", - resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); - - // set the flag to false - cmd.setFlag(false); - Msg.send(mMockRilChannel, RilCtrlCmds.CTRL_CMD_SET_CALL_TRANSITION_FLAG, 0, 0, cmd); - resp = Msg.recv(mMockRilChannel); - assertTrue("Set call transition flag failed", - resp.getStatus() == RilCtrlCmds.CTRL_STATUS_OK); - } -} |