summaryrefslogtreecommitdiffstats
path: root/testapps/src
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2018-11-30 14:26:13 -0800
committerTyler Gunn <tgunn@google.com>2018-12-04 15:30:54 -0800
commitc972e903468aa598e31d9e3c8ac952c22b5a706f (patch)
tree164bcd2b236fa668417769275ffcb246df5661a3 /testapps/src
parent4673b43926124d4df17dd9ed0cedc87cfee19ed5 (diff)
downloadandroid_packages_services_Telecomm-c972e903468aa598e31d9e3c8ac952c22b5a706f.tar.gz
android_packages_services_Telecomm-c972e903468aa598e31d9e3c8ac952c22b5a706f.tar.bz2
android_packages_services_Telecomm-c972e903468aa598e31d9e3c8ac952c22b5a706f.zip
CallScreeningService behavior changes and improvements.
1. When sending information about a call to the CallScreeningService, using a new parceling method which passes the bare minimum amount of info about a call necessary to screen the call. 2. Fix bug where the app name was being logged as the package name for screened calls. Adding an AppLabelProxy in the CallScreeningServiceController to perform lookup of the app name for logging purposes. 3. Change lookup of user-defined call screening app to make use of the role manager proxy instead. Bug: 63966743 Test: Created call screening service test app. Test: Manually tested operation of user selected CS app using test app and test override commands. Change-Id: I51c816f36ad1e5dcd229271c608982113f97b751
Diffstat (limited to 'testapps/src')
-rw-r--r--testapps/src/com/android/server/telecom/testapps/CallScreeningActivity.java55
-rw-r--r--testapps/src/com/android/server/telecom/testapps/TestCallScreeningService.java68
2 files changed, 123 insertions, 0 deletions
diff --git a/testapps/src/com/android/server/telecom/testapps/CallScreeningActivity.java b/testapps/src/com/android/server/telecom/testapps/CallScreeningActivity.java
new file mode 100644
index 00000000..05ba500e
--- /dev/null
+++ b/testapps/src/com/android/server/telecom/testapps/CallScreeningActivity.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2018 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.server.telecom.testapps;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.telecom.CallScreeningService;
+import android.view.WindowManager;
+
+public class CallScreeningActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ AlertDialog alertDialog = new AlertDialog.Builder(this)
+ .setTitle("Test Call Screening")
+ .setMessage("Allow the call?")
+ .setNegativeButton("Block", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (TestCallScreeningService.getInstance() != null) {
+ TestCallScreeningService.getInstance().blockCall();
+ }
+ finish();
+ }
+ })
+ .setPositiveButton("Allow", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (TestCallScreeningService.getInstance() != null) {
+ TestCallScreeningService.getInstance().allowCall();
+ }
+ finish();
+ }
+ }).create();
+ alertDialog.show();
+ }
+}
diff --git a/testapps/src/com/android/server/telecom/testapps/TestCallScreeningService.java b/testapps/src/com/android/server/telecom/testapps/TestCallScreeningService.java
new file mode 100644
index 00000000..81a469e5
--- /dev/null
+++ b/testapps/src/com/android/server/telecom/testapps/TestCallScreeningService.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2018 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.server.telecom.testapps;
+
+import android.content.Intent;
+import android.telecom.Call;
+import android.telecom.CallScreeningService;
+import android.telecom.Log;
+
+public class TestCallScreeningService extends CallScreeningService {
+ private Call.Details mDetails;
+ private static TestCallScreeningService sTestCallScreeningService;
+
+ public static TestCallScreeningService getInstance() {
+ return sTestCallScreeningService;
+ }
+
+ /**
+ * Handles request from the system to screen an incoming call.
+ * @param callDetails Information about a new incoming call, see {@link Call.Details}.
+ */
+ @Override
+ public void onScreenCall(Call.Details callDetails) {
+ Log.i(this, "onScreenCall: received call %s", callDetails);
+ sTestCallScreeningService = this;
+
+ mDetails = callDetails;
+ Intent errorIntent = new Intent(this, CallScreeningActivity.class);
+ errorIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(errorIntent);
+ }
+
+ public void blockCall() {
+ CallScreeningService.CallResponse
+ response = new CallScreeningService.CallResponse.Builder()
+ .setDisallowCall(true)
+ .setRejectCall(true)
+ .setSkipCallLog(false)
+ .setSkipNotification(true)
+ .build();
+ respondToCall(mDetails, response);
+ }
+
+ public void allowCall() {
+ CallScreeningService.CallResponse
+ response = new CallScreeningService.CallResponse.Builder()
+ .setDisallowCall(false)
+ .setRejectCall(false)
+ .setSkipCallLog(false)
+ .setSkipNotification(false)
+ .build();
+ respondToCall(mDetails, response);
+ }
+}