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