diff --git a/res/values/strings.xml b/res/values/strings.xml
index cae71531265..03a8e9eb21c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -263,39 +263,55 @@
Choose Bluetooth device
-
- "Bluetooth permission request"
+
+ %1$s wants to turn on Bluetooth
+
+ %1$s wants to turn off Bluetooth
- An app wants to turn Bluetooth ON for this device.
-
+ An app wants to turn on Bluetooth
- An app wants to turn Bluetooth OFF for this device.
+ An app wants to turn off Bluetooth
-
- An app wants to make your tablet visible to other Bluetooth devices for %1$d seconds.
-
- An app wants to make your phone visible to other Bluetooth devices for %1$d seconds.
+
+ %1$s wants to make your tablet visible to other Bluetooth devices for %2$d seconds.
+
+ %1$s wants to make your phone visible to other Bluetooth devices for %2$d seconds.
-
- An app wants to make your tablet visible to other Bluetooth devices. You can change this later in Bluetooth settings.
- An app wants to make your phone visible to other Bluetooth devices. You can change this later in Bluetooth settings.
+
+ An app wants to make your tablet visible to other Bluetooth devices for %1$d seconds.
+
+ An app wants to make your phone visible to other Bluetooth devices for %1$d seconds.
-
- %1$s wants to turn on Bluetooth broadcasting to communicate with other devices nearby. You can change this later in Bluetooth settings.
-
- %1$s wants to turn on Bluetooth and Bluetooth broadcasting to communicate with other devices nearby. You can change this later in Bluetooth settings.
-
- When this feature is turned on, your phone can communicate with other devices nearby.\n\nBroadcasting uses low-power Bluetooth signals.
+
+ %1$s wants to make your tablet visible to other Bluetooth devices. You can change this later in Bluetooth settings.
+
+ %1$s wants to make your phone visible to other Bluetooth devices. You can change this later in Bluetooth settings.
-
- An app wants to turn on Bluetooth and make your tablet visible to other devices for %1$d seconds.
-
- An app wants to turn on Bluetooth and make your phone visible to other devices for %1$d seconds.
+
+ An app wants to make your tablet visible to other Bluetooth devices. You can change this later in Bluetooth settings.
+
+ An app wants to make your phone visible to other Bluetooth devices. You can change this later in Bluetooth settings.
-
- An app wants to turn on Bluetooth and make your tablet visible to other devices. You can change this later in Bluetooth settings.
- An app wants to turn on Bluetooth and make your phone visible to other devices. You can change this later in Bluetooth settings.
+
+ %1$s wants to turn on Bluetooth and make your tablet visible to other devices for %2$d seconds.
+
+ %1$s wants to turn on Bluetooth and make your phone visible to other devices for %2$d seconds.
+
+
+ An app wants to turn on Bluetooth and make your tablet visible to other devices for %1$d seconds.
+
+ An app wants to turn on Bluetooth and make your phone visible to other devices for %1$d seconds.
+
+
+ %1$s wants to turn on Bluetooth and make your tablet visible to other devices. You can change this later in Bluetooth settings.
+
+ %1$s wants to turn on Bluetooth and make your phone visible to other devices. You can change this later in Bluetooth settings.
+
+
+ An app wants to turn on Bluetooth and make your tablet visible to other devices. You can change this later in Bluetooth settings.
+
+ An app wants to turn on Bluetooth and make your phone visible to other devices. You can change this later in Bluetooth settings.
"Turning Bluetooth on\u2026"
@@ -1492,9 +1508,9 @@
%1$d Mbps
- %s wants to turn WiFi ON for this device.
+ %s wants to turn on Wi-Fi
- %s wants to turn WiFi OFF for this device.
+ %s wants to turn off Wi-Fi
diff --git a/src/com/android/settings/bluetooth/RequestPermissionActivity.java b/src/com/android/settings/bluetooth/RequestPermissionActivity.java
index 9cfcc6b689d..ac6fc5de7d5 100644
--- a/src/com/android/settings/bluetooth/RequestPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/RequestPermissionActivity.java
@@ -16,7 +16,9 @@
package com.android.settings.bluetooth;
+import android.annotation.NonNull;
import android.app.Activity;
+import android.app.ActivityManagerNative;
import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
@@ -25,7 +27,10 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
import android.os.Bundle;
+import android.text.TextUtils;
import android.util.Log;
import com.android.settings.R;
@@ -62,6 +67,8 @@ public class RequestPermissionActivity extends Activity implements
private BroadcastReceiver mReceiver;
+ private @NonNull CharSequence mAppLabel;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -86,8 +93,10 @@ public class RequestPermissionActivity extends Activity implements
case BluetoothAdapter.STATE_ON:
case BluetoothAdapter.STATE_TURNING_ON: {
Intent intent = new Intent(this, RequestPermissionHelperActivity.class);
+ intent.putExtra(RequestPermissionHelperActivity.EXTRA_APP_LABEL, mAppLabel);
intent.setAction(RequestPermissionHelperActivity
.ACTION_INTERNAL_REQUEST_BT_OFF);
+
startActivityForResult(intent, 0);
} break;
@@ -116,6 +125,7 @@ public class RequestPermissionActivity extends Activity implements
*/
Intent intent = new Intent(this, RequestPermissionHelperActivity.class);
intent.setAction(RequestPermissionHelperActivity.ACTION_INTERNAL_REQUEST_BT_ON);
+ intent.putExtra(RequestPermissionHelperActivity.EXTRA_APP_LABEL, mAppLabel);
if (mRequest == REQUEST_ENABLE_DISCOVERABLE) {
intent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, mTimeout);
}
@@ -165,9 +175,15 @@ public class RequestPermissionActivity extends Activity implements
// Ask the user whether to turn on discovery mode or not
// For lasting discoverable mode there is a different message
if (mTimeout == BluetoothDiscoverableEnabler.DISCOVERABLE_TIMEOUT_NEVER) {
- builder.setMessage(getString(R.string.bluetooth_ask_lasting_discovery));
+ CharSequence message = mAppLabel != null
+ ? getString(R.string.bluetooth_ask_lasting_discovery, mAppLabel)
+ : getString(R.string.bluetooth_ask_lasting_discovery_no_name);
+ builder.setMessage(message);
} else {
- builder.setMessage(getString(R.string.bluetooth_ask_discovery, mTimeout));
+ CharSequence message = mAppLabel != null
+ ? getString(R.string.bluetooth_ask_discovery, mAppLabel)
+ : getString(R.string.bluetooth_ask_discovery_no_name);
+ builder.setMessage(message);
}
builder.setPositiveButton(getString(R.string.allow), this);
builder.setNegativeButton(getString(R.string.deny), this);
@@ -303,6 +319,23 @@ public class RequestPermissionActivity extends Activity implements
setResult(RESULT_CANCELED);
return true;
}
+
+ String packageName = getCallingPackage();
+ if (TextUtils.isEmpty(packageName)) {
+ packageName = getIntent().getStringExtra(Intent.EXTRA_PACKAGE_NAME);
+ }
+ if (!TextUtils.isEmpty(packageName)) {
+ try {
+ ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo(
+ packageName, 0);
+ mAppLabel = applicationInfo.loadSafeLabel(getPackageManager());
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "Couldn't find app with package name " + packageName);
+ setResult(RESULT_CANCELED);
+ return true;
+ }
+ }
+
mLocalAdapter = manager.getBluetoothAdapter();
return false;
diff --git a/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java b/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java
index d70a63f9c50..bc33cce03f2 100644
--- a/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java
+++ b/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java
@@ -20,12 +20,17 @@ import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.text.TextUtils;
import android.util.Log;
import com.android.internal.app.AlertActivity;
import com.android.internal.app.AlertController;
import com.android.internal.util.ArrayUtils;
+import com.android.internal.util.CharSequences;
import com.android.settings.R;
import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -45,8 +50,13 @@ public class RequestPermissionHelperActivity extends AlertActivity implements
public static final String ACTION_INTERNAL_REQUEST_BT_OFF =
"com.android.settings.bluetooth.ACTION_INTERNAL_REQUEST_BT_OFF";
+ public static final String EXTRA_APP_LABEL =
+ "com.android.settings.bluetooth.extra.APP_LABEL";
+
private LocalBluetoothAdapter mLocalAdapter;
+ private CharSequence mAppLabel;
+
private int mTimeout = -1;
private int mRequest;
@@ -78,18 +88,29 @@ public class RequestPermissionHelperActivity extends AlertActivity implements
switch (mRequest) {
case RequestPermissionActivity.REQUEST_ENABLE: {
if (mTimeout < 0) {
- p.mMessage = getString(R.string.bluetooth_ask_enablement);
+ p.mMessage = mAppLabel != null
+ ? getString(R.string.bluetooth_ask_enablement, mAppLabel)
+ : getString(R.string.bluetooth_ask_enablement_no_name);
} else if (mTimeout == BluetoothDiscoverableEnabler.DISCOVERABLE_TIMEOUT_NEVER) {
- p.mMessage = getString(
- R.string.bluetooth_ask_enablement_and_lasting_discovery);
+ p.mMessage = mAppLabel != null
+ ? getString(
+ R.string.bluetooth_ask_enablement_and_lasting_discovery,
+ mAppLabel)
+ : getString(
+ R.string.bluetooth_ask_enablement_and_lasting_discovery_no_name);
} else {
- p.mMessage = getString(
- R.string.bluetooth_ask_enablement_and_discovery, mTimeout);
+ p.mMessage = mAppLabel != null
+ ? getString(R.string.bluetooth_ask_enablement_and_discovery,
+ mAppLabel, mTimeout)
+ : getString(R.string.bluetooth_ask_enablement_and_discovery_no_name,
+ mTimeout);
}
} break;
case RequestPermissionActivity.REQUEST_DISABLE: {
- p.mMessage = getString(R.string.bluetooth_ask_disablement);
+ p.mMessage = mAppLabel != null
+ ? getString(R.string.bluetooth_ask_disablement, mAppLabel)
+ : getString(R.string.bluetooth_ask_disablement_no_name);
} break;
}
@@ -145,6 +166,8 @@ public class RequestPermissionHelperActivity extends AlertActivity implements
return false;
}
+ mAppLabel = getIntent().getCharSequenceExtra(EXTRA_APP_LABEL);
+
mLocalAdapter = manager.getBluetoothAdapter();
return true;