Skip to content

Commit 5f83cb6

Browse files
author
arangelov
committed
Add option to use RESET_PASSWORD_REQUIRE_ENTRY flag when resetting
password in TestDPC. Test: None Change-Id: I266e2eff772eb13e590cef2887d7d6828d8227ed
1 parent bad5f53 commit 5f83cb6

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

app/src/main/java/com/afwsamples/testdpc/policy/resetpassword/ResetPasswordWithTokenFragment.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public class ResetPasswordWithTokenFragment extends Fragment implements View.OnC
6464
private Button mBtnSetPassword;
6565
private CheckBox mChkRequireEntry;
6666
private CheckBox mChkDoNotRequirePasswordOnBoot;
67+
private CheckBox mChkDoNotAllowOtherAdminsChange;
6768
private Button mBtnActivateToken;
6869
private KeyguardManager mKeyguardMgr;
6970

@@ -135,6 +136,8 @@ public View onCreateView(LayoutInflater layoutInflater, ViewGroup container,
135136
mChkRequireEntry = (CheckBox) view.findViewById(R.id.require_password_entry_checkbox);
136137
mChkDoNotRequirePasswordOnBoot = (CheckBox) view.findViewById(
137138
R.id.dont_require_password_on_boot_checkbox);
139+
mChkDoNotAllowOtherAdminsChange =
140+
(CheckBox) view.findViewById(R.id.dont_allow_other_admins_change_password);
138141

139142
mBtnNewToken = (Button) view.findViewById(R.id.btnNewToken);
140143
mBtnRemoveToken = (Button) view.findViewById(R.id.btnRemoveToken);
@@ -227,6 +230,8 @@ private void resetPasswordWithToken() {
227230
DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY : 0;
228231
flags |= mChkDoNotRequirePasswordOnBoot.isChecked() ?
229232
DevicePolicyManager.RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT : 0;
233+
flags |= mChkDoNotAllowOtherAdminsChange.isChecked() ?
234+
DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY : 0;
230235

231236
if (token != null) {
232237
boolean result = mDpm.resetPasswordWithToken(

app/src/main/java/com/afwsamples/testdpc/transferownership/PickTransferComponentFragment.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ private String performTransfer(ComponentName target) {
105105
Log.i(getClass().getName(), "Transferring ownership from " + source
106106
+ " to target " + target);
107107
try {
108+
PersistableBundle persistableBundle = new PersistableBundle();
109+
persistableBundle.putString("random_key", "random_value");
108110
com.afwsamples.testdpc.common.ReflectionUtil.invoke(mDevicePolicyManager,
109-
"transferOwnership", source, target, new PersistableBundle());
111+
"transferOwnership", source, target, persistableBundle);
110112
return "Success!";
111113
} catch (ReflectionUtil.ReflectionIsTemporaryException e) {
112114
Throwable cause = e.getCause();

app/src/main/res/layout/reset_password_token.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ limitations under the License.
8888
android:layout_height="wrap_content"
8989
android:layout_below="@+id/edtTokenStatus"
9090
android:layout_alignStart="@+id/textView"
91-
android:layout_marginTop="92dp"
91+
android:layout_marginTop="30dp"
9292
android:id="@+id/textView3" />
9393

9494
<EditText
@@ -151,11 +151,19 @@ limitations under the License.
151151
android:layout_below="@+id/require_password_entry_checkbox"
152152
android:layout_alignStart="@+id/btnSetPassword" />
153153

154+
<CheckBox
155+
android:layout_below="@+id/dont_require_password_on_boot_checkbox"
156+
android:text="@string/do_not_allow_other_admins_change_password"
157+
android:layout_width="wrap_content"
158+
android:layout_height="wrap_content"
159+
android:id="@+id/dont_allow_other_admins_change_password"
160+
android:layout_alignStart="@+id/btnSetPassword" />
161+
154162
<Button
155163
android:text="@string/reset_password_fragment_set_password"
156164
android:layout_width="wrap_content"
157165
android:layout_height="wrap_content"
158166
android:id="@+id/btnSetPassword"
159-
android:layout_below="@+id/dont_require_password_on_boot_checkbox"
167+
android:layout_below="@+id/dont_allow_other_admins_change_password"
160168
android:layout_alignEnd="@+id/btnNewToken" />
161169
</RelativeLayout>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@
819819
<string name="dont_require_password_on_boot">Do not require password to start user in future</string>
820820
<string name="password_reset_success">Password has been reset</string>
821821
<string name="password_reset_failed">Failed to reset password</string>
822+
<string name="do_not_allow_other_admins_change_password">Do not allow other admins to change the password again until the user has entered it.</string>
822823

823824
<!-- Strings for trust agent -->
824825
<string name="saved_trust_agent_config">Saved trust agent configuration</string>

0 commit comments

Comments
 (0)