Merge "Update TrustAgentService API after review" into lmp-mr1-dev
This commit is contained in:
@@ -790,6 +790,10 @@
|
|||||||
<string name="require_encryption">Require encryption</string>
|
<string name="require_encryption">Require encryption</string>
|
||||||
<string name="activate_encryption">Activate encryption</string>
|
<string name="activate_encryption">Activate encryption</string>
|
||||||
|
|
||||||
|
<string name="trust_agent_category">Trust Agent Features</string>
|
||||||
|
<string name="set_trust_agent_component_name">Enabled Component Name</string>
|
||||||
|
<string name="set_trust_agent_feature_list">Enabled Features (comma-separated)</string>
|
||||||
|
|
||||||
<!-- Strings used by DeviceAdminSample controller code -->
|
<!-- Strings used by DeviceAdminSample controller code -->
|
||||||
<string name="password_sufficient">Current password meets policy requirements</string>
|
<string name="password_sufficient">Current password meets policy requirements</string>
|
||||||
<string name="password_insufficient">Current password does not meet policy requirements</string>
|
<string name="password_insufficient">Current password does not meet policy requirements</string>
|
||||||
|
|||||||
@@ -57,4 +57,19 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:title="@string/trust_agent_category" >
|
||||||
|
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="key_trust_agent_component"
|
||||||
|
android:title="@string/set_trust_agent_component_name"
|
||||||
|
android:dialogTitle="@string/set_trust_agent_component_name" />
|
||||||
|
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="key_trust_agent_features"
|
||||||
|
android:title="@string/set_trust_agent_feature_list"
|
||||||
|
android:dialogTitle="@string/set_trust_agent_feature_list" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.PersistableBundle;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
@@ -41,6 +43,8 @@ import android.text.TextUtils;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,6 +75,8 @@ public class DeviceAdminSample extends PreferenceActivity {
|
|||||||
private static final String KEY_DISABLE_NOTIFICATIONS = "key_disable_notifications";
|
private static final String KEY_DISABLE_NOTIFICATIONS = "key_disable_notifications";
|
||||||
private static final String KEY_DISABLE_UNREDACTED = "key_disable_unredacted";
|
private static final String KEY_DISABLE_UNREDACTED = "key_disable_unredacted";
|
||||||
private static final String KEY_DISABLE_TRUST_AGENTS = "key_disable_trust_agents";
|
private static final String KEY_DISABLE_TRUST_AGENTS = "key_disable_trust_agents";
|
||||||
|
private static final String KEY_TRUST_AGENT_COMPONENT = "key_trust_agent_component";
|
||||||
|
private static final String KEY_TRUST_AGENT_FEATURES = "key_trust_agent_features";
|
||||||
private static final String KEY_DISABLE_KEYGUARD_WIDGETS = "key_disable_keyguard_widgets";
|
private static final String KEY_DISABLE_KEYGUARD_WIDGETS = "key_disable_keyguard_widgets";
|
||||||
private static final String KEY_DISABLE_KEYGUARD_SECURE_CAMERA
|
private static final String KEY_DISABLE_KEYGUARD_SECURE_CAMERA
|
||||||
= "key_disable_keyguard_secure_camera";
|
= "key_disable_keyguard_secure_camera";
|
||||||
@@ -274,6 +280,8 @@ public class DeviceAdminSample extends PreferenceActivity {
|
|||||||
private CheckBoxPreference mDisableKeyguardNotificationCheckbox;
|
private CheckBoxPreference mDisableKeyguardNotificationCheckbox;
|
||||||
private CheckBoxPreference mDisableKeyguardTrustAgentCheckbox;
|
private CheckBoxPreference mDisableKeyguardTrustAgentCheckbox;
|
||||||
private CheckBoxPreference mDisableKeyguardUnredactedCheckbox;
|
private CheckBoxPreference mDisableKeyguardUnredactedCheckbox;
|
||||||
|
private EditTextPreference mTrustAgentComponent;
|
||||||
|
private EditTextPreference mTrustAgentFeatures;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -304,6 +312,14 @@ public class DeviceAdminSample extends PreferenceActivity {
|
|||||||
mDisableKeyguardTrustAgentCheckbox =
|
mDisableKeyguardTrustAgentCheckbox =
|
||||||
(CheckBoxPreference) findPreference(KEY_DISABLE_TRUST_AGENTS);
|
(CheckBoxPreference) findPreference(KEY_DISABLE_TRUST_AGENTS);
|
||||||
mDisableKeyguardTrustAgentCheckbox.setOnPreferenceChangeListener(this);
|
mDisableKeyguardTrustAgentCheckbox.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
mTrustAgentComponent =
|
||||||
|
(EditTextPreference) findPreference(KEY_TRUST_AGENT_COMPONENT);
|
||||||
|
mTrustAgentComponent.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
mTrustAgentFeatures =
|
||||||
|
(EditTextPreference) findPreference(KEY_TRUST_AGENT_FEATURES);
|
||||||
|
mTrustAgentFeatures.setOnPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// At onResume time, reload UI with current values as required
|
// At onResume time, reload UI with current values as required
|
||||||
@@ -340,8 +356,8 @@ public class DeviceAdminSample extends PreferenceActivity {
|
|||||||
if (super.onPreferenceChange(preference, newValue)) {
|
if (super.onPreferenceChange(preference, newValue)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean value = (Boolean) newValue;
|
|
||||||
if (preference == mEnableCheckbox) {
|
if (preference == mEnableCheckbox) {
|
||||||
|
boolean value = (Boolean) newValue;
|
||||||
if (value != mAdminActive) {
|
if (value != mAdminActive) {
|
||||||
if (value) {
|
if (value) {
|
||||||
// Launch the activity to have the user enable our admin.
|
// Launch the activity to have the user enable our admin.
|
||||||
@@ -359,6 +375,7 @@ public class DeviceAdminSample extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (preference == mDisableCameraCheckbox) {
|
} else if (preference == mDisableCameraCheckbox) {
|
||||||
|
boolean value = (Boolean) newValue;
|
||||||
mDPM.setCameraDisabled(mDeviceAdminSample, value);
|
mDPM.setCameraDisabled(mDeviceAdminSample, value);
|
||||||
// Delay update because the change is only applied after exiting this method.
|
// Delay update because the change is only applied after exiting this method.
|
||||||
postReloadSummaries();
|
postReloadSummaries();
|
||||||
@@ -366,20 +383,39 @@ public class DeviceAdminSample extends PreferenceActivity {
|
|||||||
|| preference == mDisableKeyguardSecureCameraCheckbox
|
|| preference == mDisableKeyguardSecureCameraCheckbox
|
||||||
|| preference == mDisableKeyguardNotificationCheckbox
|
|| preference == mDisableKeyguardNotificationCheckbox
|
||||||
|| preference == mDisableKeyguardUnredactedCheckbox
|
|| preference == mDisableKeyguardUnredactedCheckbox
|
||||||
|| preference == mDisableKeyguardTrustAgentCheckbox) {
|
|| preference == mDisableKeyguardTrustAgentCheckbox
|
||||||
// Delay update because the change is only applied after exiting this method.
|
|| preference == mTrustAgentComponent
|
||||||
getView().post(new Runnable() {
|
|| preference == mTrustAgentFeatures) {
|
||||||
@Override
|
postUpdateDpmDisableFeatures();
|
||||||
public void run() {
|
|
||||||
mDPM.setKeyguardDisabledFeatures(mDeviceAdminSample,
|
|
||||||
createKeyguardDisabledFlag());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
postReloadSummaries();
|
postReloadSummaries();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void postUpdateDpmDisableFeatures() {
|
||||||
|
getView().post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mDPM.setKeyguardDisabledFeatures(mDeviceAdminSample,
|
||||||
|
createKeyguardDisabledFlag());
|
||||||
|
String component = mTrustAgentComponent.getText();
|
||||||
|
if (component != null) {
|
||||||
|
ComponentName agent = ComponentName.unflattenFromString(component);
|
||||||
|
if (agent != null) {
|
||||||
|
String featureString = mTrustAgentFeatures.getText();
|
||||||
|
if (featureString != null) {
|
||||||
|
PersistableBundle bundle = new PersistableBundle();
|
||||||
|
bundle.putStringArray("features", featureString.split(","));
|
||||||
|
mDPM.setTrustAgentConfiguration(mDeviceAdminSample, agent, bundle);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "Invalid component: " + component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void reloadSummaries() {
|
protected void reloadSummaries() {
|
||||||
super.reloadSummaries();
|
super.reloadSummaries();
|
||||||
@@ -416,6 +452,17 @@ public class DeviceAdminSample extends PreferenceActivity {
|
|||||||
R.string.keyguard_trust_agents_disabled
|
R.string.keyguard_trust_agents_disabled
|
||||||
: R.string.keyguard_trust_agents_enabled);
|
: R.string.keyguard_trust_agents_enabled);
|
||||||
mDisableKeyguardTrustAgentCheckbox.setSummary(keyguardEnableTrustAgentSummary);
|
mDisableKeyguardTrustAgentCheckbox.setSummary(keyguardEnableTrustAgentSummary);
|
||||||
|
|
||||||
|
final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
||||||
|
final boolean trustDisabled =
|
||||||
|
(disabled & DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0;
|
||||||
|
String component = prefs.getString(mTrustAgentComponent.getKey(), null);
|
||||||
|
mTrustAgentComponent.setSummary(component);
|
||||||
|
mTrustAgentComponent.setEnabled(trustDisabled);
|
||||||
|
|
||||||
|
String features = prefs.getString(mTrustAgentFeatures.getKey(), null);
|
||||||
|
mTrustAgentFeatures.setSummary(features);
|
||||||
|
mTrustAgentFeatures.setEnabled(trustDisabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Updates the device capabilities area (dis/enabling) as the admin is (de)activated */
|
/** Updates the device capabilities area (dis/enabling) as the admin is (de)activated */
|
||||||
@@ -426,6 +473,8 @@ public class DeviceAdminSample extends PreferenceActivity {
|
|||||||
mDisableKeyguardNotificationCheckbox.setEnabled(enabled);
|
mDisableKeyguardNotificationCheckbox.setEnabled(enabled);
|
||||||
mDisableKeyguardUnredactedCheckbox.setEnabled(enabled);
|
mDisableKeyguardUnredactedCheckbox.setEnabled(enabled);
|
||||||
mDisableKeyguardTrustAgentCheckbox.setEnabled(enabled);
|
mDisableKeyguardTrustAgentCheckbox.setEnabled(enabled);
|
||||||
|
mTrustAgentComponent.setEnabled(enabled);
|
||||||
|
mTrustAgentFeatures.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user