1b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project/* 2b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Copyright (C) 2007 The Android Open Source Project 3b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 4b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 5b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * you may not use this file except in compliance with the License. 6b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * You may obtain a copy of the License at 7b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 8b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 9b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * 10b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 11b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 12b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * See the License for the specific language governing permissions and 14b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * limitations under the License. 15b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 16b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 17b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectpackage com.android.phone; 18b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 19b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.app.Activity; 20b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.app.NotificationManager; 21b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.os.Bundle; 22b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport com.android.internal.telephony.test.SimulatedRadioControl; 23b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.util.Log; 24b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.view.View.OnClickListener; 25b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.view.View; 26b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.widget.Button; 27b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.widget.EditText; 28b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectimport android.widget.Toast; 29b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 30b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project/** 31b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project * A simple activity that presents you with a UI for faking incoming phone operations. 32b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project */ 33b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Projectpublic class FakePhoneActivity extends Activity { 34b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private static final String TAG = "FakePhoneActivity"; 35b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 36b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private Button mPlaceCall; 37b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private EditText mPhoneNumber; 38b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project SimulatedRadioControl mRadioControl; 39b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 40b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project @Override 41b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public void onCreate(Bundle icicle) { 42b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project super.onCreate(icicle); 43b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 44b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project setContentView(R.layout.fake_phone_activity); 45b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 46b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPlaceCall = (Button) findViewById(R.id.placeCall); 47b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPlaceCall.setOnClickListener(new ButtonListener()); 48b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 49b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPhoneNumber = (EditText) findViewById(R.id.phoneNumber); 50b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPhoneNumber.setOnClickListener( 51b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project new View.OnClickListener() { 52b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public void onClick(View v) { 53b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mPlaceCall.requestFocus(); 54b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 55b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project }); 56b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 57b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mRadioControl = PhoneApp.getInstance().phone.getSimulatedRadioControl(); 58b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 59b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Log.i(TAG, "- PhoneApp.getInstance(): " + PhoneApp.getInstance()); 60b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Log.i(TAG, "- PhoneApp.getInstance().phone: " + PhoneApp.getInstance().phone); 61b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Log.i(TAG, "- mRadioControl: " + mRadioControl); 62b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 63b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 64b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project private class ButtonListener implements OnClickListener { 65b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project public void onClick(View v) { 66b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project if (mRadioControl == null) { 67b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Log.e("Phone", "SimulatedRadioControl not available, abort!"); 68b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project NotificationManager nm = 69b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 70b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Toast.makeText(FakePhoneActivity.this, "null mRadioControl!", 71b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project Toast.LENGTH_SHORT).show(); 72b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project return; 73b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 74b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project 75b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project mRadioControl.triggerRing(mPhoneNumber.getText().toString()); 76b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 77b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project } 78b16363f5fc191b769e88c364243e34b92eb22688The Android Open Source Project} 79