5050 */
5151public final class DeviceAdminInfo implements Parcelable {
5252 static final String TAG = "DeviceAdminInfo" ;
53-
53+
5454 /**
5555 * A type of policy that this device admin can use: limit the passwords
5656 * that the user can select, via {@link DevicePolicyManager#setPasswordQuality}
5757 * and {@link DevicePolicyManager#setPasswordMinimumLength}.
58- *
58+ *
5959 * <p>To control this policy, the device admin must have a "limit-password"
6060 * tag in the "uses-policies" section of its meta-data.
6161 */
6262 public static final int USES_POLICY_LIMIT_PASSWORD = 0 ;
63-
63+
6464 /**
6565 * A type of policy that this device admin can use: able to watch login
6666 * attempts from the user, via {@link DeviceAdminReceiver#ACTION_PASSWORD_FAILED},
6767 * {@link DeviceAdminReceiver#ACTION_PASSWORD_SUCCEEDED}, and
6868 * {@link DevicePolicyManager#getCurrentFailedPasswordAttempts}.
69- *
69+ *
7070 * <p>To control this policy, the device admin must have a "watch-login"
7171 * tag in the "uses-policies" section of its meta-data.
7272 */
@@ -76,7 +76,7 @@ public final class DeviceAdminInfo implements Parcelable {
7676 * A type of policy that this device admin can use: able to reset the
7777 * user's password via
7878 * {@link DevicePolicyManager#resetPassword}.
79- *
79+ *
8080 * <p>To control this policy, the device admin must have a "reset-password"
8181 * tag in the "uses-policies" section of its meta-data.
8282 */
@@ -87,7 +87,7 @@ public final class DeviceAdminInfo implements Parcelable {
8787 * to lock via{@link DevicePolicyManager#lockNow} or limit the
8888 * maximum lock timeout for the device via
8989 * {@link DevicePolicyManager#setMaximumTimeToLock}.
90- *
90+ *
9191 * <p>To control this policy, the device admin must have a "force-lock"
9292 * tag in the "uses-policies" section of its meta-data.
9393 */
@@ -97,7 +97,7 @@ public final class DeviceAdminInfo implements Parcelable {
9797 * A type of policy that this device admin can use: able to factory
9898 * reset the device, erasing all of the user's data, via
9999 * {@link DevicePolicyManager#wipeData}.
100- *
100+ *
101101 * <p>To control this policy, the device admin must have a "wipe-data"
102102 * tag in the "uses-policies" section of its meta-data.
103103 */
@@ -138,25 +138,33 @@ public final class DeviceAdminInfo implements Parcelable {
138138 */
139139 public static final int USES_POLICY_DISABLE_CAMERA = 8 ;
140140
141+ /**
142+ * A type of policy that this device admin can use: disables use of keyguard widgets.
143+ *
144+ * <p>To control this policy, the device admin must have a "disable-keyguard-widgets"
145+ * tag in the "uses-policies" section of its meta-data.
146+ */
147+ public static final int USES_POLICY_DISABLE_KEYGUARD_WIDGETS = 9 ;
148+
141149 /** @hide */
142150 public static class PolicyInfo {
143151 public final int ident ;
144152 final public String tag ;
145153 final public int label ;
146154 final public int description ;
147-
155+
148156 public PolicyInfo (int identIn , String tagIn , int labelIn , int descriptionIn ) {
149157 ident = identIn ;
150158 tag = tagIn ;
151159 label = labelIn ;
152160 description = descriptionIn ;
153161 }
154162 }
155-
163+
156164 static ArrayList <PolicyInfo > sPoliciesDisplayOrder = new ArrayList <PolicyInfo >();
157165 static HashMap <String , Integer > sKnownPolicies = new HashMap <String , Integer >();
158166 static SparseArray <PolicyInfo > sRevKnownPolicies = new SparseArray <PolicyInfo >();
159-
167+
160168 static {
161169 sPoliciesDisplayOrder .add (new PolicyInfo (USES_POLICY_WIPE_DATA , "wipe-data" ,
162170 com .android .internal .R .string .policylab_wipeData ,
@@ -185,32 +193,36 @@ public PolicyInfo(int identIn, String tagIn, int labelIn, int descriptionIn) {
185193 sPoliciesDisplayOrder .add (new PolicyInfo (USES_POLICY_DISABLE_CAMERA , "disable-camera" ,
186194 com .android .internal .R .string .policylab_disableCamera ,
187195 com .android .internal .R .string .policydesc_disableCamera ));
196+ sPoliciesDisplayOrder .add (new PolicyInfo (
197+ USES_POLICY_DISABLE_KEYGUARD_WIDGETS , "disable-keyguard-widgets" ,
198+ com .android .internal .R .string .policylab_disableKeyguardWidgets ,
199+ com .android .internal .R .string .policydesc_disableKeyguardWidgets ));
188200
189201 for (int i =0 ; i <sPoliciesDisplayOrder .size (); i ++) {
190202 PolicyInfo pi = sPoliciesDisplayOrder .get (i );
191203 sRevKnownPolicies .put (pi .ident , pi );
192204 sKnownPolicies .put (pi .tag , pi .ident );
193205 }
194206 }
195-
207+
196208 /**
197209 * The BroadcastReceiver that implements this device admin component.
198210 */
199211 final ResolveInfo mReceiver ;
200-
212+
201213 /**
202214 * Whether this should be visible to the user.
203215 */
204216 boolean mVisible ;
205-
217+
206218 /**
207219 * The policies this administrator needs access to.
208220 */
209221 int mUsesPolicies ;
210-
222+
211223 /**
212224 * Constructor.
213- *
225+ *
214226 * @param context The Context in which we are parsing the device admin.
215227 * @param receiver The ResolveInfo returned from the package manager about
216228 * this device admin's component.
@@ -219,40 +231,40 @@ public DeviceAdminInfo(Context context, ResolveInfo receiver)
219231 throws XmlPullParserException , IOException {
220232 mReceiver = receiver ;
221233 ActivityInfo ai = receiver .activityInfo ;
222-
234+
223235 PackageManager pm = context .getPackageManager ();
224-
236+
225237 XmlResourceParser parser = null ;
226238 try {
227239 parser = ai .loadXmlMetaData (pm , DeviceAdminReceiver .DEVICE_ADMIN_META_DATA );
228240 if (parser == null ) {
229241 throw new XmlPullParserException ("No "
230242 + DeviceAdminReceiver .DEVICE_ADMIN_META_DATA + " meta-data" );
231243 }
232-
244+
233245 Resources res = pm .getResourcesForApplication (ai .applicationInfo );
234-
246+
235247 AttributeSet attrs = Xml .asAttributeSet (parser );
236-
248+
237249 int type ;
238250 while ((type =parser .next ()) != XmlPullParser .END_DOCUMENT
239251 && type != XmlPullParser .START_TAG ) {
240252 }
241-
253+
242254 String nodeName = parser .getName ();
243255 if (!"device-admin" .equals (nodeName )) {
244256 throw new XmlPullParserException (
245257 "Meta-data does not start with device-admin tag" );
246258 }
247-
259+
248260 TypedArray sa = res .obtainAttributes (attrs ,
249261 com .android .internal .R .styleable .DeviceAdmin );
250262
251263 mVisible = sa .getBoolean (
252264 com .android .internal .R .styleable .DeviceAdmin_visible , true );
253-
265+
254266 sa .recycle ();
255-
267+
256268 int outerDepth = parser .getDepth ();
257269 while ((type =parser .next ()) != XmlPullParser .END_DOCUMENT
258270 && (type != XmlPullParser .END_TAG || parser .getDepth () > outerDepth )) {
@@ -290,14 +302,14 @@ public DeviceAdminInfo(Context context, ResolveInfo receiver)
290302 mReceiver = ResolveInfo .CREATOR .createFromParcel (source );
291303 mUsesPolicies = source .readInt ();
292304 }
293-
305+
294306 /**
295307 * Return the .apk package that implements this device admin.
296308 */
297309 public String getPackageName () {
298310 return mReceiver .activityInfo .packageName ;
299311 }
300-
312+
301313 /**
302314 * Return the class name of the receiver component that implements
303315 * this device admin.
@@ -321,20 +333,20 @@ public ComponentName getComponent() {
321333 return new ComponentName (mReceiver .activityInfo .packageName ,
322334 mReceiver .activityInfo .name );
323335 }
324-
336+
325337 /**
326338 * Load the user-displayed label for this device admin.
327- *
339+ *
328340 * @param pm Supply a PackageManager used to load the device admin's
329341 * resources.
330342 */
331343 public CharSequence loadLabel (PackageManager pm ) {
332344 return mReceiver .loadLabel (pm );
333345 }
334-
346+
335347 /**
336348 * Load user-visible description associated with this device admin.
337- *
349+ *
338350 * @param pm Supply a PackageManager used to load the device admin's
339351 * resources.
340352 */
@@ -351,25 +363,25 @@ public CharSequence loadDescription(PackageManager pm) throws NotFoundException
351363 }
352364 throw new NotFoundException ();
353365 }
354-
366+
355367 /**
356368 * Load the user-displayed icon for this device admin.
357- *
369+ *
358370 * @param pm Supply a PackageManager used to load the device admin's
359371 * resources.
360372 */
361373 public Drawable loadIcon (PackageManager pm ) {
362374 return mReceiver .loadIcon (pm );
363375 }
364-
376+
365377 /**
366378 * Returns whether this device admin would like to be visible to the
367379 * user, even when it is not enabled.
368380 */
369381 public boolean isVisible () {
370382 return mVisible ;
371383 }
372-
384+
373385 /**
374386 * Return true if the device admin has requested that it be able to use
375387 * the given policy control. The possible policy identifier inputs are:
@@ -382,7 +394,7 @@ public boolean isVisible() {
382394 public boolean usesPolicy (int policyIdent ) {
383395 return (mUsesPolicies & (1 <<policyIdent )) != 0 ;
384396 }
385-
397+
386398 /**
387399 * Return the XML tag name for the given policy identifier. Valid identifiers
388400 * are as per {@link #usesPolicy(int)}. If the given identifier is not
@@ -391,7 +403,7 @@ public boolean usesPolicy(int policyIdent) {
391403 public String getTagForPolicy (int policyIdent ) {
392404 return sRevKnownPolicies .get (policyIdent ).tag ;
393405 }
394-
406+
395407 /** @hide */
396408 public ArrayList <PolicyInfo > getUsedPolicies () {
397409 ArrayList <PolicyInfo > res = new ArrayList <PolicyInfo >();
@@ -403,33 +415,33 @@ public ArrayList<PolicyInfo> getUsedPolicies() {
403415 }
404416 return res ;
405417 }
406-
418+
407419 /** @hide */
408420 public void writePoliciesToXml (XmlSerializer out )
409421 throws IllegalArgumentException , IllegalStateException , IOException {
410422 out .attribute (null , "flags" , Integer .toString (mUsesPolicies ));
411423 }
412-
424+
413425 /** @hide */
414426 public void readPoliciesFromXml (XmlPullParser parser )
415427 throws XmlPullParserException , IOException {
416428 mUsesPolicies = Integer .parseInt (
417429 parser .getAttributeValue (null , "flags" ));
418430 }
419-
431+
420432 public void dump (Printer pw , String prefix ) {
421433 pw .println (prefix + "Receiver:" );
422434 mReceiver .dump (pw , prefix + " " );
423435 }
424-
436+
425437 @ Override
426438 public String toString () {
427439 return "DeviceAdminInfo{" + mReceiver .activityInfo .name + "}" ;
428440 }
429441
430442 /**
431443 * Used to package this object into a {@link Parcel}.
432- *
444+ *
433445 * @param dest The {@link Parcel} to be written.
434446 * @param flags The flags used for parceling.
435447 */
0 commit comments