Add Telecom debug menu.
New menu is accessible via *#*#828282#*#*. This is a developer settings
type activity for the Telecom subsystem.
Adding in an option to enable the enhanced call blocking functionality
to facilitate testing.
Test: Manual
Bug: 28189985
Change-Id: If7ce957e3e04f8f3de2251bb70dafb6b5834a6d8
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 588e5c3..9202e74 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -288,6 +288,10 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
+ <activity android:name=".ui.TelecomDeveloperMenu"
+ android:label="@string/developer_title"
+ android:exported="false"
+ android:process=":ui" />
<receiver android:name=".components.PrimaryCallReceiver"
android:exported="true"
diff --git a/res/layout/telecom_developer_menu.xml b/res/layout/telecom_developer_menu.xml
new file mode 100644
index 0000000..0df0cdd
--- /dev/null
+++ b/res/layout/telecom_developer_menu.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <Switch
+ android:id="@+id/switchEnhancedCallBlocking"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/developer_enhanced_call_blocking"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index bb63ad2..8c29a21 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -285,4 +285,10 @@
<string name="phone_strings_emergency_call_made_dialog_title_txt">Emergency call made</string>
<!-- Notification details that appear when the user taps the notification "phone_strings_call_blocking_turned_off_notification_text_txt". -->
<string name="phone_strings_emergency_call_made_dialog_call_blocking_text_txt">Call Blocking has been disabled to allow emergency responders to contact you.</string>
+ <!-- Window title used for the Telecom Developer Menu -->
+ <string name="developer_title">Telecom Developer Menu</string>
+ <!-- Label for a switch in the Telecom Developer Menu which is used to enable the enhanced call
+ blocking functionality (for test purposes).
+ DO NOT TRANSLATE -->
+ <string name="developer_enhanced_call_blocking" translatable="false">Enhanced Call Blocking</string>
</resources>
diff --git a/src/com/android/server/telecom/DialerCodeReceiver.java b/src/com/android/server/telecom/DialerCodeReceiver.java
index 57f84a0..1cd922a 100644
--- a/src/com/android/server/telecom/DialerCodeReceiver.java
+++ b/src/com/android/server/telecom/DialerCodeReceiver.java
@@ -19,9 +19,12 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.os.UserHandle;
import android.telecom.Log;
import android.telecom.TelecomManager;
+import com.android.server.telecom.ui.TelecomDeveloperMenu;
+
/**
* Receiver for "secret codes" broadcast by Dialer.
*/
@@ -38,6 +41,9 @@
// Writes a MARK to the Telecom log.
public static final String TELECOM_SECRET_CODE_MARK = "826275";
+ // Opens the Telecom developer menu.
+ public static final String TELECOM_SECRET_CODE_MENU = "828282";
+
private final CallsManager mCallsManager;
DialerCodeReceiver(CallsManager callsManager) {
@@ -61,6 +67,11 @@
// add a non-call event.
Call currentCall = mCallsManager.getActiveCall();
Log.addEvent(currentCall, LogUtils.Events.USER_LOG_MARK);
+ } else if (intent.getData().getHost().equals(TELECOM_SECRET_CODE_MENU)) {
+ Log.i("DialerCodeReceiver", "Secret code used to open developer menu.");
+ Intent confirmIntent = new Intent(context, TelecomDeveloperMenu.class);
+ confirmIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivityAsUser(confirmIntent, UserHandle.CURRENT);
}
}
}
diff --git a/src/com/android/server/telecom/SystemSettingsUtil.java b/src/com/android/server/telecom/SystemSettingsUtil.java
index 3c75e4d..97659a8 100644
--- a/src/com/android/server/telecom/SystemSettingsUtil.java
+++ b/src/com/android/server/telecom/SystemSettingsUtil.java
@@ -36,4 +36,14 @@
return Settings.System.getInt(context.getContentResolver(),
Settings.System.VIBRATE_WHEN_RINGING, 0) != 0;
}
+
+ public boolean isEnhancedCallBlockingEnabled(Context context) {
+ return Settings.System.getInt(context.getContentResolver(),
+ Settings.System.DEBUG_ENABLE_ENHANCED_CALL_BLOCKING, 0) != 0;
+ }
+
+ public boolean setEnhancedCallBlockingEnabled(Context context, boolean enabled) {
+ return Settings.System.putInt(context.getContentResolver(),
+ Settings.System.DEBUG_ENABLE_ENHANCED_CALL_BLOCKING, enabled ? 1 : 0);
+ }
}
diff --git a/src/com/android/server/telecom/TelecomSystem.java b/src/com/android/server/telecom/TelecomSystem.java
index 3fd0e21..9ecdde2 100644
--- a/src/com/android/server/telecom/TelecomSystem.java
+++ b/src/com/android/server/telecom/TelecomSystem.java
@@ -96,6 +96,8 @@
.addDataAuthority(DialerCodeReceiver.TELECOM_SECRET_CODE_DEBUG_OFF, null);
DIALER_SECRET_CODE_FILTER
.addDataAuthority(DialerCodeReceiver.TELECOM_SECRET_CODE_MARK, null);
+ DIALER_SECRET_CODE_FILTER
+ .addDataAuthority(DialerCodeReceiver.TELECOM_SECRET_CODE_MENU, null);
}
private static TelecomSystem INSTANCE = null;
diff --git a/src/com/android/server/telecom/settings/BlockedNumbersUtil.java b/src/com/android/server/telecom/settings/BlockedNumbersUtil.java
index 4f45720..5acfe64 100644
--- a/src/com/android/server/telecom/settings/BlockedNumbersUtil.java
+++ b/src/com/android/server/telecom/settings/BlockedNumbersUtil.java
@@ -33,6 +33,7 @@
import android.widget.Toast;
import com.android.server.telecom.R;
+import com.android.server.telecom.SystemSettingsUtil;
import com.android.server.telecom.ui.NotificationChannelManager;
import java.util.Locale;
@@ -134,7 +135,8 @@
carrierConfig = configManager.getDefaultConfig();
}
return carrierConfig.getBoolean(
- CarrierConfigManager.KEY_SUPPORT_ENHANCED_CALL_BLOCKING_BOOL);
+ CarrierConfigManager.KEY_SUPPORT_ENHANCED_CALL_BLOCKING_BOOL)
+ || new SystemSettingsUtil().isEnhancedCallBlockingEnabled(context);
}
/**
diff --git a/src/com/android/server/telecom/ui/TelecomDeveloperMenu.java b/src/com/android/server/telecom/ui/TelecomDeveloperMenu.java
new file mode 100644
index 0000000..ae2e853
--- /dev/null
+++ b/src/com/android/server/telecom/ui/TelecomDeveloperMenu.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.ui;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.widget.Switch;
+
+import com.android.server.telecom.R;
+import com.android.server.telecom.SystemSettingsUtil;
+
+/**
+ * Telecom Developer Settings Menu.
+ */
+public class TelecomDeveloperMenu extends Activity {
+
+ private Switch mEnhancedCallingSwitch;
+ private SystemSettingsUtil mSystemSettingsUtil;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mSystemSettingsUtil = new SystemSettingsUtil();
+ setContentView(R.layout.telecom_developer_menu);
+
+ mEnhancedCallingSwitch = findViewById(R.id.switchEnhancedCallBlocking);
+ mEnhancedCallingSwitch.setOnClickListener(l -> {
+ handleEnhancedCallingToggle();
+ });
+ loadPreferences();
+ }
+
+ private void handleEnhancedCallingToggle() {
+ mSystemSettingsUtil.setEnhancedCallBlockingEnabled(this,
+ mEnhancedCallingSwitch.isChecked());
+ }
+
+ private void loadPreferences() {
+ mEnhancedCallingSwitch.setChecked(mSystemSettingsUtil.isEnhancedCallBlockingEnabled(this));
+ }
+}
\ No newline at end of file