Let package of encryption be set by resolving information am: 78bba113cb am: 62bb93ca6c am: a311e5ae51 am: aa6e309c0f
am: 3e8ba20911
Change-Id: Iade86eea81a8e82bafc83d6c9dd8a1474d909992
diff --git a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
index f00592f..63b2f21 100644
--- a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
+++ b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
@@ -43,6 +43,9 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+// for another encryption ui setting package
+import android.content.pm.ResolveInfo;
+
public class EncryptionAppTest extends InstrumentationTestCase {
private static final String TAG = "EncryptionAppTest";
@@ -62,6 +65,9 @@
private UiDevice mDevice;
private AwareActivity mActivity;
+ // for another encryption ui setting package
+ private String mEncryptionSettingPackage = "com.android.settings";
+
@Override
public void setUp() throws Exception {
super.setUp();
@@ -70,6 +76,13 @@
mDe = mCe.createDeviceProtectedStorageContext();
mPm = mCe.getPackageManager();
+ final Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
+ intent.addCategory(Intent.CATEGORY_DEFAULT);
+ ResolveInfo rInfo = mPm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
+ if (rInfo != null) {
+ mEncryptionSettingPackage = rInfo.activityInfo.packageName;
+ }
+
mDevice = UiDevice.getInstance(getInstrumentation());
assertNotNull(mDevice);
}
@@ -102,14 +115,22 @@
// Pick PIN from the option list
UiObject view = new UiObject(new UiSelector()
- .resourceId("com.android.settings:id/lock_pin"));
+ .resourceId(mEncryptionSettingPackage + ":id/lock_pin"));
assertTrue("lock_pin", view.waitForExists(TIMEOUT));
view.click();
mDevice.waitForIdle();
// Ignore any interstitial options
view = new UiObject(new UiSelector()
- .resourceId("com.android.settings:id/encrypt_dont_require_password"));
+ .resourceId(mEncryptionSettingPackage + ":id/encrypt_dont_require_password"));
+ if (view.waitForExists(TIMEOUT)) {
+ view.click();
+ mDevice.waitForIdle();
+ }
+
+ // Yes, we really want to
+ view = new UiObject(new UiSelector()
+ .resourceId(mEncryptionSettingPackage + ":id/next_button"));
if (view.waitForExists(TIMEOUT)) {
view.click();
mDevice.waitForIdle();
@@ -117,7 +138,7 @@
// Set our PIN
view = new UiObject(new UiSelector()
- .resourceId("com.android.settings:id/password_entry"));
+ .resourceId(mEncryptionSettingPackage + ":id/password_entry"));
assertTrue("password_entry", view.waitForExists(TIMEOUT));
// Enter it twice to confirm
@@ -143,7 +164,7 @@
// Enter current PIN
UiObject view = new UiObject(new UiSelector()
- .resourceId("com.android.settings:id/password_entry"));
+ .resourceId(mEncryptionSettingPackage + ":id/password_entry"));
if (!view.waitForExists(TIMEOUT)) {
// Odd, maybe there is a crash dialog showing; try dismissing it
mDevice.pressBack();
@@ -156,7 +177,7 @@
// Set back to "none"
view = new UiObject(new UiSelector()
- .resourceId("com.android.settings:id/lock_none"));
+ .resourceId(mEncryptionSettingPackage + ":id/lock_none"));
assertTrue("lock_none", view.waitForExists(TIMEOUT));
view.click();
mDevice.waitForIdle();