Merge "Add BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS for binding to the InCallService"
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..8ee7754
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,77 @@
+// Build the Telecom service.
+android_app {
+ name: "Telecom",
+ libs: ["telephony-common"],
+ srcs: [
+ "src/**/*.java",
+ "proto/**/*.proto",
+ ],
+ resource_dirs: ["res"],
+ proto: {
+ type: "nano",
+ local_include_dirs: ["proto/"],
+ output_params: ["optional_field_style=accessors"],
+ },
+ platform_apis: true,
+ certificate: "platform",
+ privileged: true,
+ optimize: {
+ proguard_flags_files: ["proguard.flags"],
+ },
+ defaults: ["SettingsLibDefaults"],
+}
+
+android_test {
+ name: "TelecomUnitTests",
+ static_libs: [
+ "android-ex-camera2",
+ "guava",
+ "mockito-target-inline",
+ "android-support-test",
+ "platform-test-annotations",
+ "androidx.legacy_legacy-support-core-ui",
+ "androidx.legacy_legacy-support-core-utils",
+ "androidx.core_core",
+ "androidx.fragment_fragment",
+ ],
+ srcs: [
+ "tests/src/**/*.java",
+ "src/**/*.java",
+ "proto/**/*.proto",
+ ],
+ proto: {
+ type: "nano",
+ local_include_dirs: ["proto/"],
+ output_params: ["optional_field_style=accessors"],
+ },
+ resource_dirs: [
+ "tests/res",
+ "res",
+ ],
+ libs: [
+ "android.test.mock",
+ "android.test.base",
+ "android.test.runner",
+ "telephony-common",
+ ],
+
+ jni_libs: ["libdexmakerjvmtiagent"],
+
+ aaptflags: [
+ "--auto-add-overlay",
+ "--extra-packages",
+ "com.android.server.telecom",
+ ],
+ manifest: "tests/AndroidManifest.xml",
+ optimize: {
+ enabled: false,
+ },
+ platform_apis: true,
+ certificate: "platform",
+ jacoco: {
+ include_filter: ["com.android.server.telecom.*"],
+ exclude_filter: ["com.android.server.telecom.tests.*"],
+ },
+ test_suites: ["device-tests"],
+ defaults: ["SettingsLibDefaults"],
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index 4e5eeff..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-# Build the Telecom service.
-include $(CLEAR_VARS)
-
-LOCAL_JAVA_LIBRARIES := telephony-common
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-proto-files-under, proto)
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_USE_AAPT2 := true
-
-LOCAL_PROTOC_OPTIMIZE_TYPE := nano
-LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/proto/
-LOCAL_PROTO_JAVA_OUTPUT_PARAMS := optional_field_style=accessors
-
-LOCAL_PACKAGE_NAME := Telecom
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_CERTIFICATE := platform
-LOCAL_PRIVILEGED_MODULE := true
-
-LOCAL_PROGUARD_FLAG_FILES := proguard.flags
-
-include frameworks/base/packages/SettingsLib/common.mk
-
-include $(BUILD_PACKAGE)
-
-# Build the test package.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/res/xml/add_blocked_number_dialog.xml b/res/xml/add_blocked_number_dialog.xml
index d0942ec..35ab633 100644
--- a/res/xml/add_blocked_number_dialog.xml
+++ b/res/xml/add_blocked_number_dialog.xml
@@ -20,19 +20,22 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:gravity="center"
+ android:gravity="start"
android:padding="@dimen/blocked_numbers_dialog_padding">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/add_blocked_dialog_body"
android:paddingBottom="@dimen/blocked_numbers_large_padding"
+ android:gravity="start"
style="@style/BlockedNumbersTextPrimary2" />
<EditText
android:id="@+id/add_blocked_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/blocked_numbers_large_padding"
+ android:textDirection="locale"
+ android:textAlignment="viewStart"
android:hint="@string/add_blocked_number_hint"
android:inputType="phone" />
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/src/com/android/server/telecom/NewOutgoingCallIntentBroadcaster.java b/src/com/android/server/telecom/NewOutgoingCallIntentBroadcaster.java
index e5cbf77..51ddd8e 100644
--- a/src/com/android/server/telecom/NewOutgoingCallIntentBroadcaster.java
+++ b/src/com/android/server/telecom/NewOutgoingCallIntentBroadcaster.java
@@ -401,7 +401,7 @@
checkAndCopyProviderExtras(originalCallIntent, broadcastIntent);
final BroadcastOptions options = BroadcastOptions.makeBasic();
- options.setAllowBackgroundActivityStarts(true);
+ options.setBackgroundActivityStartsAllowed(true);
mContext.sendOrderedBroadcastAsUser(
broadcastIntent,
targetUser,
diff --git a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
index 4800832..3c334ca 100644
--- a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
+++ b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
@@ -73,12 +73,14 @@
"Lost BluetoothHeadset service. " +
"Removing all tracked devices.");
lostServiceDevices = mHfpDevicesByAddress;
+ mBluetoothRouteManager.onActiveDeviceChanged(null, false);
} else if (profile == BluetoothProfile.HEARING_AID) {
mBluetoothHearingAidService = null;
Log.i(BluetoothDeviceManager.this,
"Lost BluetoothHearingAid service. " +
"Removing all tracked devices.");
lostServiceDevices = mHearingAidDevicesByAddress;
+ mBluetoothRouteManager.onActiveDeviceChanged(null, true);
} else {
return;
}
diff --git a/testapps/Android.bp b/testapps/Android.bp
new file mode 100644
index 0000000..26347fe
--- /dev/null
+++ b/testapps/Android.bp
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2013 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.
+//
+
+android_test {
+ name: "TelecomTestApps",
+ static_libs: [
+ "androidx.legacy_legacy-support-v4",
+ "android-ex-camera2",
+ "guava",
+ ],
+ srcs: ["src/**/*.java"],
+ platform_apis: true,
+ certificate: "platform",
+}
diff --git a/testapps/Android.mk b/testapps/Android.mk
deleted file mode 100644
index 0651a87..0000000
--- a/testapps/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Copyright (C) 2013 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_USE_AAPT2 := true
-LOCAL_STATIC_ANDROID_LIBRARIES := androidx.legacy_legacy-support-v4
-LOCAL_STATIC_JAVA_LIBRARIES := \
- android-ex-camera2 \
- guava
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := TelecomTestApps
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_CERTIFICATE := platform
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_PACKAGE)
diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index 5abf999..0000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,75 +0,0 @@
-#
-# Copyright (C) 2013 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- android-ex-camera2 \
- guava \
- mockito-target-inline \
- android-support-test \
- platform-test-annotations
-
-LOCAL_STATIC_ANDROID_LIBRARIES := \
- androidx.legacy_legacy-support-core-ui \
- androidx.legacy_legacy-support-core-utils \
- androidx.core_core \
- androidx.fragment_fragment
-
-LOCAL_SRC_FILES := \
- $(call all-java-files-under, src) \
- $(call all-java-files-under, ../src) \
- $(call all-proto-files-under, ../proto)
-
-LOCAL_PROTOC_OPTIMIZE_TYPE := nano
-LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/../proto/
-LOCAL_PROTO_JAVA_OUTPUT_PARAMS := optional_field_style=accessors
-
-LOCAL_RESOURCE_DIR := \
- $(LOCAL_PATH)/res \
- $(LOCAL_PATH)/../res
-
-LOCAL_JAVA_LIBRARIES := \
- android.test.mock \
- android.test.base \
- android.test.runner \
- telephony-common
-
-LOCAL_USE_AAPT2 := true
-
-LOCAL_JNI_SHARED_LIBRARIES := \
- libdexmakerjvmtiagent \
-
-LOCAL_AAPT_FLAGS := \
- --auto-add-overlay \
- --extra-packages com.android.server.telecom
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-LOCAL_PACKAGE_NAME := TelecomUnitTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_CERTIFICATE := platform
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.server.telecom.*
-LOCAL_JACK_COVERAGE_EXCLUDE_FILTER := com.android.server.telecom.tests.*
-
-LOCAL_COMPATIBILITY_SUITE := device-tests
-include frameworks/base/packages/SettingsLib/common.mk
-
-include $(BUILD_PACKAGE)
diff --git a/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java b/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java
index 9fd97f8..2129ffa 100644
--- a/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java
@@ -40,6 +40,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.never;
@@ -161,6 +162,7 @@
buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device2, true));
serviceListenerUnderTest.onServiceDisconnected(BluetoothProfile.HEADSET);
+ verify(mRouteManager).onActiveDeviceChanged(isNull(), eq(false));
verify(mRouteManager).onDeviceLost(device1.getAddress());
verify(mRouteManager).onDeviceLost(device3.getAddress());
verify(mRouteManager, never()).onDeviceLost(device2.getAddress());
@@ -170,6 +172,25 @@
@SmallTest
@Test
+ public void testHearingAidServiceDisconnect() {
+ receiverUnderTest.onReceive(mContext,
+ buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device1, false));
+ receiverUnderTest.onReceive(mContext,
+ buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device3, false));
+ receiverUnderTest.onReceive(mContext,
+ buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device2, true));
+ serviceListenerUnderTest.onServiceDisconnected(BluetoothProfile.HEARING_AID);
+
+ verify(mRouteManager).onActiveDeviceChanged(isNull(), eq(true));
+ verify(mRouteManager).onDeviceLost(device2.getAddress());
+ verify(mRouteManager, never()).onDeviceLost(device1.getAddress());
+ verify(mRouteManager, never()).onDeviceLost(device3.getAddress());
+ assertNull(mBluetoothDeviceManager.getHearingAidService());
+ assertEquals(2, mBluetoothDeviceManager.getNumConnectedDevices());
+ }
+
+ @SmallTest
+ @Test
public void testConnectDisconnectAudioHeadset() {
receiverUnderTest.onReceive(mContext,
buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device1, false));