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