Fix 2527411: Extend sample DPM app to test setMaximumTimeToLock()
Change-Id: I1a0ff93a27d7d27b66acbacf953eb0984e85e4cf
This commit is contained in:
@@ -116,5 +116,25 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout android:orientation="horizontal" android:gravity="center"
|
||||||
|
android:layout_width="match_parent" android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<EditText android:id="@+id/timeout"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:hint="@string/timeout_hint"
|
||||||
|
android:inputType="number"
|
||||||
|
android:freezesText="true">
|
||||||
|
</EditText>
|
||||||
|
|
||||||
|
<Button android:id="@+id/set_timeout"
|
||||||
|
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:text="@string/set_timeout_label">
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -464,6 +464,8 @@
|
|||||||
<string name="max_failed_pw_hint">Password Attempts Wipe Data</string>
|
<string name="max_failed_pw_hint">Password Attempts Wipe Data</string>
|
||||||
<string name="force_lock">Force Lock</string>
|
<string name="force_lock">Force Lock</string>
|
||||||
<string name="wipe_data">Wipe Data</string>
|
<string name="wipe_data">Wipe Data</string>
|
||||||
|
<string name="timeout_hint">Max screen timeout</string>
|
||||||
|
<string name="set_timeout_label">Set Timeout</string>
|
||||||
|
|
||||||
<!-- ============================== -->
|
<!-- ============================== -->
|
||||||
<!-- app/voice recognition examples strings -->
|
<!-- app/voice recognition examples strings -->
|
||||||
|
|||||||
@@ -129,6 +129,10 @@ public class DeviceAdminSample extends DeviceAdminReceiver {
|
|||||||
Button mForceLockButton;
|
Button mForceLockButton;
|
||||||
Button mWipeDataButton;
|
Button mWipeDataButton;
|
||||||
|
|
||||||
|
private Button mTimeoutButton;
|
||||||
|
|
||||||
|
private EditText mTimeout;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -204,6 +208,10 @@ public class DeviceAdminSample extends DeviceAdminReceiver {
|
|||||||
mForceLockButton.setOnClickListener(mForceLockListener);
|
mForceLockButton.setOnClickListener(mForceLockListener);
|
||||||
mWipeDataButton = (Button)findViewById(R.id.wipe_data);
|
mWipeDataButton = (Button)findViewById(R.id.wipe_data);
|
||||||
mWipeDataButton.setOnClickListener(mWipeDataListener);
|
mWipeDataButton.setOnClickListener(mWipeDataListener);
|
||||||
|
|
||||||
|
mTimeout = (EditText) findViewById(R.id.timeout);
|
||||||
|
mTimeoutButton = (Button) findViewById(R.id.set_timeout);
|
||||||
|
mTimeoutButton.setOnClickListener(mSetTimeoutListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateButtonStates() {
|
void updateButtonStates() {
|
||||||
@@ -397,5 +405,24 @@ public class DeviceAdminSample extends DeviceAdminReceiver {
|
|||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private OnClickListener mSetTimeoutListener = new OnClickListener() {
|
||||||
|
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (mAM.isUserAMonkey()) {
|
||||||
|
// Don't trust monkeys to do the right thing!
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(Controller.this);
|
||||||
|
builder.setMessage("You can't lock my screen because you are a monkey!");
|
||||||
|
builder.setPositiveButton("I admit defeat", null);
|
||||||
|
builder.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean active = mDPM.isAdminActive(mDeviceAdminSample);
|
||||||
|
if (active) {
|
||||||
|
long timeMs = 1000L*Long.parseLong(mTimeout.getText().toString());
|
||||||
|
mDPM.setMaximumTimeToLock(mDeviceAdminSample, timeMs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user