From faadcd60e7ab8fa6eb9b5be7be907129bd3f8575 Mon Sep 17 00:00:00 2001 From: Casper Bonde Date: Mon, 4 May 2015 22:04:29 -0700 Subject: [PATCH] Settings UI for SIM access profile (1/2) Change-Id: Iff14295ac0eb65561a2097f25c70e8b5f8be5003 --- res/values/strings.xml | 6 +++++ .../bluetooth/BluetoothPermissionActivity.java | 14 ++++++++++++ .../bluetooth/BluetoothPermissionRequest.java | 26 ++++++++++++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-) mode change 100755 => 100644 src/com/android/settings/bluetooth/BluetoothPermissionActivity.java diff --git a/res/values/strings.xml b/res/values/strings.xml index a4066c1ece..ebef5dec62 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -367,6 +367,12 @@ %1$s wants to access your messages. Give access to %2$s? + + "SIM access request" + + + %1$s 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 %2$s? + Date & time 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 7a1e69d74b..22675556c2 --- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java +++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java @@ -101,6 +101,8 @@ public class BluetoothPermissionActivity extends AlertActivity implements 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 @@ public class BluetoothPermissionActivity extends AlertActivity implements 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 @@ public class BluetoothPermissionActivity extends AlertActivity implements 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 b3a9571978..372f9a5da1 100644 --- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java +++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java @@ -44,7 +44,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { 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 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { 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 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { 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 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { // 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 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { } 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; -- 2.11.0