1 <?xml version="1.0" encoding="UTF-8"?> 2 <!-- 3 Copyright 2016 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>DirectBoot</name> 20 <group>Security</group> <!-- This field will be deprecated in the future 21 and replaced with the "categories" tags below. --> 22 <package>com.example.android.directboot</package> 23 24 <minSdk>24</minSdk> 25 <compileSdkVersion>25</compileSdkVersion> 26 <targetSdkVersion>25</targetSdkVersion> 27 28 <!-- Include additional dependencies here.--> 29 <!-- dependency>com.google.android.gms:play-services:5.0.+</dependency --> 30 <dependency>com.android.support:recyclerview-v7:25.0.1</dependency> 31 <dependency>com.android.support:design:25.0.1</dependency> 32 33 <template src="base" /> 34 35 <strings> 36 <intro> 37 <![CDATA[ 38 This sample demonstrates how to store/access data in a device protected storage 39 which is always available while the device is booted. 40 This sample works as a simple alarm clock. On > Android N devices, the scheduled alarms 41 go off after reboot even before the user enters their credentials. 42 ]]> 43 </intro> 44 </strings> 45 46 <metadata> 47 <status>PUBLISHED</status> 48 <categories>Security</categories> 49 <technologies>Android</technologies> 50 <languages>Java</languages> 51 <solutions>Mobile</solutions> 52 <level>INTERMEDIATE</level> 53 <icon>screenshots/icon-web.png</icon> 54 <screenshots> 55 <img>screenshots/1.png</img> 56 <img>screenshots/2.png</img> 57 <img>screenshots/3.png</img> 58 <img>screenshots/4.png</img> 59 </screenshots> 60 <!-- List of APIs that this sample should be cross-referenced under. Use <android> 61 for fully-qualified Framework class names ("android:" namespace). 62 63 Use <ext> for custom namespaces, if needed. See "Samples Index API" documentation 64 for more details. --> 65 <api_refs> 66 <android>android.content.Context.createDeviceProtectedStorageContext</android> 67 </api_refs> 68 69 <!-- 1-3 line description of the sample here. 70 71 Avoid simply rearranging the sample's title. What does this sample actually 72 accomplish, and how does it do it? --> 73 <description> 74 <![CDATA[ 75 Sample demonstrating how to store data in a device protected storage which 76 is always available while the device is booted both before and after any 77 user credentials(PIN/Pattern/Password) are entered. 78 ]]> 79 </description> 80 81 <!-- Multi-paragraph introduction to sample, from an educational point-of-view. 82 Makrdown formatting allowed. This will be used to generate a mini-article for the 83 sample on DAC. --> 84 <intro> 85 <![CDATA[ 86 87 This sample demonstrates how to store and access data in a device protected 88 storage which is always available while the device is booted. 89 Starting from Android N, the system provides two storage locations for user data: 90 91 - Credential protected: 92 - The default storage location for all apps, available only after the user has entered their pattern/password 93 94 - Device protected: 95 - A new storage location which is always available while the device is booted, both before and after any user credentials are entered 96 97 Apps can mark individual components as being direct boot aware which indicates to the system that they can safely run when 98 Credential protected storage is unavailable (an direct boot aware component primarily relies on data stored in the new Device protected storage area, 99 but they may access Credential protected data when unlocked) by adding `directBootAware="true"` in the manifest. 100 ``` 101 <activity|provider|receiver|service ... 102 android:directBootAware=true> 103 ``` 104 105 Components marked as directBoot aware are normal components that will continue to be available after the 106 Credential protected storage becomes available. The storage APIs on the Context supplied to these components will always point to Credential protected storage by default. 107 To access Device protected storage, you can create a secondary Context using this API 108 ``` 109 Context.createDeviceProtectedStorageContext() 110 ``` 111 All of the storage APIs on this returned Context will be redirected to point at Device protected storage. 112 113 You need to be careful what data is stored/moved to a device protected storage 114 because the storage isn't protected by the user's credential (PIN/Pattern/Password) 115 You shouldn't store sensitive data (such as user's emails, auth tokens) in a 116 device protected storage. 117 ]]> 118 </intro> 119 </metadata> 120 </sample> 121