summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/profiles
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2015-05-28 01:03:15 +0200
committerAdnan Begovic <adnan@cyngn.com>2015-10-27 14:06:49 -0700
commit2087aa07bd07376d9424a61160714e3f34df7b40 (patch)
treee38409a97e068c4d4cd8b79daef1bf0a27e1f8a7 /src/com/android/settings/profiles
parent5a031e85d29cfea87af2b567a079629f1af882d5 (diff)
downloadpackages_apps_Settings-2087aa07bd07376d9424a61160714e3f34df7b40.zip
packages_apps_Settings-2087aa07bd07376d9424a61160714e3f34df7b40.tar.gz
packages_apps_Settings-2087aa07bd07376d9424a61160714e3f34df7b40.tar.bz2
profiles: respect lockscreen policies
Don't allow to change lockscreen mode if there is a device administrador that avoid it Change-Id: I2485f96fba41c60248260ee03ffa0614e94195b4 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src/com/android/settings/profiles')
-rw-r--r--src/com/android/settings/profiles/SetupActionsFragment.java11
-rw-r--r--src/com/android/settings/profiles/actions/ItemListAdapter.java1
-rw-r--r--src/com/android/settings/profiles/actions/item/DisabledItem.java67
3 files changed, 78 insertions, 1 deletions
diff --git a/src/com/android/settings/profiles/SetupActionsFragment.java b/src/com/android/settings/profiles/SetupActionsFragment.java
index bc7cad1..bcd98be 100644
--- a/src/com/android/settings/profiles/SetupActionsFragment.java
+++ b/src/com/android/settings/profiles/SetupActionsFragment.java
@@ -26,6 +26,7 @@ import android.app.NotificationGroup;
import cyanogenmod.profiles.LockSettings;
import cyanogenmod.profiles.RingModeSettings;
import cyanogenmod.profiles.StreamSettings;
+import android.app.admin.DevicePolicyManager;
import android.bluetooth.BluetoothAdapter;
import android.content.ContentResolver;
import android.content.Context;
@@ -75,6 +76,7 @@ import com.android.settings.profiles.actions.item.AirplaneModeItem;
import com.android.settings.profiles.actions.item.BrightnessItem;
import com.android.settings.profiles.actions.item.AppGroupItem;
import com.android.settings.profiles.actions.item.ConnectionOverrideItem;
+import com.android.settings.profiles.actions.item.DisabledItem;
import com.android.settings.profiles.actions.item.DozeModeItem;
import com.android.settings.profiles.actions.item.Header;
import com.android.settings.profiles.actions.item.Item;
@@ -238,7 +240,14 @@ public class SetupActionsFragment extends SettingsPreferenceFragment
mItems.add(new Header(getString(R.string.profile_system_settings_title)));
mItems.add(new RingModeItem(mProfile.getRingMode()));
mItems.add(new AirplaneModeItem(mProfile.getAirplaneMode()));
- mItems.add(new LockModeItem(mProfile));
+ DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(
+ Context.DEVICE_POLICY_SERVICE);
+ if (!dpm.requireSecureKeyguard()) {
+ mItems.add(new LockModeItem(mProfile));
+ } else {
+ mItems.add(new DisabledItem(R.string.profile_lockmode_title,
+ R.string.profile_lockmode_policy_disabled_summary));
+ }
mItems.add(new BrightnessItem(mProfile.getBrightness()));
final Activity activity = getActivity();
diff --git a/src/com/android/settings/profiles/actions/ItemListAdapter.java b/src/com/android/settings/profiles/actions/ItemListAdapter.java
index 61bbd0d..2b26d99 100644
--- a/src/com/android/settings/profiles/actions/ItemListAdapter.java
+++ b/src/com/android/settings/profiles/actions/ItemListAdapter.java
@@ -29,6 +29,7 @@ public class ItemListAdapter extends ArrayAdapter<Item> {
public enum RowType {
HEADER_ITEM,
+ DISABLED_ITEM,
CONNECTION_ITEM,
VOLUME_STREAM_ITEM,
NAME_ITEM,
diff --git a/src/com/android/settings/profiles/actions/item/DisabledItem.java b/src/com/android/settings/profiles/actions/item/DisabledItem.java
new file mode 100644
index 0000000..3b16c28
--- /dev/null
+++ b/src/com/android/settings/profiles/actions/item/DisabledItem.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2015 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.profiles.actions.item;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.profiles.actions.ItemListAdapter;
+
+public class DisabledItem implements Item {
+
+ private final int mResTitle;
+ private final int mResSummary;
+
+ public DisabledItem(int resTitle, int resSummary) {
+ mResTitle = resTitle;
+ mResSummary = resSummary;
+ }
+
+ @Override
+ public ItemListAdapter.RowType getRowType() {
+ return ItemListAdapter.RowType.DISABLED_ITEM;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return false;
+ }
+
+ @Override
+ public View getView(LayoutInflater inflater, View convertView, ViewGroup parent) {
+ View view;
+ if (convertView == null) {
+ view = inflater.inflate(R.layout.list_two_line_item, parent, false);
+ // Do some initialization
+ } else {
+ view = convertView;
+ }
+
+ TextView text = (TextView) view.findViewById(R.id.title);
+ text.setText(mResTitle);
+ text.setEnabled(false);
+
+ TextView desc = (TextView) view.findViewById(R.id.summary);
+ desc.setText(mResSummary);
+ desc.setEnabled(false);
+
+ return view;
+ }
+
+}