1*d353a188SXin Li 2*d353a188SXin LiAndroid DirectBoot Sample 3*d353a188SXin Li=================================== 4*d353a188SXin Li 5*d353a188SXin LiSample demonstrating how to store data in a device protected storage which 6*d353a188SXin Liis always available while the device is booted both before and after any 7*d353a188SXin Liuser credentials(PIN/Pattern/Password) are entered. 8*d353a188SXin Li 9*d353a188SXin LiIntroduction 10*d353a188SXin Li------------ 11*d353a188SXin Li 12*d353a188SXin LiThis sample demonstrates how to store and access data in a device protected 13*d353a188SXin Listorage which is always available while the device is booted. 14*d353a188SXin LiStarting from Android N, the system provides two storage locations for user data: 15*d353a188SXin Li 16*d353a188SXin Li- Credential protected: 17*d353a188SXin Li - The default storage location for all apps, available only after the user has entered their pattern/password 18*d353a188SXin Li 19*d353a188SXin Li- Device protected: 20*d353a188SXin Li - A new storage location which is always available while the device is booted, both before and after any user credentials are entered 21*d353a188SXin Li 22*d353a188SXin LiApps can mark individual components as being direct boot aware which indicates to the system that they can safely run when 23*d353a188SXin LiCredential protected storage is unavailable (an direct boot aware component primarily relies on data stored in the new Device protected storage area, 24*d353a188SXin Libut they may access Credential protected data when unlocked) by adding `directBootAware="true"` in the manifest. 25*d353a188SXin Li``` 26*d353a188SXin Li<activity|provider|receiver|service ... 27*d353a188SXin Liandroid:directBootAware=”true”> 28*d353a188SXin Li``` 29*d353a188SXin Li 30*d353a188SXin LiComponents marked as directBoot aware are normal components that will continue to be available after the 31*d353a188SXin LiCredential protected storage becomes available. The storage APIs on the Context supplied to these components will always point to Credential protected storage by default. 32*d353a188SXin LiTo access Device protected storage, you can create a secondary Context using this API 33*d353a188SXin Li``` 34*d353a188SXin LiContext.createDeviceProtectedStorageContext() 35*d353a188SXin Li``` 36*d353a188SXin LiAll of the storage APIs on this returned Context will be redirected to point at Device protected storage. 37*d353a188SXin Li 38*d353a188SXin LiYou need to be careful what data is stored/moved to a device protected storage 39*d353a188SXin Libecause the storage isn't protected by the user's credential (PIN/Pattern/Password) 40*d353a188SXin LiYou shouldn't store sensitive data (such as user's emails, auth tokens) in a 41*d353a188SXin Lidevice protected storage. 42*d353a188SXin Li 43*d353a188SXin LiPre-requisites 44*d353a188SXin Li-------------- 45*d353a188SXin Li 46*d353a188SXin Li- Android SDK 25 47*d353a188SXin Li- Android Build Tools v27.0.2 48*d353a188SXin Li- Android Support Repository 49*d353a188SXin Li 50*d353a188SXin LiScreenshots 51*d353a188SXin Li------------- 52*d353a188SXin Li 53*d353a188SXin Li<img src="screenshots/1.png" height="400" alt="Screenshot"/> <img src="screenshots/2.png" height="400" alt="Screenshot"/> <img src="screenshots/3.png" height="400" alt="Screenshot"/> <img src="screenshots/4.png" height="400" alt="Screenshot"/> 54*d353a188SXin Li 55*d353a188SXin LiGetting Started 56*d353a188SXin Li--------------- 57*d353a188SXin Li 58*d353a188SXin LiThis sample uses the Gradle build system. To build this project, use the 59*d353a188SXin Li"gradlew build" command or use "Import Project" in Android Studio. 60*d353a188SXin Li 61*d353a188SXin LiSupport 62*d353a188SXin Li------- 63*d353a188SXin Li 64*d353a188SXin Li- Google+ Community: https://plus.google.com/communities/105153134372062985968 65*d353a188SXin Li- Stack Overflow: http://stackoverflow.com/questions/tagged/android 66*d353a188SXin Li 67*d353a188SXin LiIf you've found an error in this sample, please file an issue: 68*d353a188SXin Lihttps://github.com/googlesamples/android-DirectBoot 69*d353a188SXin Li 70*d353a188SXin LiPatches are encouraged, and may be submitted by forking this project and 71*d353a188SXin Lisubmitting a pull request through GitHub. Please see CONTRIBUTING.md for more details. 72*d353a188SXin Li 73*d353a188SXin LiLicense 74*d353a188SXin Li------- 75*d353a188SXin Li 76*d353a188SXin LiCopyright 2017 The Android Open Source Project, Inc. 77*d353a188SXin Li 78*d353a188SXin LiLicensed to the Apache Software Foundation (ASF) under one or more contributor 79*d353a188SXin Lilicense agreements. See the NOTICE file distributed with this work for 80*d353a188SXin Liadditional information regarding copyright ownership. The ASF licenses this 81*d353a188SXin Lifile to you under the Apache License, Version 2.0 (the "License"); you may not 82*d353a188SXin Liuse this file except in compliance with the License. You may obtain a copy of 83*d353a188SXin Lithe License at 84*d353a188SXin Li 85*d353a188SXin Lihttp://www.apache.org/licenses/LICENSE-2.0 86*d353a188SXin Li 87*d353a188SXin LiUnless required by applicable law or agreed to in writing, software 88*d353a188SXin Lidistributed under the License is distributed on an "AS IS" BASIS, WITHOUT 89*d353a188SXin LiWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 90*d353a188SXin LiLicense for the specific language governing permissions and limitations under 91*d353a188SXin Lithe License. 92