Bluetooth MAP (Message Access Profile) Upstream Changes (2/3)
PORTED FROM CM10: http://review.cyanogenmod.org/#/c/26393/
Incorporates updates to the Bluetooth MAP profile from Code Aurora's
Android Enablement Project since we initially pulled in from their
gingerbread to CM7 last year. This patch addresses bugs with the
current MAP profile, adds a UI request for message access approval
when pairing, and adds additional error checking and logging.
Confirmed to fix date and "Download" function of Ford SYNC Gen1.
Pulled in from the codeaurora jb branch.
Change-Id: Ie35067f389ced8e86433a991776b4a8e1f1ce963
diff --git a/res/layout/bluetooth_mas_access.xml b/res/layout/bluetooth_mas_access.xml
new file mode 100644
index 0000000..dc7c2d5
--- /dev/null
+++ b/res/layout/bluetooth_mas_access.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2009, The Android Open Source Project
+** Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+**
+** 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.
+*/
+-->
+
+<ScrollView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent">
+
+ <LinearLayout
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/message"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dip"
+ android:layout_marginRight="20dip"
+ android:gravity="center_horizontal"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <CheckBox android:id="@+id/bluetooth_mas_remember_choice"
+ style="?android:attr/textAppearanceMedium"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="2dip"
+ android:text="@string/bluetooth_mas_remember_choice" />
+
+ </LinearLayout>
+
+</ScrollView>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4fcc239..7986e67 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -354,6 +354,15 @@
<!-- Bluetooth phone book permission Alert Activity checkbox text [CHAR LIMIT=none] -->
<string name="bluetooth_pb_remember_choice">Don\'t ask again</string>
+ <!-- Activity label of BluetoothMasPermissionActivity, also used as Strings in the permission dialog [CHAR LIMIT=none] -->
+ <string name="bluetooth_mas_request">"Message Access request"</string>
+
+ <!-- Bluetooth MAS permission Alert Activity text [CHAR LIMIT=none] -->
+ <string name="bluetooth_mas_acceptance_dialog_text">%1$s would like to access your messages. Give access to %2$s?</string>
+
+ <!-- Bluetooth MAS permission Alert Activity checkbox text [CHAR LIMIT=none] -->
+ <string name="bluetooth_mas_remember_choice">Don\'t ask again</string>
+
<!-- Date & time settings screen title -->
<string name="date_and_time">Date & time settings</string>
<!-- The title of the activity to pick a time zone. -->
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
index 16476fa..363d694 100755
--- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
@@ -98,6 +98,8 @@
showConnectionDialog();
} else if (requestType == BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) {
showPhonebookDialog();
+ } else if (requestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
+ showMasDialog();
} else {
Log.e(TAG, "Error: bad request type: " + requestType);
finish();
@@ -134,6 +136,19 @@
setupAlert();
}
+ private void showMasDialog() {
+ final AlertController.AlertParams p = mAlertParams;
+ p.mIconId = android.R.drawable.ic_dialog_info;
+ p.mTitle = getString(R.string.bluetooth_mas_request);
+ p.mView = createMasDialogView();
+ p.mPositiveButtonText = getString(android.R.string.yes);
+ p.mPositiveButtonListener = this;
+ p.mNegativeButtonText = getString(android.R.string.no);
+ p.mNegativeButtonListener = this;
+ mOkButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
+ setupAlert();
+ }
+
private String createConnectionDisplayText() {
String mRemoteName = mDevice != null ? mDevice.getAliasName() : null;
@@ -152,6 +167,15 @@
return mMessage1;
}
+ private String createMasDisplayText() {
+ String mRemoteName = mDevice != null ? mDevice.getAliasName() : null;
+
+ if (mRemoteName == null) mRemoteName = getString(R.string.unknown);
+ String mMessage1 = getString(R.string.bluetooth_mas_acceptance_dialog_text,
+ mRemoteName, mRemoteName);
+ return mMessage1;
+ }
+
private View createConnectionDialogView() {
mView = getLayoutInflater().inflate(R.layout.bluetooth_connection_access, null);
messageView = (TextView)mView.findViewById(R.id.message);
@@ -177,6 +201,24 @@
return mView;
}
+ private View createMasDialogView() {
+ mView = getLayoutInflater().inflate(R.layout.bluetooth_mas_access, null);
+ messageView = (TextView)mView.findViewById(R.id.message);
+ messageView.setText(createMasDisplayText());
+ mRememberChoice = (CheckBox)mView.findViewById(R.id.bluetooth_mas_remember_choice);
+ mRememberChoice.setChecked(false);
+ mRememberChoice.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (isChecked) {
+ mRememberChoiceValue = true;
+ } else {
+ mRememberChoiceValue = false;
+ }
+ }
+ });
+ return mView;
+ }
+
private void onPositive() {
if (DEBUG) Log.d(TAG, "onPositive mRememberChoiceValue: " + mRememberChoiceValue);