blob: 34b71972aadebb7966004552c549600afde2c38b [file] [log] [blame]
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001/*
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
17package com.android.phone;
18
19import android.app.Activity;
20import android.app.NotificationManager;
21import android.os.Bundle;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070022import android.util.Log;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070023import android.view.View;
Aravind Sreekumarc94dea82018-04-10 15:34:32 -070024import android.view.View.OnClickListener;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070025import android.widget.Button;
26import android.widget.EditText;
27import android.widget.Toast;
28
Aravind Sreekumarc94dea82018-04-10 15:34:32 -070029import com.android.internal.telephony.test.SimulatedRadioControl;
30
Santos Cordon7d4ddf62013-07-10 11:58:08 -070031/**
32 * A simple activity that presents you with a UI for faking incoming phone operations.
33 */
34public class FakePhoneActivity extends Activity {
35 private static final String TAG = "FakePhoneActivity";
36
37 private Button mPlaceCall;
38 private EditText mPhoneNumber;
39 SimulatedRadioControl mRadioControl;
40
41 @Override
42 public void onCreate(Bundle icicle) {
43 super.onCreate(icicle);
44
45 setContentView(R.layout.fake_phone_activity);
46
47 mPlaceCall = (Button) findViewById(R.id.placeCall);
48 mPlaceCall.setOnClickListener(new ButtonListener());
49
50 mPhoneNumber = (EditText) findViewById(R.id.phoneNumber);
51 mPhoneNumber.setOnClickListener(
52 new View.OnClickListener() {
53 public void onClick(View v) {
54 mPlaceCall.requestFocus();
55 }
56 });
57
58 mRadioControl = PhoneGlobals.getPhone().getSimulatedRadioControl();
59
60 Log.i(TAG, "- PhoneApp.getInstance(): " + PhoneGlobals.getInstance());
61 Log.i(TAG, "- PhoneApp.getPhone(): " + PhoneGlobals.getPhone());
62 Log.i(TAG, "- mRadioControl: " + mRadioControl);
63 }
64
65 private class ButtonListener implements OnClickListener {
66 public void onClick(View v) {
67 if (mRadioControl == null) {
68 Log.e("Phone", "SimulatedRadioControl not available, abort!");
69 NotificationManager nm =
70 (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
71 Toast.makeText(FakePhoneActivity.this, "null mRadioControl!",
72 Toast.LENGTH_SHORT).show();
73 return;
74 }
75
76 mRadioControl.triggerRing(mPhoneNumber.getText().toString());
77 }
78 }
79}