Merge "Stay discoverable in Bluetooth settings and pairing pages" into oc-dr1-dev
diff --git a/res/values-mcc262-mnc02/strings.xml b/res/values-mcc262-mnc02/strings.xml
index 17f9272..280f59e 100644
--- a/res/values-mcc262-mnc02/strings.xml
+++ b/res/values-mcc262-mnc02/strings.xml
@@ -16,4 +16,6 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Wi-Fi Calling settings. Additional text displayed when Wi-Fi Calling is off. Default empty. [CHAR LIMIT=NONE] -->
<string name="wifi_calling_off_explanation_2">\n\nYou can\u2019t make emergency calls through Wi-Fi calling. If you try to make an emergency call, your device will automatically use the mobile network. Emergency calls can only be made in areas with mobile network coverage.</string>
+ <!-- Do not translate. Wireless networks, item title to go into the WFC settings [CHAR LIMIT=30] -->
+ <string name="wifi_calling_settings_title">"Wi-Fi calling"</string>
</resources>
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index 96ce17e..2c97018 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -144,10 +144,10 @@
public void onClick(View view) {
final Context context = view.getContext();
if (Utils.isDemoUser(context)) {
- final String packageName = Utils.getDemoModePackageName(context);
- if (!TextUtils.isEmpty(packageName)) {
+ final ComponentName componentName = Utils.getDeviceOwnerComponent(context);
+ if (componentName != null) {
final Intent requestFactoryReset = new Intent()
- .setPackage(packageName)
+ .setPackage(componentName.getPackageName())
.setAction(Intent.ACTION_FACTORY_RESET);
context.startActivity(requestFactoryReset);
}
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index eecc8c2..5371ca4 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -1280,8 +1280,10 @@
return UserManager.isDeviceInDemoMode(context) && getUserManager(context).isDemoUser();
}
- public static String getDemoModePackageName(Context context) {
- return context.getString(com.android.internal.R.string.config_demoModePackage);
+ public static ComponentName getDeviceOwnerComponent(Context context) {
+ final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
+ Context.DEVICE_POLICY_SERVICE);
+ return dpm.getDeviceOwnerComponentOnAnyUser();
}
/**
diff --git a/tests/robotests/src/com/android/settings/MasterClearTest.java b/tests/robotests/src/com/android/settings/MasterClearTest.java
index b501654..21b8e47 100644
--- a/tests/robotests/src/com/android/settings/MasterClearTest.java
+++ b/tests/robotests/src/com/android/settings/MasterClearTest.java
@@ -26,6 +26,7 @@
import android.app.Activity;
import android.app.Fragment;
+import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Intent;
import android.os.Bundle;
@@ -37,7 +38,6 @@
import android.widget.ScrollView;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowUtils;
import org.junit.Before;
@@ -144,19 +144,19 @@
}
@Test
- @Config(shadows = { ShadowUtils.class, SettingsShadowResources.class })
+ @Config(shadows = { ShadowUtils.class })
public void testInitiateMasterClear_inDemoMode_sendsIntent() {
- SettingsShadowResources.overrideResource(
- com.android.internal.R.string.config_demoModePackage, "package");
-
ShadowUtils.setIsDemoUser(true);
+ final ComponentName componentName = ComponentName.unflattenFromString(
+ "com.android.retaildemo/.DeviceAdminReceiver");
+ ShadowUtils.setDeviceOwnerComponent(componentName);
+
mMasterClear.mInitiateListener.onClick(
mContentView.findViewById(R.id.initiate_master_clear));
final Intent intent = mShadowActivity.getNextStartedActivity();
assertThat(Intent.ACTION_FACTORY_RESET).isEqualTo(intent.getAction());
- final String packageName = Utils.getDemoModePackageName(RuntimeEnvironment.application);
- assertThat(packageName).isEqualTo(intent.getPackage());
+ assertThat(componentName.getPackageName()).isEqualTo(intent.getPackage());
}
private void initScrollView(int height, int scrollY, int childBottom) {
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
index 9b1e26e..8d0df17 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
@@ -30,6 +30,7 @@
private static IFingerprintManager sFingerprintManager = null;
private static boolean sIsDemoUser;
+ private static ComponentName sDeviceOwnerComponentName;
@Implementation
public static int enforceSameOwner(Context context, int userId) {
@@ -63,4 +64,13 @@
public static boolean isDemoUser(Context context) {
return sIsDemoUser;
}
+
+ public static void setDeviceOwnerComponent(ComponentName componentName) {
+ sDeviceOwnerComponentName = componentName;
+ }
+
+ @Implementation
+ public static ComponentName getDeviceOwnerComponent(Context context) {
+ return sDeviceOwnerComponentName;
+ }
}