summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/DeviceAdminSettings.java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2014-07-28 16:28:36 -0700
committerAmith Yamasani <yamasani@google.com>2014-07-29 13:50:40 -0700
commitb8e0f608cf28f20b95b65a4f7c0b345298d98e41 (patch)
tree6d61e79fadf672162304a2a202fb15cb8a8fffce /src/com/android/settings/DeviceAdminSettings.java
parent01daaca5475930e394295b06f5a46dc057b44b0f (diff)
downloadpackages_apps_Settings-b8e0f608cf28f20b95b65a4f7c0b345298d98e41.zip
packages_apps_Settings-b8e0f608cf28f20b95b65a4f7c0b345298d98e41.tar.gz
packages_apps_Settings-b8e0f608cf28f20b95b65a4f7c0b345298d98e41.tar.bz2
Implement SET_PROFILE_OWNER intent
This will be shown when a system priv-app tries to add a profile owner to a device that's already been through setupwizard. Refactored the Add Device Admin dialog to also be used for this purpose with additional warning text. Also, make sure that profile owners cannot be deactivated. Bug: 16207721 Change-Id: I25499a22718b2219a5a56b158ca2681243751549
Diffstat (limited to 'src/com/android/settings/DeviceAdminSettings.java')
-rw-r--r--src/com/android/settings/DeviceAdminSettings.java25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/com/android/settings/DeviceAdminSettings.java b/src/com/android/settings/DeviceAdminSettings.java
index 11f8b00..f597b9a 100644
--- a/src/com/android/settings/DeviceAdminSettings.java
+++ b/src/com/android/settings/DeviceAdminSettings.java
@@ -50,13 +50,14 @@ import java.util.Set;
public class DeviceAdminSettings extends ListFragment {
static final String TAG = "DeviceAdminSettings";
-
+
static final int DIALOG_WARNING = 1;
-
+
DevicePolicyManager mDPM;
final HashSet<ComponentName> mActiveAdmins = new HashSet<ComponentName>();
final ArrayList<DeviceAdminInfo> mAvailableAdmins = new ArrayList<DeviceAdminInfo>();
String mDeviceOwnerPkg;
+ ComponentName mProfileOwnerComponent;
@Override
public void onCreate(Bundle icicle) {
@@ -84,6 +85,7 @@ public class DeviceAdminSettings extends ListFragment {
if (mDeviceOwnerPkg != null && !mDPM.isDeviceOwner(mDeviceOwnerPkg)) {
mDeviceOwnerPkg = null;
}
+ mProfileOwnerComponent = mDPM.getProfileOwner();
updateList();
}
@@ -139,7 +141,7 @@ public class DeviceAdminSettings extends ListFragment {
Log.w(TAG, "Skipping " + ri.activityInfo, e);
}
}
-
+
getListView().setAdapter(new PolicyListAdapter());
}
@@ -158,10 +160,10 @@ public class DeviceAdminSettings extends ListFragment {
CheckBox checkbox;
TextView description;
}
-
+
class PolicyListAdapter extends BaseAdapter {
final LayoutInflater mInflater;
-
+
PolicyListAdapter() {
mInflater = (LayoutInflater)
getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -170,7 +172,7 @@ public class DeviceAdminSettings extends ListFragment {
public boolean hasStableIds() {
return true;
}
-
+
public int getCount() {
return mAvailableAdmins.size();
}
@@ -189,8 +191,11 @@ public class DeviceAdminSettings extends ListFragment {
public boolean isEnabled(int position) {
DeviceAdminInfo info = mAvailableAdmins.get(position);
- if (mActiveAdmins.contains(info.getComponent())
- && info.getPackageName().equals(mDeviceOwnerPkg)) {
+ String packageName = info.getPackageName();
+ ComponentName component = info.getComponent();
+ if (mActiveAdmins.contains(component)
+ && (packageName.equals(mDeviceOwnerPkg)
+ || component.equals(mProfileOwnerComponent))) {
return false;
} else {
return true;
@@ -207,7 +212,7 @@ public class DeviceAdminSettings extends ListFragment {
bindView(v, position);
return v;
}
-
+
public View newView(ViewGroup parent) {
View v = mInflater.inflate(R.layout.device_admin_item, parent, false);
ViewHolder h = new ViewHolder();
@@ -218,7 +223,7 @@ public class DeviceAdminSettings extends ListFragment {
v.setTag(h);
return v;
}
-
+
public void bindView(View view, int position) {
final Activity activity = getActivity();
ViewHolder vh = (ViewHolder) view.getTag();