Settings UI for SIM access profile (1/2)
Change-Id: Iff14295ac0eb65561a2097f25c70e8b5f8be5003
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a4066c1..ebef5de 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -367,6 +367,12 @@
<!-- Bluetooth message permission Alert Activity text [CHAR LIMIT=none] -->
<string name="bluetooth_map_acceptance_dialog_text">%1$s wants to access your messages. Give access to %2$s?</string>
+ <!-- Activity label of BluetoothMessagePermissionActivity for SIM access profile. Also used as Strings in the permission dialog [CHAR LIMIT=none] -->
+ <string name="bluetooth_sap_request">"SIM access request"</string>
+
+ <!-- Bluetooth SIM access permission Alert Activity text [CHAR LIMIT=none] -->
+ <string name="bluetooth_sap_acceptance_dialog_text"><xliff:g id="device_name">%1$s</xliff:g> wants to access your SIM card. Granting access to the SIM card will disable data connectivity on your device for the duration of the connection. Give access to <xliff:g id="device_name">%2$s?</xliff:g></string>
+
<!-- Date & time settings screen title -->
<string name="date_and_time">Date & time</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
old mode 100755
new mode 100644
index 7a1e69d..2267555
--- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
@@ -101,6 +101,8 @@
showDialog(getString(R.string.bluetooth_phonebook_request), mRequestType);
} else if (mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
showDialog(getString(R.string.bluetooth_map_request), mRequestType);
+ } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
+ showDialog(getString(R.string.bluetooth_sap_request), mRequestType);
}
else {
Log.e(TAG, "Error: bad request type: " + mRequestType);
@@ -129,6 +131,9 @@
case BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS:
p.mView = createMapDialogView();
break;
+ case BluetoothDevice.REQUEST_TYPE_SIM_ACCESS:
+ p.mView = createSapDialogView();
+ break;
}
p.mPositiveButtonText = getString(R.string.yes);
p.mPositiveButtonListener = this;
@@ -183,6 +188,15 @@
return mView;
}
+ private View createSapDialogView() {
+ String mRemoteName = createRemoteName();
+ mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null);
+ messageView = (TextView)mView.findViewById(R.id.message);
+ messageView.setText(getString(R.string.bluetooth_sap_acceptance_dialog_text,
+ mRemoteName, mRemoteName));
+ return mView;
+ }
+
private void onPositive() {
if (DEBUG) Log.d(TAG, "onPositive");
sendReplyIntentToReceiver(true, true);
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
index b3a9571..372f9a5 100644
--- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
@@ -44,7 +44,7 @@
private static final String NOTIFICATION_TAG_PBAP = "Phonebook Access" ;
private static final String NOTIFICATION_TAG_MAP = "Message Access";
-
+ private static final String NOTIFICATION_TAG_SAP = "SIM Access";
Context mContext;
int mRequestType;
@@ -139,6 +139,11 @@
message = context.getString(R.string.bluetooth_map_acceptance_dialog_text,
deviceName, deviceName);
break;
+ case BluetoothDevice.REQUEST_TYPE_SIM_ACCESS:
+ title = context.getString(R.string.bluetooth_sap_request);
+ message = context.getString(R.string.bluetooth_sap_acceptance_dialog_text,
+ deviceName, deviceName);
+ break;
default:
title = context.getString(R.string.bluetooth_connection_permission_request);
message = context.getString(R.string.bluetooth_connection_dialog_text,
@@ -184,6 +189,8 @@
return NOTIFICATION_TAG_PBAP;
} else if(mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
return NOTIFICATION_TAG_MAP;
+ } else if(mRequestType == BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
+ return NOTIFICATION_TAG_SAP;
}
return null;
}
@@ -198,7 +205,8 @@
// ignore if it is something else than phonebook/message settings it wants us to remember
if (mRequestType != BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS
- && mRequestType != BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
+ && mRequestType != BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS
+ && mRequestType != BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
if (DEBUG) Log.d(TAG, "checkUserChoice(): Unknown RequestType " + mRequestType);
return processed;
}
@@ -242,6 +250,20 @@
} else {
Log.e(TAG, "Bad messagePermission: " + messagePermission);
}
+ } else if(mRequestType == BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
+ int simPermission = cachedDevice.getSimPermissionChoice();
+
+ if (simPermission == CachedBluetoothDevice.ACCESS_UNKNOWN) {
+ // Leave 'processed' as false.
+ } else if (simPermission == CachedBluetoothDevice.ACCESS_ALLOWED) {
+ sendReplyIntentToReceiver(true);
+ processed = true;
+ } else if (simPermission == CachedBluetoothDevice.ACCESS_REJECTED) {
+ sendReplyIntentToReceiver(false);
+ processed = true;
+ } else {
+ Log.e(TAG, "Bad simPermission: " + simPermission);
+ }
}
if (DEBUG) Log.d(TAG,"checkUserChoice(): returning " + processed);
return processed;