1 page.title= Direct Boot 2 page.keywords=preview,sdk,direct boot 3 page.tags=androidn 4 page.image=images/cards/card-nyc_2x.jpg 5 6 @jd:body 7 8 <div id="tb-wrapper"> 9 <div id="tb"> 10 <h2> </h2> 11 <ol> 12 <li><a href="#run"> Direct Boot</a></li> 13 <li><a href="#access"> </a></li> 14 <li><a href="#notification"> </a></li> 15 <li><a href="#migrating"> </a></li> 16 <li><a href="#testing"> </a></li> 17 </ol> 18 </div> 19 </div> 20 21 <p>Android N <i>Direct Boot,</i> 22 , . 23 :</p> 24 25 <ul> 26 <li><i>, .</i> 27 , .</li> 28 <li><i>, .</i> 29 Direct Boot , .</li> 30 </ul> 31 32 <p> Direct Boot . 33 - Direct Boot, 34 , . 35 , Direct Boot:</p> 36 37 <ul> 38 <li> , , 39 .</li> 40 <li>, , , .</li> 41 <li> , , Talkback.</li> 42 </ul> 43 44 <p> Direct Boot, 45 . , 46 , 47 .</p> 48 49 <p> , 50 (, PIN- ), , . 51 52 , . 53 , , 54 , .</p> 55 56 <h2 id="run"> Direct Boot</h2> 57 58 <p> 59 Direct Boot 60 , . , 61 <i> </i>. , 62 <code>android:encryptionAware</code> true.<p> 63 64 <p>, , 65 <code>LOCKED_BOOT_COMPLETED</code> 66 . 67 , 68 Direct Boot, , .</p> 69 70 <p> 71 {@link android.content.BroadcastReceiver} 72 <code>LOCKED_BOOT_COMPLETED</code> :</p> 73 74 <pre> 75 <receiever 76 android:encryptionAware="true" > 77 ... 78 <intent-filter> 79 <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" /> 80 </intent-filter> 81 </receiver> 82 </pre> 83 84 <p> 85 , .</p> 86 87 <h2 id="access"> </h2> 88 89 <p> 90 {@link android.content.Context} 91 <code>Context.createDeviceEncryptedStorageContext()</code>. API 92 . 93 , 94 :</p> 95 96 <pre> 97 Context directBootContext = Context.createDeviceEncryptedStorageContext(); 98 // Access appDataFilename that lives in device encrypted storage 99 FileInputStream inStream = directBootContext.openFileInput(appDataFilename); 100 // Use inStream to read content... 101 </pre> 102 103 <p> 104 , Direct Boot. 105 . 106 , 107 Direct Boot, , .</p> 108 109 <h2 id="notification"> </h2> 110 111 <p> , 112 , , , 113 .</p> 114 115 <p> , 116 {@link android.content.BroadcastReceiver} 117 <code>ACTION_USER_UNLOCKED</code>. 118 {@link android.content.Intent#ACTION_BOOT_COMPLETED 119 ACTION_BOOT_COMPLETED}, , 120 .</p> 121 122 <p> , 123 <code>UserManager.isUserUnlocked()</code>.</p> 124 125 <h2 id="migrating"> </h2> 126 127 <p> Direct Boot, 128 . 129 <code>Context.migrateSharedPreferencesFrom()</code> 130 <code>Context.migrateDatabaseFrom()</code> 131 , , .</p> 132 133 <p> , 134 , , . 135 , 136 . 137 .</p> 138 139 <h2 id="testing"> </h2> 140 141 <p> Direct Boot. 142 Direct Boot.</p> 143 144 <p class="caution"><strong>!</strong> Direct Boot 145 .</p> 146 147 <p> 148 Direct Boot Android N, .</p> 149 150 <ul> 151 <li> <b>Developer options</b>, . 152 <b>Settings>About phone</b> <b>Build number</b>. 153 , 154 <b>Settings>Developer options</b> 155 <b>Convert to file encryption</b>.</li> 156 <li> adb Direct Boot: 157 <pre class="no-pretty-print"> 158 $ adb reboot-bootloader 159 $ fastboot --wipe-and-use-fbe 160 </pre> 161 </li> 162 </ul> 163 164 <p> 165 , Direct Boot. 166 , . Direct Boot, 167 , "No thanks", 168 , 169 adb:</p> 170 171 <pre class="no-pretty-print"> 172 $ adb shell sm set-emulate-fbe true 173 </pre> 174 175 <p> Direct Boot :</p> 176 177 <pre class="no-pretty-print"> 178 $ adb shell sm set-emulate-fbe false 179 </pre> 180 181 <p> .</p> 182