Home | History | Annotate | Download | only in AppRestrictionSchema
      1 <?xml version="1.0" encoding="UTF-8"?>
      2 <!--
      3  Copyright 2014 The Android Open Source Project
      4 
      5  Licensed under the Apache License, Version 2.0 (the "License");
      6  you may not use this file except in compliance with the License.
      7  You may obtain a copy of the License at
      8 
      9      http://www.apache.org/licenses/LICENSE-2.0
     10 
     11  Unless required by applicable law or agreed to in writing, software
     12  distributed under the License is distributed on an "AS IS" BASIS,
     13  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  See the License for the specific language governing permissions and
     15  limitations under the License.
     16 -->
     17 
     18 <sample>
     19     <name>AppRestrictionSchema</name>
     20     <group>Admin</group>
     21     <package>com.example.android.apprestrictionschema</package>
     22 
     23     <minSdk>21</minSdk>
     24 
     25     <strings>
     26         <intro>
     27             <![CDATA[
     28             This sample shows how to use app restrictions. This application has one boolean
     29             restriction with a key \"can_say_hello\" that defines whether the only feature of this
     30             app (press the button to show \"Hello\" message) is enabled or disabled. Use
     31             AppRestrictionEnforcer sample to toggle the restriction.
     32             ]]>
     33         </intro>
     34     </strings>
     35 
     36     <template src="base" />
     37     <template src="FragmentView" />
     38     <common src="logger" />
     39     <common src="activities" />
     40 
     41     <metadata>
     42         <status>PUBLISHED</status>
     43         <categories>Device Admin</categories>
     44         <technologies>Android</technologies>
     45         <languages>Java</languages>
     46         <solutions>Mobile</solutions>
     47         <level>ADVANCED</level>
     48         <icon>screenshots/big_icon.png</icon>
     49         <screenshots>
     50             <img>screenshots/main.png</img>
     51         </screenshots>
     52         <api_refs>
     53             <android>android.content.RestrictionsManager</android>
     54         </api_refs>
     55 
     56         <description>
     57 A basic app showing how to allow a device administrator to restrict user
     58 activities using the Android Device Administration API. The app exports
     59 a custom policy that enables or disables a UI control. Device Administration
     60 applications are able to enforce a specific value for this policy, as
     61 directed by enterprise administrators.
     62         </description>
     63 
     64         <intro>
     65 <![CDATA[
     66 The [Android Device Administration API][1] allows enterprise administrators to
     67 enforce specific policies on a managed device. The system provides policies
     68 that control settings such as password complexity, screen lock, or camera
     69 availability. Developers can also augment this list with custom policies
     70 that control specific features within their applications. For example,
     71 a web browser could provide access to a whitelist of allowed domains.
     72 
     73 The list of policies exposed by an app must be specified using a file
     74 inside of the `res/xml` directory, using the `<restriction>` tag:
     75 
     76 ```xml
     77 <restrictions xmlns:android="http://schemas.android.com/apk/res/android">
     78 
     79     <restriction
     80             android:defaultValue="false"
     81             android:description="@string/description_can_say_hello"
     82             android:key="can_say_hello"
     83             android:restrictionType="bool"
     84             android:title="@string/title_can_say_hello" />
     85 
     86 </restrictions>
     87 ```
     88 
     89 In this sample, that file can be found at
     90 `Application/src/main/res/xml/app_restrictions.xml`. This file must be
     91 also be declared inside of `ApplicationManifest.xml` using a `<meta-data>`
     92 element:
     93 
     94 ```xml
     95 <meta-data
     96         android:name="android.content.APP_RESTRICTIONS"
     97         android:resource="@xml/app_restrictions" />
     98 ```
     99 
    100 At runtime, the current list of restrictions enforced by policy can be
    101 checked by calling [RestrictionsManager.getApplicationRestrictions()][2].
    102 
    103 [1]: http://developer.android.com/guide/topics/admin/device-admin.html
    104 [2]: https://developer.android.com/reference/android/content/RestrictionsManager.html#getApplicationRestrictions()
    105 ]]>
    106         </intro>
    107     </metadata>
    108 
    109 </sample>
    110