summaryrefslogtreecommitdiffstats
path: root/testapps
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2019-01-16 10:43:26 -0800
committerTyler Gunn <tgunn@google.com>2019-01-22 20:07:23 -0800
commitf4f7576fc85dfae9711f10a9d840de20c1f98898 (patch)
tree446f32ced719928420f1d201ae693b63651eb205 /testapps
parentd59147238313ab3a01548e203a6243b337c4071c (diff)
downloadandroid_packages_services_Telecomm-f4f7576fc85dfae9711f10a9d840de20c1f98898.tar.gz
android_packages_services_Telecomm-f4f7576fc85dfae9711f10a9d840de20c1f98898.tar.bz2
android_packages_services_Telecomm-f4f7576fc85dfae9711f10a9d840de20c1f98898.zip
Add support for reporting nuisance calls to CallScreeningService.
Add new API to report nuisance calls from the default dialer. This API will relay the nuisance report on to the current call screening service if it has previously provided call id information for calls. Test: Manual using test app Test: Added CTS coverage Test: Added unit tests Bug: 63966743 Change-Id: I43c05ec9fa20f2df31da07c19090335c4d0154ca
Diffstat (limited to 'testapps')
-rw-r--r--testapps/AndroidManifest.xml7
-rw-r--r--testapps/res/layout/testdialer_main.xml10
-rw-r--r--testapps/src/com/android/server/telecom/testapps/NuisanceReportReceiver.java52
-rw-r--r--testapps/src/com/android/server/telecom/testapps/TestDialerActivity.java21
4 files changed, 90 insertions, 0 deletions
diff --git a/testapps/AndroidManifest.xml b/testapps/AndroidManifest.xml
index b3ecd278..e3393560 100644
--- a/testapps/AndroidManifest.xml
+++ b/testapps/AndroidManifest.xml
@@ -239,6 +239,13 @@
android:process="com.android.server.telecom.testapps.SelfMangingCallingApp"
android:name="com.android.server.telecom.testapps.SelfManagedCallNotificationReceiver" />
+ <receiver android:exported="true"
+ android:name="com.android.server.telecom.testapps.NuisanceReportReceiver">
+ <intent-filter>
+ <action android:name="android.telecom.action.NUISANCE_CALL_STATUS_CHANGED" />
+ </intent-filter>
+ </receiver>
+
<service
android:name=".TestCallScreeningService"
android:permission="android.permission.BIND_SCREENING_SERVICE">
diff --git a/testapps/res/layout/testdialer_main.xml b/testapps/res/layout/testdialer_main.xml
index e6c56b74..9da3789a 100644
--- a/testapps/res/layout/testdialer_main.xml
+++ b/testapps/res/layout/testdialer_main.xml
@@ -30,6 +30,16 @@
android:layout_height="wrap_content"
android:text="@string/placeCallButton" />
<Button
+ android:id="@+id/report_nuisance_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Report Nuisance" />
+ <Button
+ android:id="@+id/report_not_nuisance_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Report Not Nuisance" />
+ <Button
android:id="@+id/set_default_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/testapps/src/com/android/server/telecom/testapps/NuisanceReportReceiver.java b/testapps/src/com/android/server/telecom/testapps/NuisanceReportReceiver.java
new file mode 100644
index 00000000..76fff665
--- /dev/null
+++ b/testapps/src/com/android/server/telecom/testapps/NuisanceReportReceiver.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2019 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.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.telecom.CallScreeningService;
+import android.widget.Toast;
+
+/**
+ * Example receiver for nuisance call reports from Telecom.
+ */
+public class NuisanceReportReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(CallScreeningService.ACTION_NUISANCE_CALL_STATUS_CHANGED)) {
+ Uri handle = intent.getParcelableExtra(CallScreeningService.EXTRA_CALL_HANDLE);
+ boolean isNuisance = intent.getBooleanExtra(CallScreeningService.EXTRA_IS_NUISANCE,
+ false);
+ int durationBucket = intent.getIntExtra(CallScreeningService.EXTRA_CALL_DURATION, 0);
+ int callType = intent.getIntExtra(CallScreeningService.EXTRA_CALL_TYPE, 0);
+ handleNuisanceReport(context, handle, isNuisance, durationBucket, callType);
+ }
+ }
+
+ private void handleNuisanceReport(Context context, Uri handle, boolean isNuisance,
+ int durationBucket, int callType) {
+
+ String message = "Nuisance report for: " + handle + " isNuisance=" + isNuisance
+ + " duration=" + durationBucket + " callType=" + callType;
+ Toast.makeText(context,
+ (CharSequence) message,
+ Toast.LENGTH_LONG)
+ .show();
+ }
+}
diff --git a/testapps/src/com/android/server/telecom/testapps/TestDialerActivity.java b/testapps/src/com/android/server/telecom/testapps/TestDialerActivity.java
index c7eccf72..66a69445 100644
--- a/testapps/src/com/android/server/telecom/testapps/TestDialerActivity.java
+++ b/testapps/src/com/android/server/telecom/testapps/TestDialerActivity.java
@@ -54,6 +54,20 @@ public class TestDialerActivity extends Activity {
}
});
+ findViewById(R.id.report_nuisance_button).setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ reportNuisance(true);
+ }
+ });
+
+ findViewById(R.id.report_not_nuisance_button).setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ reportNuisance(false);
+ }
+ });
+
mNumberView = (EditText) findViewById(R.id.number);
mRttCheckbox = (CheckBox) findViewById(R.id.call_with_rtt_checkbox);
updateMutableUi();
@@ -140,4 +154,11 @@ public class TestDialerActivity extends Activity {
Log.i("Santos xtr", intentExtras.toString());
return intentExtras;
}
+
+ private void reportNuisance(boolean isNuisance) {
+ final TelecomManager telecomManager =
+ (TelecomManager) getSystemService(Context.TELECOM_SERVICE);
+ telecomManager.reportNuisanceCallStatus(Uri.fromParts(PhoneAccount.SCHEME_TEL,
+ mNumberView.getText().toString(), null), isNuisance);
+ }
}