Merge tag 'android-security-10.0.0_r53' into int/10/fp2

Android security 10.0.0 release 53

* tag 'android-security-10.0.0_r53':

Change-Id: Iae9d09d779540e7e6f2297ee72cd68f05e0846ac
diff --git a/Android.bp b/Android.bp
index 764dc49..a05de4d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -39,6 +39,8 @@
     sdk_version: "system_current",
     min_sdk_version: "28",
     target_sdk_version: "28",
+
+    plugins: ["java_api_finder"],
 }
 
 filegroup {
diff --git a/perf-tests/Android.bp b/perf-tests/Android.bp
index 963a6da..e745fdf 100644
--- a/perf-tests/Android.bp
+++ b/perf-tests/Android.bp
@@ -20,6 +20,7 @@
 
     static_libs: [
         "androidx.legacy_legacy-support-v4",
+        "androidx.test.rules",
         "androidx.test.espresso.core",
         "mockito-target",
         "ub-janktesthelper",
diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml
index 383be7c..8b4c135 100644
--- a/res/values-ar/strings.xml
+++ b/res/values-ar/strings.xml
@@ -17,7 +17,7 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="files_label" msgid="771781190045103748">"الملفات"</string>
-    <string name="downloads_label" msgid="5462789470049501103">"التنزيلات"</string>
+    <string name="downloads_label" msgid="5462789470049501103">"عمليات التنزيل"</string>
     <!-- no translation found for app_label (8089292432455111409) -->
     <skip />
     <!-- no translation found for launcher_label (799410258349837668) -->
@@ -35,7 +35,7 @@
     <string name="menu_save" msgid="5195367497138965168">"حفظ"</string>
     <string name="menu_share" msgid="4307140947108068356">"مشاركة"</string>
     <string name="menu_delete" msgid="1022254131543256626">"حذف"</string>
-    <string name="menu_select_all" msgid="7600576812185570403">"تحديد الكل"</string>
+    <string name="menu_select_all" msgid="7600576812185570403">"اختيار الكل"</string>
     <string name="menu_select" msgid="1366061076507142387">"اختيار"</string>
     <string name="menu_sort" msgid="3362419226163725275">"الترتيب حسب..."</string>
     <string name="menu_copy" msgid="7404820171352314754">"نسخ إلى…"</string>
@@ -297,7 +297,7 @@
     <string name="archive_loading_failed" msgid="7243436722828766996">"يتعذر فتح الأرشيف وتصفحه. ربما يكون الملف تالفًا أو بتنسيق غير متوافق."</string>
     <string name="name_conflict" msgid="28407269328862986">"هناك ملف بالاسم نفسه‬."</string>
     <string name="authentication_required" msgid="8030880723643436099">"لعرض هذا الدليل، يُرجى تسجيل الدخول إلى <xliff:g id="NAME">%1$s</xliff:g>"</string>
-    <string name="cant_display_content" msgid="8633226333229417237">"يتعذَّر عرض المحتويات"</string>
+    <string name="cant_display_content" msgid="8633226333229417237">"يتعذَّر عرض المحتوى"</string>
     <string name="sign_in" msgid="6253762676723505592">"تسجيل الدخول"</string>
     <string name="new_archive_file_name" msgid="1604650338077249838">"أرشيف<xliff:g id="EXTENSION">%s</xliff:g>"</string>
     <string name="overwrite_file_confirmation_message" msgid="2496109652768222716">"هل تريد استبدال <xliff:g id="NAME">%1$s</xliff:g>؟"</string>
diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml
index 5cf1d79..1a06fbc 100644
--- a/res/values-da/strings.xml
+++ b/res/values-da/strings.xml
@@ -93,7 +93,7 @@
     <string name="root_type_device" msgid="1713604128005476585">"Enheder"</string>
     <string name="root_type_apps" msgid="8646073235029886342">"Flere apps"</string>
     <string name="empty" msgid="5300254272613103004">"Ingen elementer"</string>
-    <string name="no_results" msgid="2371026325236359209">"Ingen kampe i %1$s"</string>
+    <string name="no_results" msgid="2371026325236359209">"Ingen resultater i %1$s"</string>
     <string name="toast_no_application" msgid="7555319548595113121">"Filen kan ikke åbnes"</string>
     <string name="toast_view_in_archives_unsupported" msgid="1923221390170964845">"Filer i arkiver kan ikke åbnes"</string>
     <string name="toast_failed_delete" msgid="3453846588205817591">"Nogle dokumenter kan ikke slettes"</string>
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index d7043d2..4d991a5 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -174,8 +174,8 @@
       <item quantity="other">Ces fichiers ont été convertis dans un autre format : <xliff:g id="LIST_1">%1$s</xliff:g></item>
     </plurals>
     <plurals name="clipboard_files_clipped" formatted="false" msgid="4847061634862926902">
-      <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> élément a été copié dans le Presse-papiers.</item>
-      <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> éléments ont été copiés dans le Presse-papiers.</item>
+      <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> élément a été copié dans le presse-papiers.</item>
+      <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> éléments ont été copiés dans le presse-papiers.</item>
     </plurals>
     <string name="file_operation_rejected" msgid="4301554203329008794">"Opération relative au fichier non acceptée."</string>
     <string name="file_operation_error" msgid="2234357335716533795">"L\'opération relative au fichier a échoué."</string>
diff --git a/res/values-gl/strings.xml b/res/values-gl/strings.xml
index bfd9648..fa2da0c 100644
--- a/res/values-gl/strings.xml
+++ b/res/values-gl/strings.xml
@@ -28,7 +28,7 @@
     <string name="menu_grid" msgid="1453636521731880680">"Vista de grade"</string>
     <string name="menu_list" msgid="6714267452146410402">"Vista de lista"</string>
     <string name="menu_search" msgid="1876699106790719849">"Buscar"</string>
-    <string name="menu_settings" msgid="6520844520117939047">"Configur. almacenamento"</string>
+    <string name="menu_settings" msgid="6520844520117939047">"Axustes almacenamento"</string>
     <string name="menu_open" msgid="9092138100049759315">"Abrir"</string>
     <string name="menu_open_with" msgid="5507647065467520229">"Abrir con"</string>
     <string name="menu_open_in_new_window" msgid="6686563636123311276">"Abrir nunha ventá nova"</string>
diff --git a/res/values-gu/strings.xml b/res/values-gu/strings.xml
index 8fa1c2d..ead430e 100644
--- a/res/values-gu/strings.xml
+++ b/res/values-gu/strings.xml
@@ -28,7 +28,7 @@
     <string name="menu_grid" msgid="1453636521731880680">"ગ્રિડ દૃશ્ય"</string>
     <string name="menu_list" msgid="6714267452146410402">"સૂચિ દૃશ્ય"</string>
     <string name="menu_search" msgid="1876699106790719849">"શોધો"</string>
-    <string name="menu_settings" msgid="6520844520117939047">"સ્ટોરેજ સેટિંગ્સ"</string>
+    <string name="menu_settings" msgid="6520844520117939047">"સ્ટોરેજ સેટિંગ"</string>
     <string name="menu_open" msgid="9092138100049759315">"ખોલો"</string>
     <string name="menu_open_with" msgid="5507647065467520229">"આની સાથે ખોલો"</string>
     <string name="menu_open_in_new_window" msgid="6686563636123311276">"નવી વિંડોમાં ખોલો"</string>
diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml
index 57bc2e9..75e4a2f 100644
--- a/res/values-hi/strings.xml
+++ b/res/values-hi/strings.xml
@@ -124,7 +124,7 @@
       <item quantity="one"><xliff:g id="COUNT_1">%1$d</xliff:g> आइटम मिटाए जा रहे हैं.</item>
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> आइटम मिटाए जा रहे हैं.</item>
     </plurals>
-    <string name="undo" msgid="2902438994196400565">"पूर्ववत करें"</string>
+    <string name="undo" msgid="2902438994196400565">"पहले जैसा करें"</string>
     <string name="copy_preparing" msgid="4759516490222449324">"तैयार किया जा रहा है..."</string>
     <string name="compress_preparing" msgid="7401605598969019696">"तैयार किया जा रहा है..."</string>
     <string name="extract_preparing" msgid="4796626960061745796">"तैयार किया जा रहा है..."</string>
@@ -242,9 +242,9 @@
     <string name="preview_file" msgid="4056622696305432343">"<xliff:g id="FILENAME">%1$s</xliff:g> फ़ाइल की झलक देखें"</string>
     <string name="apps_row_title" msgid="3340490016663092925">"दूसरे ऐप्लिकेशन में फ़ाइलें ब्राउज़ करें"</string>
     <string name="anonymous_application" msgid="7633027057951625862">"अनाम"</string>
-    <string name="open_tree_button" msgid="19992834788135845">"\"<xliff:g id="DIRECTORY">%1$s</xliff:g>\" एक्सेस करने दें"</string>
-    <string name="open_tree_dialog_title" msgid="8429465292253532274">"\"<xliff:g id="ROOT">%2$s</xliff:g>\" पर \"<xliff:g id="DIRECTORY">%1$s</xliff:g>\" का एक्सेस दें?"</string>
-    <string name="open_tree_dialog_message" msgid="8545093618524340168">"यह \"<xliff:g id="APPNAME">%1$s</xliff:g>\" को इस जगह में इस समय सेव की गई सभी फ़ाइलों और आने वाले समय में यहां सेव की जाने वाली किसी भी सामग्री का पूरा एक्सेस करने देगा."</string>
+    <string name="open_tree_button" msgid="19992834788135845">"\"<xliff:g id="DIRECTORY">%1$s</xliff:g>\" ऐक्सेस करने दें"</string>
+    <string name="open_tree_dialog_title" msgid="8429465292253532274">"\"<xliff:g id="ROOT">%2$s</xliff:g>\" पर \"<xliff:g id="DIRECTORY">%1$s</xliff:g>\" का ऐक्सेस दें?"</string>
+    <string name="open_tree_dialog_message" msgid="8545093618524340168">"यह \"<xliff:g id="APPNAME">%1$s</xliff:g>\" को इस जगह में इस समय सेव की गई सभी फ़ाइलों और आने वाले समय में यहां सेव की जाने वाली किसी भी सामग्री का पूरा ऐक्सेस करने देगा."</string>
     <string name="search_bar_hint" msgid="4517366509897977321">"यह फ़ोन खोजें"</string>
     <string name="delete_search_history" msgid="2202015025607694515">"खोज का इतिहास मिटाएं <xliff:g id="TEXT">%1$s</xliff:g>"</string>
 </resources>
diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml
index 91344cf..f659625 100644
--- a/res/values-in/strings.xml
+++ b/res/values-in/strings.xml
@@ -147,7 +147,7 @@
       <item quantity="other">Tidak dapat menghapus <xliff:g id="COUNT_1">%1$d</xliff:g> item</item>
       <item quantity="one">Tidak dapat menghapus <xliff:g id="COUNT_0">%1$d</xliff:g> item</item>
     </plurals>
-    <string name="notification_touch_for_details" msgid="2385563502445129570">"Tap untuk melihat detail"</string>
+    <string name="notification_touch_for_details" msgid="2385563502445129570">"Ketuk untuk melihat detail"</string>
     <string name="close" msgid="905969391788869975">"Tutup"</string>
     <plurals name="copy_failure_alert_content" formatted="false" msgid="5570549471912990536">
       <item quantity="other">File ini tidak disalin: <xliff:g id="LIST_1">%1$s</xliff:g></item>
diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml
index b805063..5eafbad 100644
--- a/res/values-iw/strings.xml
+++ b/res/values-iw/strings.xml
@@ -22,7 +22,7 @@
     <skip />
     <!-- no translation found for launcher_label (799410258349837668) -->
     <skip />
-    <string name="title_open" msgid="3165686459158020921">"פתח מ-"</string>
+    <string name="title_open" msgid="3165686459158020921">"פתיחה מ-"</string>
     <string name="title_save" msgid="4384490653102710025">"שמור ב-"</string>
     <string name="menu_create_dir" msgid="2413624798689091042">"תיקיה חדשה"</string>
     <string name="menu_grid" msgid="1453636521731880680">"תצוגת רשת"</string>
diff --git a/res/values-ky/strings.xml b/res/values-ky/strings.xml
index 3c51a48..303e5fb 100644
--- a/res/values-ky/strings.xml
+++ b/res/values-ky/strings.xml
@@ -35,7 +35,7 @@
     <string name="menu_save" msgid="5195367497138965168">"Сактоо"</string>
     <string name="menu_share" msgid="4307140947108068356">"Бөлүшүү"</string>
     <string name="menu_delete" msgid="1022254131543256626">"Жок кылуу"</string>
-    <string name="menu_select_all" msgid="7600576812185570403">"Бардыгын тандоо"</string>
+    <string name="menu_select_all" msgid="7600576812185570403">"Баарын тандоо"</string>
     <string name="menu_select" msgid="1366061076507142387">"Тандоо"</string>
     <string name="menu_sort" msgid="3362419226163725275">"Төмөнкү боюнча иреттөө…"</string>
     <string name="menu_copy" msgid="7404820171352314754">"Төмөнкүгө көчүрүү…"</string>
@@ -58,7 +58,7 @@
     <string name="button_extract" msgid="1038674453689912247">"Чыгаруу"</string>
     <string name="button_move" msgid="8596460499325291272">"Жылдыруу"</string>
     <string name="button_dismiss" msgid="7235249361023803349">"Көз жаздымда калтыруу"</string>
-    <string name="button_retry" msgid="4011461781916631389">"Кайра аракет кылыңыз"</string>
+    <string name="button_retry" msgid="4011461781916631389">"Кайталап көрүңүз"</string>
     <string name="button_clear" msgid="5412304437764369441">"Тазалоо"</string>
     <string name="button_show_provider" msgid="6905880493806292753">"Демейки колдонмодон көрсөтүү"</string>
     <string name="not_sorted" msgid="7813496644889115530">"Ылганган эмес"</string>
@@ -147,7 +147,7 @@
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> нерсе жок кылынбай койду</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> нерсе жок кылынбай койду</item>
     </plurals>
-    <string name="notification_touch_for_details" msgid="2385563502445129570">"Чоо-жайын көрүү үчүн таптаңыз"</string>
+    <string name="notification_touch_for_details" msgid="2385563502445129570">"Чоо-жайын билгиңиз келсе, таптаңыз"</string>
     <string name="close" msgid="905969391788869975">"Жабуу"</string>
     <plurals name="copy_failure_alert_content" formatted="false" msgid="5570549471912990536">
       <item quantity="other">Төмөнкү файлдар көчүрүлгөн жок: <xliff:g id="LIST_1">%1$s</xliff:g></item>
@@ -166,8 +166,8 @@
       <item quantity="one">Төмөнкү файл жылдырылган жок: <xliff:g id="LIST_0">%1$s</xliff:g></item>
     </plurals>
     <plurals name="delete_failure_alert_content" formatted="false" msgid="6122372614839711711">
-      <item quantity="other">Төмөнкү файлдар жок кылынган жок: <xliff:g id="LIST_1">%1$s</xliff:g></item>
-      <item quantity="one">Төмөнкү файл жок кылынган жок: <xliff:g id="LIST_0">%1$s</xliff:g></item>
+      <item quantity="other">Төмөнкү файлдар өчкөн жок: <xliff:g id="LIST_1">%1$s</xliff:g></item>
+      <item quantity="one">Төмөнкү файл өчкөн жок: <xliff:g id="LIST_0">%1$s</xliff:g></item>
     </plurals>
     <plurals name="copy_converted_warning_content" formatted="false" msgid="7433742181712126588">
       <item quantity="other">Төмөнкү файлдардын форматы өзгөртүлдү: <xliff:g id="LIST_1">%1$s</xliff:g></item>
@@ -184,9 +184,9 @@
     <string name="notification_copy_files_converted_title" msgid="6916768494891833365">"Айрым файлдардын форматы өзгөртүлдү"</string>
     <string name="open_external_dialog_request" msgid="8173558471322861268">"<xliff:g id="APPNAME"><b>^1</b></xliff:g> колдонмосуна <xliff:g id="STORAGE"><i>^3</i></xliff:g> түзмөгүндөгү <xliff:g id="DIRECTORY"><i>^2</i></xliff:g> папканы пайдалануу мүмкүнчүлүгү берилсинби?"</string>
     <string name="open_external_dialog_request_primary_volume" msgid="2240992164087948176">"<xliff:g id="APPNAME"><b>^1</b></xliff:g> колдонмосуна <xliff:g id="DIRECTORY"><i>^2</i></xliff:g> каталогун пайдалануу мүмкүнчүлүгү берилсинби?"</string>
-    <string name="open_external_dialog_root_request" msgid="6776729293982633">"<xliff:g id="APPNAME"><b>^1</b></xliff:g> колдонмосуна <xliff:g id="STORAGE"><i>^2</i></xliff:g> түзмөгүндөгү дайындарыңыз, сүрөттөрүңүз жана видеолоруңузду пайдалануу мүмкүнчүлүгү берилсинби?"</string>
+    <string name="open_external_dialog_root_request" msgid="6776729293982633">"<xliff:g id="APPNAME"><b>^1</b></xliff:g> колдонмосуна <xliff:g id="STORAGE"><i>^2</i></xliff:g> түзмөгүндөгү дайын-даректериңиз, сүрөттөрүңүз жана видеолоруңузду пайдалануу мүмкүнчүлүгү берилсинби?"</string>
     <string name="allow" msgid="1275746941353040309">"Уруксат берүү"</string>
-    <string name="deny" msgid="5127201668078153379">"Жок"</string>
+    <string name="deny" msgid="5127201668078153379">"Тыюу салынат"</string>
     <plurals name="elements_selected" formatted="false" msgid="4448165978637163692">
       <item quantity="other"><xliff:g id="COUNT_1">%1$d</xliff:g> тандалды</item>
       <item quantity="one"><xliff:g id="COUNT_0">%1$d</xliff:g> тандалды</item>
diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml
index d188830..26c0068 100644
--- a/res/values-pl/strings.xml
+++ b/res/values-pl/strings.xml
@@ -57,7 +57,7 @@
     <string name="button_compress" msgid="8951561310857223966">"Skompresuj"</string>
     <string name="button_extract" msgid="1038674453689912247">"Rozpakuj"</string>
     <string name="button_move" msgid="8596460499325291272">"Przenieś"</string>
-    <string name="button_dismiss" msgid="7235249361023803349">"Odrzuć"</string>
+    <string name="button_dismiss" msgid="7235249361023803349">"Zamknij"</string>
     <string name="button_retry" msgid="4011461781916631389">"Spróbuj jeszcze raz"</string>
     <string name="button_clear" msgid="5412304437764369441">"Zrezygnuj"</string>
     <string name="button_show_provider" msgid="6905880493806292753">"Pokaż w usłudze"</string>
diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml
index 784fc1d..2e5f622 100644
--- a/res/values-pt-rPT/strings.xml
+++ b/res/values-pt-rPT/strings.xml
@@ -236,7 +236,7 @@
     <string name="chip_title_images" msgid="7838299046109841015">"Imagens"</string>
     <string name="chip_title_audio" msgid="1032801828748235436">"Áudio"</string>
     <string name="chip_title_videos" msgid="7011260091979776447">"Vídeos"</string>
-    <string name="chip_title_documents" msgid="7432457563000753983">"Documentos"</string>
+    <string name="chip_title_documents" msgid="7432457563000753983">"Docs"</string>
     <string name="input_hint_new_folder" msgid="479672411219725677">"Nome da pasta"</string>
     <string name="input_hint_rename" msgid="8390711744270994452">"Novo nome"</string>
     <string name="preview_file" msgid="4056622696305432343">"Pré-visualizar o ficheiro <xliff:g id="FILENAME">%1$s</xliff:g>"</string>
diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml
index 7e84f4c..46cdb07 100644
--- a/res/values-sw/strings.xml
+++ b/res/values-sw/strings.xml
@@ -94,7 +94,7 @@
     <string name="root_type_apps" msgid="8646073235029886342">"Programu zaidi"</string>
     <string name="empty" msgid="5300254272613103004">"Hakuna chochote"</string>
     <string name="no_results" msgid="2371026325236359209">"Hakuna zinazolingana katika %1$s"</string>
-    <string name="toast_no_application" msgid="7555319548595113121">"Haiwezi kufungua faili"</string>
+    <string name="toast_no_application" msgid="7555319548595113121">"Imeshindwa kufungua faili"</string>
     <string name="toast_view_in_archives_unsupported" msgid="1923221390170964845">"Haiwezi kufungua faili zilizo kwenye kumbukumbu"</string>
     <string name="toast_failed_delete" msgid="3453846588205817591">"Imeshindwa kufuta baadhi ya hati"</string>
     <string name="share_via" msgid="8725082736005677161">"Shiriki kupitia"</string>
diff --git a/res/values-ta/strings.xml b/res/values-ta/strings.xml
index e492436..b5e146e 100644
--- a/res/values-ta/strings.xml
+++ b/res/values-ta/strings.xml
@@ -91,7 +91,7 @@
     <string name="root_type_service" msgid="6521366147466512289">"சேமிப்பகச் சேவைகள்"</string>
     <string name="root_type_shortcut" msgid="6059343175525442279">"ஷார்ட்கட்கள்"</string>
     <string name="root_type_device" msgid="1713604128005476585">"சாதனங்கள்"</string>
-    <string name="root_type_apps" msgid="8646073235029886342">"மேலும் பயன்பாடுகள்"</string>
+    <string name="root_type_apps" msgid="8646073235029886342">"மேலும் ஆப்ஸ்"</string>
     <string name="empty" msgid="5300254272613103004">"எதுவும் இல்லை"</string>
     <string name="no_results" msgid="2371026325236359209">"%1$s இல் பொருந்தும் முடிவு இல்லை"</string>
     <string name="toast_no_application" msgid="7555319548595113121">"கோப்பைத் திறக்க முடியாது"</string>
diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml
index 8123daf..8682f7b 100644
--- a/res/values-vi/strings.xml
+++ b/res/values-vi/strings.xml
@@ -17,7 +17,7 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="files_label" msgid="771781190045103748">"Tệp"</string>
-    <string name="downloads_label" msgid="5462789470049501103">"Nội dung tải xuống"</string>
+    <string name="downloads_label" msgid="5462789470049501103">"Tệp đã tải xuống"</string>
     <!-- no translation found for app_label (8089292432455111409) -->
     <skip />
     <!-- no translation found for launcher_label (799410258349837668) -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 10f9b05..2409ed6 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -91,8 +91,14 @@
         <item name="buttonBarNegativeButtonStyle">@style/DialogTextButton</item>
     </style>
 
+    <style name="MaterialAlertDialogStyle" parent="@style/MaterialAlertDialog.MaterialComponents">
+        <item name="backgroundInsetTop">12dp</item>
+        <item name="backgroundInsetBottom">12dp</item>
+    </style>
+
     <style name="MaterialAlertDialogTheme" parent="@style/ThemeOverlay.MaterialComponents.MaterialAlertDialog.Centered">
         <item name="android:dialogCornerRadius">@dimen/grid_item_radius</item>
+        <item name="alertDialogStyle">@style/MaterialAlertDialogStyle</item>
         <item name="buttonBarPositiveButtonStyle">@style/DialogTextButton</item>
         <item name="buttonBarNegativeButtonStyle">@style/DialogTextButton</item>
         <item name="materialAlertDialogTitleTextStyle">@style/MaterialAlertDialogTitleStyle</item>
diff --git a/src/com/android/documentsui/AbstractActionHandler.java b/src/com/android/documentsui/AbstractActionHandler.java
index 423565d..824d209 100644
--- a/src/com/android/documentsui/AbstractActionHandler.java
+++ b/src/com/android/documentsui/AbstractActionHandler.java
@@ -576,11 +576,15 @@
             Context context = mActivity;
 
             if (mState.stack.isRecents()) {
+                final LockingContentObserver observer = new LockingContentObserver(
+                        mContentLock, AbstractActionHandler.this::loadDocumentsForCurrentStack);
+                MultiRootDocumentsLoader loader;
+
                 if (mSearchMgr.isSearching()) {
                     if (DEBUG) {
                         Log.d(TAG, "Creating new GlobalSearchLoader.");
                     }
-                    return new GlobalSearchLoader(
+                    loader = new GlobalSearchLoader(
                             context,
                             mProviders,
                             mState,
@@ -591,13 +595,15 @@
                     if (DEBUG) {
                         Log.d(TAG, "Creating new loader recents.");
                     }
-                    return new RecentsLoader(
+                    loader =  new RecentsLoader(
                             context,
                             mProviders,
                             mState,
                             mExecutors,
                             mInjector.fileTypeLookup);
                 }
+                loader.setObserver(observer);
+                return loader;
             } else {
                 Uri contentsUri = mSearchMgr.isSearching()
                         ? DocumentsContract.buildSearchDocumentsUri(
diff --git a/src/com/android/documentsui/CreateDirectoryFragment.java b/src/com/android/documentsui/CreateDirectoryFragment.java
index 756b555..dcaa87a 100644
--- a/src/com/android/documentsui/CreateDirectoryFragment.java
+++ b/src/com/android/documentsui/CreateDirectoryFragment.java
@@ -68,7 +68,6 @@
     @Override
     public Dialog onCreateDialog(Bundle savedInstanceState) {
         final Context context = getActivity();
-        final ContentResolver resolver = context.getContentResolver();
 
         final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context);
         final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
diff --git a/src/com/android/documentsui/DirectoryLoader.java b/src/com/android/documentsui/DirectoryLoader.java
index d65b4c3..63c3bf6 100644
--- a/src/com/android/documentsui/DirectoryLoader.java
+++ b/src/com/android/documentsui/DirectoryLoader.java
@@ -16,20 +16,16 @@
 
 package com.android.documentsui;
 
-import static com.android.documentsui.base.SharedMinimal.DEBUG;
 import static com.android.documentsui.base.SharedMinimal.VERBOSE;
 
 import android.content.ContentProviderClient;
 import android.content.ContentResolver;
 import android.content.Context;
-import android.database.ContentObserver;
 import android.database.Cursor;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.CancellationSignal;
 import android.os.FileUtils;
-import android.os.Handler;
-import android.os.Looper;
 import android.os.OperationCanceledException;
 import android.os.RemoteException;
 import android.provider.DocumentsContract.Document;
@@ -241,28 +237,4 @@
 
         getContext().getContentResolver().unregisterContentObserver(mObserver);
     }
-
-    private static final class LockingContentObserver extends ContentObserver {
-        private final ContentLock mLock;
-        private final Runnable mContentChangedCallback;
-
-        public LockingContentObserver(ContentLock lock, Runnable contentChangedCallback) {
-            super(new Handler(Looper.getMainLooper()));
-            mLock = lock;
-            mContentChangedCallback = contentChangedCallback;
-        }
-
-        @Override
-        public boolean deliverSelfNotifications() {
-            return true;
-        }
-
-        @Override
-        public void onChange(boolean selfChange) {
-            if (DEBUG) {
-                Log.d(TAG, "Directory content updated.");
-            }
-            mLock.runWhenUnlocked(mContentChangedCallback);
-        }
-    }
 }
diff --git a/src/com/android/documentsui/LockingContentObserver.java b/src/com/android/documentsui/LockingContentObserver.java
new file mode 100644
index 0000000..bbd7a98
--- /dev/null
+++ b/src/com/android/documentsui/LockingContentObserver.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.documentsui;
+
+import static com.android.documentsui.base.SharedMinimal.DEBUG;
+import static com.android.documentsui.base.SharedMinimal.TAG;
+
+import android.database.ContentObserver;
+import android.os.Handler;
+import android.os.Looper;
+import android.util.Log;
+
+/**
+ * A custom {@link ContentObserver} which constructed by a {@link ContentLock}
+ * and a {@link Runnable} callback. It will callback when it's onChange and ContentLock is unlock.
+ */
+public final class LockingContentObserver extends ContentObserver {
+    private final ContentLock mLock;
+    private final Runnable mContentChangedCallback;
+
+    public LockingContentObserver(ContentLock lock, Runnable contentChangedCallback) {
+        super(new Handler(Looper.getMainLooper()));
+        mLock = lock;
+        mContentChangedCallback = contentChangedCallback;
+    }
+
+    @Override
+    public boolean deliverSelfNotifications() {
+        return true;
+    }
+
+    @Override
+    public void onChange(boolean selfChange) {
+        if (DEBUG) {
+            Log.d(TAG, "Content updated.");
+        }
+        mLock.runWhenUnlocked(mContentChangedCallback);
+    }
+}
diff --git a/src/com/android/documentsui/MultiRootDocumentsLoader.java b/src/com/android/documentsui/MultiRootDocumentsLoader.java
index 777efe0..11208c1 100644
--- a/src/com/android/documentsui/MultiRootDocumentsLoader.java
+++ b/src/com/android/documentsui/MultiRootDocumentsLoader.java
@@ -17,7 +17,6 @@
 package com.android.documentsui;
 
 import static com.android.documentsui.base.SharedMinimal.DEBUG;
-import static com.android.documentsui.base.SharedMinimal.TAG;
 
 import android.app.ActivityManager;
 import android.content.ContentProviderClient;
@@ -65,6 +64,9 @@
  * and return the combined result.
  */
 public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<DirectoryResult> {
+
+    private static final String TAG = "MultiRootDocsLoader";
+
     // TODO: clean up cursor ownership so background thread doesn't traverse
     // previously returned cursors for filtering/sorting; this currently races
     // with the UI thread.
@@ -83,6 +85,7 @@
     private final ProvidersAccess mProviders;
     private final Lookup<String, Executor> mExecutors;
     private final Lookup<String, String> mFileTypeMap;
+    private LockingContentObserver mObserver;
 
     @GuardedBy("mTasks")
     /** A authority -> QueryTask map */
@@ -101,6 +104,8 @@
      * @param state current state
      * @param executors the executors of authorities
      * @param fileTypeMap the map of mime types and file types.
+     * @param lock the selection lock
+     * @param contentChangedCallback callback when content changed
      */
     public MultiRootDocumentsLoader(Context context, ProvidersAccess providers, State state,
             Lookup<String, Executor> executors, Lookup<String, String> fileTypeMap) {
@@ -126,6 +131,10 @@
         }
     }
 
+    public void setObserver(LockingContentObserver observer) {
+        mObserver = observer;
+    }
+
     private DirectoryResult loadInBackgroundLocked() {
         if (mFirstPassLatch == null) {
             // First time through we kick off all the recent tasks, and wait
@@ -322,6 +331,10 @@
 
         FileUtils.closeQuietly(mResult);
         mResult = null;
+
+        if (mObserver != null) {
+            getContext().getContentResolver().unregisterContentObserver(mObserver);
+        }
     }
 
     // TODO: create better transfer of ownership around cursor to ensure its
@@ -406,6 +419,9 @@
                         mState.sortModel.addQuerySortArgs(queryArgs);
                         addQueryArgs(queryArgs);
                         res[i] = client.query(uri, null, queryArgs, null);
+                        if (mObserver != null) {
+                            res[i].registerContentObserver(mObserver);
+                        }
                         mCursors[i] = generateResultCursor(rootInfos.get(i), res[i]);
                     } catch (Exception e) {
                         Log.w(TAG, "Failed to load " + authority + ", " + rootInfos.get(i).rootId,
diff --git a/src/com/android/documentsui/files/ActionHandler.java b/src/com/android/documentsui/files/ActionHandler.java
index 4d4f082..06d3671 100644
--- a/src/com/android/documentsui/files/ActionHandler.java
+++ b/src/com/android/documentsui/files/ActionHandler.java
@@ -701,19 +701,18 @@
         // treatment, thusly the "isDownloads" check.
 
         // Launch MANAGE_DOCUMENTS only for the root level files, so it's not called for
-        // files in archives. Also, if the activity is already browsing a ZIP from downloads,
-        // then skip MANAGE_DOCUMENTS.
+        // files in archives or in child folders. Also, if the activity is already browsing
+        // a ZIP from downloads, then skip MANAGE_DOCUMENTS.
         if (Intent.ACTION_VIEW.equals(mActivity.getIntent().getAction())
                 && mState.stack.size() > 1) {
             // viewing the contents of an archive.
             return false;
         }
 
-        // management is only supported in downloads.
-        if (mActivity.getCurrentRoot().isDownloads()) {
-            // and only and only on APKs or partial files.
-            return MimeTypes.isApkType(doc.mimeType)
-                    || doc.isPartial();
+        // management is only supported in Downloads root or downloaded files show in Recent root.
+        if (Providers.AUTHORITY_DOWNLOADS.equals(doc.authority)) {
+            // only on APKs or partial files.
+            return MimeTypes.isApkType(doc.mimeType) || doc.isPartial();
         }
 
         return false;
diff --git a/tests/Android.bp b/tests/Android.bp
index 92c578d..15aac38 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -87,6 +87,7 @@
 
     test_suites: [
         "device-tests",
+        "mts",
     ],
 
     platform_apis: true,
diff --git a/tests/AndroidTest.xml b/tests/AndroidTest.xml
index 7893150..7874118 100644
--- a/tests/AndroidTest.xml
+++ b/tests/AndroidTest.xml
@@ -14,7 +14,7 @@
      limitations under the License.
 -->
 <configuration description="Runs Tests for DocumentsUI.">
-    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="test-file-name" value="DocumentsUITests.apk" />
     </target_preparer>
 
diff --git a/tests/common/com/android/documentsui/DialogFragmentTest.java b/tests/common/com/android/documentsui/DialogFragmentTest.java
new file mode 100644
index 0000000..05ad5fb
--- /dev/null
+++ b/tests/common/com/android/documentsui/DialogFragmentTest.java
@@ -0,0 +1,320 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.documentsui;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import android.app.Activity;
+import android.app.Instrumentation;
+import android.app.UiAutomation;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.graphics.Paint;
+import android.os.Build;
+import android.os.ParcelFileDescriptor;
+
+import androidx.fragment.app.FragmentManager;
+import androidx.test.filters.MediumTest;
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.rule.ActivityTestRule;
+import androidx.test.runner.AndroidJUnit4;
+
+import com.android.documentsui.files.FilesActivity;
+
+import com.google.android.material.textfield.TextInputEditText;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+
+@MediumTest
+@RunWith(AndroidJUnit4.class)
+public class DialogFragmentTest {
+
+    private static final String CREATE_FRAGEMENT_TAG = "create_directory";
+    CreateDirectoryFragment mCreateDirectoryFragment;
+    FragmentManager mFragmentManager;
+    ScreenDensitySession mScreenDensitySession;
+    Intent mFileActivityIntent;
+
+    @Rule
+    public ActivityTestRule<FilesActivity> mActivityTestRule = new ActivityTestRule<>(
+            FilesActivity.class);
+
+    @Before
+    public void setup() {
+        mFileActivityIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
+        mFragmentManager = mActivityTestRule.getActivity().getSupportFragmentManager();
+        mScreenDensitySession = new ScreenDensitySession();
+    }
+
+    @After
+    public void tearDown() {
+        mScreenDensitySession.close();
+        mCreateDirectoryFragment = null;
+    }
+
+    @Test
+    public void testCreateDialogShows() throws Throwable {
+        mActivityTestRule.runOnUiThread(() -> CreateDirectoryFragment.show(mFragmentManager));
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+        mCreateDirectoryFragment =
+                (CreateDirectoryFragment) mFragmentManager.findFragmentByTag(CREATE_FRAGEMENT_TAG);
+
+        assertNotNull("Dialog was null", mCreateDirectoryFragment.getDialog());
+        assertTrue("Dialog was not being shown", mCreateDirectoryFragment.getDialog().isShowing());
+    }
+
+    @Test
+    public void testCreateDialogShowsDismiss() throws Throwable {
+        mActivityTestRule.runOnUiThread(() -> CreateDirectoryFragment.show(mFragmentManager));
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+        mCreateDirectoryFragment =
+                (CreateDirectoryFragment) mFragmentManager.findFragmentByTag(CREATE_FRAGEMENT_TAG);
+
+        assertNotNull("Dialog was null", mCreateDirectoryFragment.getDialog());
+        assertTrue("Dialog was not being shown", mCreateDirectoryFragment.getDialog().isShowing());
+
+        mActivityTestRule.runOnUiThread(() -> mCreateDirectoryFragment.dismiss());
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+        assertNull("Dialog should be null after dismiss()", mCreateDirectoryFragment.getDialog());
+    }
+
+    @Test
+    public void testCreateDialogShows_textInputEditText_shouldNotTruncateOnPortrait()
+            throws Throwable {
+        mActivityTestRule.runOnUiThread(() -> CreateDirectoryFragment.show(mFragmentManager));
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+        mCreateDirectoryFragment =
+                (CreateDirectoryFragment) mFragmentManager.findFragmentByTag(CREATE_FRAGEMENT_TAG);
+
+        final TextInputEditText inputView =
+                mCreateDirectoryFragment.getDialog().findViewById(android.R.id.text1);
+
+        assertTrue(inputView.getHeight() > getInputTextHeight(inputView));
+    }
+
+    @Test
+    public void testCreateDialog_textInputEditText_shouldNotTruncateOnLargeDensity()
+            throws Throwable {
+
+        mScreenDensitySession.setLargeDensity();
+        mActivityTestRule.finishActivity();
+        mActivityTestRule.launchActivity(mFileActivityIntent);
+        mFragmentManager = mActivityTestRule.getActivity().getSupportFragmentManager();
+
+        mActivityTestRule.runOnUiThread(() -> CreateDirectoryFragment.show(mFragmentManager));
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+        mCreateDirectoryFragment =
+                (CreateDirectoryFragment) mFragmentManager.findFragmentByTag(CREATE_FRAGEMENT_TAG);
+
+        final TextInputEditText inputView =
+                mCreateDirectoryFragment.getDialog().getWindow().findViewById(android.R.id.text1);
+
+        assertTrue(inputView.getHeight() > getInputTextHeight(inputView));
+
+    }
+
+    @Test
+    public void testCreateDialog_textInputEditText_shouldNotTruncateOnLargerDensity()
+            throws Throwable {
+
+        mScreenDensitySession.setLargerDensity();
+        mActivityTestRule.finishActivity();
+        mActivityTestRule.launchActivity(mFileActivityIntent);
+        mFragmentManager = mActivityTestRule.getActivity().getSupportFragmentManager();
+
+        mActivityTestRule.runOnUiThread(() -> CreateDirectoryFragment.show(mFragmentManager));
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+        mCreateDirectoryFragment =
+                (CreateDirectoryFragment) mFragmentManager.findFragmentByTag(CREATE_FRAGEMENT_TAG);
+
+        final TextInputEditText inputView =
+                mCreateDirectoryFragment.getDialog().getWindow().findViewById(android.R.id.text1);
+
+        assertTrue(inputView.getHeight() > getInputTextHeight(inputView));
+    }
+
+    @Test
+    public void testCreateDialog_textInputEditText_shouldNotTruncateOnLargestDensity()
+            throws Throwable {
+
+        mScreenDensitySession.setLargestDensity();
+        mActivityTestRule.finishActivity();
+        mActivityTestRule.launchActivity(mFileActivityIntent);
+        mFragmentManager = mActivityTestRule.getActivity().getSupportFragmentManager();
+
+        mActivityTestRule.runOnUiThread(() -> CreateDirectoryFragment.show(mFragmentManager));
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+        mCreateDirectoryFragment =
+                (CreateDirectoryFragment) mFragmentManager.findFragmentByTag(CREATE_FRAGEMENT_TAG);
+
+        final TextInputEditText inputView =
+                mCreateDirectoryFragment.getDialog().getWindow().findViewById(android.R.id.text1);
+
+        assertTrue(inputView.getHeight() > getInputTextHeight(inputView));
+    }
+
+    @Test
+    public void testCreateDirectoryFragmentShows_textInputEditText_shouldNotTruncateOnLandscape()
+            throws Throwable {
+        switchOrientation(mActivityTestRule.getActivity());
+        mScreenDensitySession.setLargestDensity();
+        mActivityTestRule.finishActivity();
+        mActivityTestRule.launchActivity(mFileActivityIntent);
+        mFragmentManager = mActivityTestRule.getActivity().getSupportFragmentManager();
+
+        mActivityTestRule.runOnUiThread(() -> CreateDirectoryFragment.show(mFragmentManager));
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+        mCreateDirectoryFragment =
+                (CreateDirectoryFragment) mFragmentManager.findFragmentByTag(CREATE_FRAGEMENT_TAG);
+
+        final TextInputEditText inputView =
+                mCreateDirectoryFragment.getDialog().getWindow().findViewById(android.R.id.text1);
+        Paint paint = inputView.getPaint();
+        final float textSize = paint.getTextSize();
+
+        assertTrue(inputView.getHeight() > Math.round(textSize));
+
+        switchOrientation(mActivityTestRule.getActivity());
+    }
+
+    private static int getInputTextHeight(TextInputEditText v) {
+        Paint paint = v.getPaint();
+        final float textSize = paint.getTextSize();
+        final float textSpace = paint.getFontSpacing();
+        return Math.round(textSize + textSpace);
+    }
+
+    private static void switchOrientation(final Activity activity) {
+        final int[] orientations = getOrientations(activity);
+        activity.setRequestedOrientation(orientations[1]);
+    }
+
+    private static int[] getOrientations(final Activity activity) {
+        final int originalOrientation = activity.getResources().getConfiguration().orientation;
+        final int newOrientation = originalOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+                ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
+                : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
+        return new int[]{originalOrientation, newOrientation};
+    }
+
+    private static class ScreenDensitySession implements AutoCloseable {
+        private static final String DENSITY_PROP_DEVICE = "ro.sf.lcd_density";
+        private static final String DENSITY_PROP_EMULATOR = "qemu.sf.lcd_density";
+
+        private static final float DENSITY_DEFAULT = 1f;
+        private static final float DENSITY_LARGE = 1.09f;
+        private static final float DENSITY_LARGER = 1.19f;
+        private static final float DENSITY_LARGEST = 1.29f;
+
+        void setDefaultDensity() {
+            final int stableDensity = getStableDensity();
+            final int targetDensity = (int) (stableDensity * DENSITY_DEFAULT);
+            setDensity(targetDensity);
+        }
+
+        void setLargeDensity() {
+            final int stableDensity = getStableDensity();
+            final int targetDensity = (int) (stableDensity * DENSITY_LARGE);
+            setDensity(targetDensity);
+        }
+
+        void setLargerDensity() {
+            final int stableDensity = getStableDensity();
+            final int targetDensity = (int) (stableDensity * DENSITY_LARGER);
+            setDensity(targetDensity);
+        }
+
+        void setLargestDensity() {
+            final int stableDensity = getStableDensity();
+            final int targetDensity = (int) (stableDensity * DENSITY_LARGEST);
+            setDensity(targetDensity);
+        }
+
+        @Override
+        public void close() {
+            resetDensity();
+        }
+
+        private int getStableDensity() {
+            final String densityProp;
+            if (Build.IS_EMULATOR) {
+                densityProp = DENSITY_PROP_EMULATOR;
+            } else {
+                densityProp = DENSITY_PROP_DEVICE;
+            }
+
+            return Integer.parseInt(executeShellCommand("getprop " + densityProp).trim());
+        }
+
+        private void setDensity(int targetDensity) {
+            executeShellCommand("wm density " + targetDensity);
+
+            // Verify that the density is changed.
+            final String output = executeShellCommand("wm density");
+            final boolean success = output.contains("Override density: " + targetDensity);
+
+            assertTrue("Failed to set density to " + targetDensity, success);
+        }
+
+        private void resetDensity() {
+            executeShellCommand("wm density reset");
+        }
+    }
+
+    public static String executeShellCommand(String cmd) {
+        try {
+            return runShellCommand(InstrumentationRegistry.getInstrumentation(), cmd);
+        } catch (IOException e) {
+            fail("Failed reading command output: " + e);
+            return "";
+        }
+    }
+
+    public static String runShellCommand(Instrumentation instrumentation, String cmd)
+            throws IOException {
+        return runShellCommand(instrumentation.getUiAutomation(), cmd);
+    }
+
+    public static String runShellCommand(UiAutomation automation, String cmd)
+            throws IOException {
+        if (cmd.startsWith("pm grant ") || cmd.startsWith("pm revoke ")) {
+            throw new UnsupportedOperationException("Use UiAutomation.grantRuntimePermission() "
+                    + "or revokeRuntimePermission() directly, which are more robust.");
+        }
+        ParcelFileDescriptor pfd = automation.executeShellCommand(cmd);
+        byte[] buf = new byte[512];
+        int bytesRead;
+        FileInputStream fis = new ParcelFileDescriptor.AutoCloseInputStream(pfd);
+        StringBuffer stdout = new StringBuffer();
+        while ((bytesRead = fis.read(buf)) != -1) {
+            stdout.append(new String(buf, 0, bytesRead));
+        }
+        fis.close();
+        return stdout.toString();
+    }
+}
diff --git a/tests/common/com/android/documentsui/DocumentsProviderHelper.java b/tests/common/com/android/documentsui/DocumentsProviderHelper.java
index e7a590e..45bc5c0 100644
--- a/tests/common/com/android/documentsui/DocumentsProviderHelper.java
+++ b/tests/common/com/android/documentsui/DocumentsProviderHelper.java
@@ -20,8 +20,11 @@
 import static android.provider.DocumentsContract.buildChildDocumentsUri;
 import static android.provider.DocumentsContract.buildDocumentUri;
 import static android.provider.DocumentsContract.buildRootsUri;
-import static com.android.documentsui.base.DocumentInfo.getCursorString;
+
 import static androidx.core.util.Preconditions.checkArgument;
+
+import static com.android.documentsui.base.DocumentInfo.getCursorString;
+
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.fail;
@@ -30,6 +33,7 @@
 import android.database.Cursor;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.FileUtils;
 import android.os.ParcelFileDescriptor;
 import android.os.ParcelFileDescriptor.AutoCloseInputStream;
 import android.os.ParcelFileDescriptor.AutoCloseOutputStream;
@@ -37,23 +41,22 @@
 import android.provider.DocumentsContract;
 import android.provider.DocumentsContract.Document;
 import android.provider.DocumentsContract.Root;
-import androidx.annotation.Nullable;
 import android.test.MoreAsserts;
 import android.text.TextUtils;
 
+import androidx.annotation.Nullable;
+
 import com.android.documentsui.base.DocumentInfo;
 import com.android.documentsui.base.RootInfo;
 import com.android.documentsui.roots.RootCursorWrapper;
 
-import android.os.FileUtils;
-import libcore.io.Streams;
-
 import com.google.common.collect.Lists;
 
+import libcore.io.Streams;
+
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -147,11 +150,11 @@
         waitForWrite();
     }
 
-    public void writeAppendDocument(Uri documentUri, byte[] contents)
+    public void writeAppendDocument(Uri documentUri, byte[] contents, int length)
             throws RemoteException, IOException {
         ParcelFileDescriptor file = mClient.openFile(documentUri, "wa", null);
         try (AutoCloseOutputStream out = new AutoCloseOutputStream(file)) {
-            out.write(contents);
+            out.write(contents, 0, length);
         }
         waitForWrite();
     }
diff --git a/tests/common/com/android/documentsui/testing/TestCursor.java b/tests/common/com/android/documentsui/testing/TestCursor.java
new file mode 100644
index 0000000..56f4269
--- /dev/null
+++ b/tests/common/com/android/documentsui/testing/TestCursor.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.documentsui.testing;
+
+import android.database.MatrixCursor;
+
+public class TestCursor extends MatrixCursor {
+
+    public TestCursor(String[] columnNames) {
+        super(columnNames);
+    }
+
+    public void mockOnChange() {
+        onChange(false);
+    }
+}
diff --git a/tests/common/com/android/documentsui/testing/TestDocumentsProvider.java b/tests/common/com/android/documentsui/testing/TestDocumentsProvider.java
index 794d1c9..3e4dffd 100644
--- a/tests/common/com/android/documentsui/testing/TestDocumentsProvider.java
+++ b/tests/common/com/android/documentsui/testing/TestDocumentsProvider.java
@@ -117,7 +117,7 @@
     }
 
     private Cursor createDocumentsCursor(DocumentInfo... docs) {
-        MatrixCursor cursor = new MatrixCursor(DOCUMENTS_PROJECTION);
+        TestCursor cursor = new TestCursor(DOCUMENTS_PROJECTION);
         for (DocumentInfo doc : docs) {
             cursor.newRow()
                     .add(Document.COLUMN_DOCUMENT_ID, doc.documentId)
diff --git a/tests/functional/com/android/documentsui/ActivityTest.java b/tests/functional/com/android/documentsui/ActivityTest.java
index 18b1e2f..777992a 100644
--- a/tests/functional/com/android/documentsui/ActivityTest.java
+++ b/tests/functional/com/android/documentsui/ActivityTest.java
@@ -37,7 +37,7 @@
 import com.android.documentsui.base.Features;
 import com.android.documentsui.base.RootInfo;
 import com.android.documentsui.bots.Bots;
-import com.android.documentsui.bots.UiBot;
+import com.android.documentsui.files.FilesActivity;
 
 import javax.annotation.Nullable;
 
@@ -145,8 +145,7 @@
     }
 
     protected void launchActivity() {
-        final Intent intent = context.getPackageManager().getLaunchIntentForPackage(
-                UiBot.targetPackageName);
+        final Intent intent = new Intent(context, FilesActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
         if (getInitialRoot() != null) {
             intent.setAction(Intent.ACTION_VIEW);
diff --git a/tests/functional/com/android/documentsui/CancelFromNotificationUiTest.java b/tests/functional/com/android/documentsui/CancelFromNotificationUiTest.java
index 5deb6b7..1c125c9 100644
--- a/tests/functional/com/android/documentsui/CancelFromNotificationUiTest.java
+++ b/tests/functional/com/android/documentsui/CancelFromNotificationUiTest.java
@@ -138,7 +138,7 @@
         for (int i = 0; i < 49; i++) {
             dummyByte = null;
             dummyByte = new byte[BUFFER_SIZE];
-            mDocsHelper.writeAppendDocument(uri, dummyByte);
+            mDocsHelper.writeAppendDocument(uri, dummyByte, dummyByte.length);
         }
     }
 
diff --git a/tests/functional/com/android/documentsui/FileCopyUiTest.java b/tests/functional/com/android/documentsui/FileCopyUiTest.java
index 666441a..2dd2742 100644
--- a/tests/functional/com/android/documentsui/FileCopyUiTest.java
+++ b/tests/functional/com/android/documentsui/FileCopyUiTest.java
@@ -26,7 +26,6 @@
 import android.content.IntentFilter;
 import android.content.res.Resources;
 import android.net.Uri;
-import android.os.Build;
 import android.os.Bundle;
 import android.os.RemoteException;
 import android.os.SystemClock;
@@ -61,7 +60,7 @@
 
     private static final String TARGET_FOLDER = "test_folder";
 
-    private static final int TARGET_COUNT = 1000;
+    private static final int TARGET_COUNT = 100;
 
     private static final int WAIT_TIME_SECONDS = 180;
 
@@ -78,7 +77,9 @@
                     mErrorReason = intent.getStringExtra(
                             TestNotificationService.EXTRA_ERROR_REASON);
                 }
-                mCountDownLatch.countDown();
+                if (mCountDownLatch != null) {
+                    mCountDownLatch.countDown();
+                }
             }
         }
     };
@@ -101,6 +102,8 @@
 
     private int mPreTestStayAwakeValue;
 
+    private String mDeviceLabel;
+
     public FileCopyUiTest() {
         super(FilesActivity.class);
     }
@@ -124,6 +127,11 @@
                 Settings.Global.STAY_ON_WHILE_PLUGGED_IN);
         device.executeShellCommand("settings put global stay_on_while_plugged_in 3");
 
+        mDeviceLabel = Settings.Global.getString(context.getContentResolver(),
+                Settings.Global.DEVICE_NAME);
+        // If null or empty, use default name.
+        mDeviceLabel = TextUtils.isEmpty(mDeviceLabel) ? "Internal Storage" : mDeviceLabel;
+
         // If Internal Storage is not shown, turn on.
         State state = ((FilesActivity) getActivity()).getDisplayState();
         if (!state.showAdvanced) {
@@ -137,12 +145,6 @@
             Log.d(TAG, "Cannot set notification access. ", e);
         }
 
-        IntentFilter filter = new IntentFilter();
-        filter.addAction(TestNotificationService.ACTION_OPERATION_RESULT);
-        context.registerReceiver(mReceiver, filter);
-        context.sendBroadcast(new Intent(
-                TestNotificationService.ACTION_CHANGE_EXECUTION_MODE));
-
         mOperationExecuted = false;
         mErrorReason = "No response from Notification";
 
@@ -156,12 +158,18 @@
             // Call initStorageRootInfo() again for setting SD Card root
             initStorageRootInfo();
         }
+
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(TestNotificationService.ACTION_OPERATION_RESULT);
+        context.registerReceiver(mReceiver, filter);
+        context.sendBroadcast(new Intent(
+                TestNotificationService.ACTION_CHANGE_EXECUTION_MODE));
     }
 
     @Override
     public void tearDown() throws Exception {
         // Delete created files
-        deleteDocuments(Build.MODEL);
+        deleteDocuments(mDeviceLabel);
         deleteDocuments(mSdCardLabel);
 
         if (mIsVirtualSdCard) {
@@ -172,6 +180,7 @@
                 + mPreTestStayAwakeValue);
 
         context.unregisterReceiver(mReceiver);
+        mCountDownLatch = null;
         try {
             bots.notifications.setNotificationAccess(getActivity(), false);
         } catch (Exception e) {
@@ -260,7 +269,7 @@
                 Uri uri = helper.createDocument(root, "image/png", fileName);
                 byte[] buff = new byte[1024];
                 while ((read = in.read(buff)) > 0) {
-                    helper.writeAppendDocument(uri, buff);
+                    helper.writeAppendDocument(uri, buff, read);
                 }
                 buff = null;
             }
@@ -389,24 +398,24 @@
     @HugeLongTest
     public void testCopyDocuments_FromSdCard() throws Exception {
         createDocuments(mSdCardLabel, mSdCardRoot, mStorageDocsHelper);
-        copyFiles(mSdCardLabel, Build.MODEL);
+        copyFiles(mSdCardLabel, mDeviceLabel);
 
         // Check that original folder exists
         bots.roots.openRoot(mSdCardLabel);
         bots.directory.assertDocumentsPresent(TARGET_FOLDER);
 
         // Check that copied files exist
-        assertFilesCopied(Build.MODEL, mPrimaryRoot, mStorageDocsHelper);
+        assertFilesCopied(mDeviceLabel, mPrimaryRoot, mStorageDocsHelper);
     }
 
     // Copy Internal Storage -> SD Card //
     @HugeLongTest
     public void testCopyDocuments_ToSdCard() throws Exception {
-        createDocuments(Build.MODEL, mPrimaryRoot, mStorageDocsHelper);
-        copyFiles(Build.MODEL, mSdCardLabel);
+        createDocuments(mDeviceLabel, mPrimaryRoot, mStorageDocsHelper);
+        copyFiles(mDeviceLabel, mSdCardLabel);
 
         // Check that original folder exists
-        bots.roots.openRoot(Build.MODEL);
+        bots.roots.openRoot(mDeviceLabel);
         bots.directory.assertDocumentsPresent(TARGET_FOLDER);
 
         // Check that copied files exist
diff --git a/tests/functional/com/android/documentsui/FileDeleteUiTest.java b/tests/functional/com/android/documentsui/FileDeleteUiTest.java
index f4efd15..d68dbd6 100644
--- a/tests/functional/com/android/documentsui/FileDeleteUiTest.java
+++ b/tests/functional/com/android/documentsui/FileDeleteUiTest.java
@@ -66,7 +66,9 @@
                     mErrorReason = intent.getStringExtra(
                             TestNotificationService.EXTRA_ERROR_REASON);
                 }
-                mCountDownLatch.countDown();
+                if (mCountDownLatch != null) {
+                    mCountDownLatch.countDown();
+                }
             }
         }
     };
@@ -111,10 +113,8 @@
 
     @Override
     public void tearDown() throws Exception {
-        mCountDownLatch.countDown();
-        mCountDownLatch = null;
-
         context.unregisterReceiver(mReceiver);
+        mCountDownLatch = null;
         try {
             bots.notifications.setNotificationAccess(getActivity(), false);
         } catch (Exception e) {
diff --git a/tests/functional/com/android/documentsui/FilesActivityUiTest.java b/tests/functional/com/android/documentsui/FilesActivityUiTest.java
index 16dc087..2da8309 100644
--- a/tests/functional/com/android/documentsui/FilesActivityUiTest.java
+++ b/tests/functional/com/android/documentsui/FilesActivityUiTest.java
@@ -57,7 +57,14 @@
     // to be able to click on it.
     public void testClickRecent() throws Exception {
         bots.roots.openRoot("Recent");
-        bots.main.assertSearchBarShow();
+
+        boolean showSearchBar =
+                context.getResources().getBoolean(R.bool.show_search_bar);
+        if (showSearchBar) {
+            bots.main.assertSearchBarShow();
+        } else {
+            bots.main.assertWindowTitle("Recent");
+        }
     }
 
     public void testRootClick_SetsWindowTitle() throws Exception {
diff --git a/tests/functional/com/android/documentsui/InspectorUiTest.java b/tests/functional/com/android/documentsui/InspectorUiTest.java
index 99d0ae0..de52250 100644
--- a/tests/functional/com/android/documentsui/InspectorUiTest.java
+++ b/tests/functional/com/android/documentsui/InspectorUiTest.java
@@ -21,7 +21,7 @@
 
 import androidx.test.filters.LargeTest;
 
-import com.android.documentsui.bots.UiBot;
+import com.android.documentsui.files.FilesActivity;
 import com.android.documentsui.inspector.InspectorActivity;
 
 @LargeTest
@@ -43,8 +43,7 @@
         if (!features.isInspectorEnabled()) {
             return;
         }
-        final Intent intent = context.getPackageManager().getLaunchIntentForPackage(
-                UiBot.targetPackageName);
+        final Intent intent = new Intent(context, FilesActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
         Uri uri = DocumentsContract.buildDocumentUri(InspectorProvider.AUTHORITY, TEST_DOC_NAME);
         intent.setData(uri);
diff --git a/tests/functional/com/android/documentsui/PickerPreviewAllTypeUiTest.java b/tests/functional/com/android/documentsui/PickerPreviewAllTypeUiTest.java
index fe5ddb3..459e9b0 100644
--- a/tests/functional/com/android/documentsui/PickerPreviewAllTypeUiTest.java
+++ b/tests/functional/com/android/documentsui/PickerPreviewAllTypeUiTest.java
@@ -16,16 +16,12 @@
 
 package com.android.documentsui;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 import android.content.Intent;
 import android.provider.DocumentsContract;
 
 import androidx.test.filters.LargeTest;
 
 import com.android.documentsui.base.Shared;
-import com.android.documentsui.bots.UiBot;
 import com.android.documentsui.picker.PickActivity;
 
 @LargeTest
@@ -47,8 +43,7 @@
 
     @Override
     protected void launchActivity() {
-        final Intent intent = context.getPackageManager().getLaunchIntentForPackage(
-                UiBot.targetPackageName);
+        final Intent intent = new Intent(context, PickActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
         intent.setAction(Intent.ACTION_GET_CONTENT);
         if (getInitialRoot() != null) {
diff --git a/tests/functional/com/android/documentsui/PickerPreviewTextUiTest.java b/tests/functional/com/android/documentsui/PickerPreviewTextUiTest.java
index af6a3c5..f5ac051 100644
--- a/tests/functional/com/android/documentsui/PickerPreviewTextUiTest.java
+++ b/tests/functional/com/android/documentsui/PickerPreviewTextUiTest.java
@@ -16,16 +16,12 @@
 
 package com.android.documentsui;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 import android.content.Intent;
 import android.provider.DocumentsContract;
 
 import androidx.test.filters.LargeTest;
 
 import com.android.documentsui.base.Shared;
-import com.android.documentsui.bots.UiBot;
 import com.android.documentsui.picker.PickActivity;
 
 @LargeTest
@@ -47,8 +43,7 @@
 
     @Override
     protected void launchActivity() {
-        final Intent intent = context.getPackageManager().getLaunchIntentForPackage(
-                UiBot.targetPackageName);
+        final Intent intent = new Intent(context, PickActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
         intent.setAction(Intent.ACTION_GET_CONTENT);
         if (getInitialRoot() != null) {
diff --git a/tests/functional/com/android/documentsui/RenameDocumentUiTest.java b/tests/functional/com/android/documentsui/RenameDocumentUiTest.java
index 58b2e58..1c72600 100644
--- a/tests/functional/com/android/documentsui/RenameDocumentUiTest.java
+++ b/tests/functional/com/android/documentsui/RenameDocumentUiTest.java
@@ -38,43 +38,43 @@
         bots.roots.closeDrawer();
     }
 
-    public void testRenameEnabled_SingleSelection() throws Exception {
-        bots.directory.selectDocument(fileName1, 1);
-        bots.main.openOverflowMenu();
-        bots.main.assertMenuEnabled(R.string.menu_rename, true);
-
-        // Dismiss more options window
-        device.pressBack();
-    }
-
-    public void testNoRenameSupport_SingleSelection() throws Exception {
-        bots.directory.selectDocument(fileNameNoRename, 1);
-        bots.main.openOverflowMenu();
-        bots.main.assertMenuEnabled(R.string.menu_rename, false);
-
-        // Dismiss more options window
-        device.pressBack();
-    }
-
-    public void testOneHasRenameSupport_MultipleSelection() throws Exception {
-        bots.directory.selectDocument(fileName1, 1);
-        bots.directory.selectDocument(fileNameNoRename, 2);
-        bots.main.openOverflowMenu();
-        bots.main.assertMenuEnabled(R.string.menu_rename, false);
-
-        // Dismiss more options window
-        device.pressBack();
-    }
-
-    public void testRenameDisabled_MultipleSelection() throws Exception {
-        bots.directory.selectDocument(fileName1, 1);
-        bots.directory.selectDocument(fileName2, 2);
-        bots.main.openOverflowMenu();
-        bots.main.assertMenuEnabled(R.string.menu_rename, false);
-
-        // Dismiss more options window
-        device.pressBack();
-    }
+//    public void testRenameEnabled_SingleSelection() throws Exception {
+//        bots.directory.selectDocument(fileName1, 1);
+//        bots.main.openOverflowMenu();
+//        bots.main.assertMenuEnabled(R.string.menu_rename, true);
+//
+//        // Dismiss more options window
+//        device.pressBack();
+//    }
+//
+//    public void testNoRenameSupport_SingleSelection() throws Exception {
+//        bots.directory.selectDocument(fileNameNoRename, 1);
+//        bots.main.openOverflowMenu();
+//        bots.main.assertMenuEnabled(R.string.menu_rename, false);
+//
+//        // Dismiss more options window
+//        device.pressBack();
+//    }
+//
+//    public void testOneHasRenameSupport_MultipleSelection() throws Exception {
+//        bots.directory.selectDocument(fileName1, 1);
+//        bots.directory.selectDocument(fileNameNoRename, 2);
+//        bots.main.openOverflowMenu();
+//        bots.main.assertMenuEnabled(R.string.menu_rename, false);
+//
+//        // Dismiss more options window
+//        device.pressBack();
+//    }
+//
+//    public void testRenameDisabled_MultipleSelection() throws Exception {
+//        bots.directory.selectDocument(fileName1, 1);
+//        bots.directory.selectDocument(fileName2, 2);
+//        bots.main.openOverflowMenu();
+//        bots.main.assertMenuEnabled(R.string.menu_rename, false);
+//
+//        // Dismiss more options window
+//        device.pressBack();
+//    }
 
     public void testRenameFile_OkButton() throws Exception {
         bots.directory.selectDocument(fileName1, 1);
diff --git a/tests/functional/com/android/documentsui/SearchViewUiTest.java b/tests/functional/com/android/documentsui/SearchViewUiTest.java
index 9a151f7..d18ac3c 100644
--- a/tests/functional/com/android/documentsui/SearchViewUiTest.java
+++ b/tests/functional/com/android/documentsui/SearchViewUiTest.java
@@ -44,6 +44,16 @@
       bots.directory.waitForDocument(fileName1);
     }
 
+    @Override
+    public void tearDown() throws Exception {
+        // manually close activity to avoid SearchFragment show when Activity close. ref b/142840883
+        device.waitForIdle();
+        device.pressBack();
+        device.pressBack();
+        device.pressBack();
+        super.tearDown();
+    }
+
     public void testSearchIconVisible() throws Exception {
         // The default root (root 0) supports search
         bots.search.assertInputExists(false);
diff --git a/tests/res/raw/uitest_images.zip b/tests/res/raw/uitest_images.zip
index 33186e4..1a1331d 100644
--- a/tests/res/raw/uitest_images.zip
+++ b/tests/res/raw/uitest_images.zip
Binary files differ
diff --git a/tests/unit/com/android/documentsui/RecentsLoaderTests.java b/tests/unit/com/android/documentsui/RecentsLoaderTests.java
index f044b92..73ba36f 100644
--- a/tests/unit/com/android/documentsui/RecentsLoaderTests.java
+++ b/tests/unit/com/android/documentsui/RecentsLoaderTests.java
@@ -29,6 +29,7 @@
 import com.android.documentsui.base.DocumentInfo;
 import com.android.documentsui.base.State;
 import com.android.documentsui.testing.ActivityManagers;
+import com.android.documentsui.testing.TestCursor;
 import com.android.documentsui.testing.TestEnv;
 import com.android.documentsui.testing.TestFileTypeLookup;
 import com.android.documentsui.testing.TestImmediateExecutor;
@@ -38,6 +39,9 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
 @RunWith(AndroidJUnit4.class)
 @MediumTest
 public class RecentsLoaderTests {
@@ -45,6 +49,7 @@
     private TestEnv mEnv;
     private TestActivity mActivity;
     private RecentsLoader mLoader;
+    private boolean mContentChanged;
 
     @Before
     public void setUp() {
@@ -105,4 +110,28 @@
             assertEquals(0, flags & Document.FLAG_SUPPORTS_MOVE);
         }
     }
+
+    @Test
+    public void testContentsUpdate_observable() throws Exception {
+        CountDownLatch latch = new CountDownLatch(1);
+        Runnable callback = () -> {
+            latch.countDown();
+            mContentChanged = true;
+        };
+        mLoader.setObserver(new LockingContentObserver(new ContentLock(), callback));
+
+        final DocumentInfo doc = mEnv.model.createFile("freddy.jpg");
+        doc.lastModified = System.currentTimeMillis();
+        mEnv.mockProviders.get(TestProvidersAccess.HOME.authority)
+                .setNextRecentDocumentsReturns(doc);
+
+        mLoader.loadInBackground();
+
+        TestCursor c = (TestCursor) mEnv.mockProviders.get(TestProvidersAccess.HOME.authority)
+                .queryRecentDocuments(null, null);
+        c.mockOnChange();
+
+        latch.await(1, TimeUnit.SECONDS);
+        assertTrue(mContentChanged);
+    }
 }
diff --git a/tests/unit/com/android/documentsui/files/ActionHandlerTest.java b/tests/unit/com/android/documentsui/files/ActionHandlerTest.java
index de4f7fa..e5141cd 100644
--- a/tests/unit/com/android/documentsui/files/ActionHandlerTest.java
+++ b/tests/unit/com/android/documentsui/files/ActionHandlerTest.java
@@ -53,6 +53,7 @@
 import com.android.documentsui.R;
 import com.android.documentsui.TestActionModeAddons;
 import com.android.documentsui.archives.ArchivesProvider;
+import com.android.documentsui.base.DebugFlags;
 import com.android.documentsui.base.DocumentInfo;
 import com.android.documentsui.base.DocumentStack;
 import com.android.documentsui.base.RootInfo;
@@ -331,6 +332,27 @@
     @Test
     public void testDocumentPicked_Downloads_ManagesApks() throws Exception {
         mActivity.currentRoot = TestProvidersAccess.DOWNLOADS;
+        TestEnv.FILE_APK.authority = TestProvidersAccess.DOWNLOADS.authority;
+
+        mHandler.openDocument(TestEnv.FILE_APK, ActionHandler.VIEW_TYPE_PREVIEW,
+                ActionHandler.VIEW_TYPE_REGULAR);
+        mActivity.assertActivityStarted(DocumentsContract.ACTION_MANAGE_DOCUMENT);
+    }
+
+    @Test
+    public void testDocumentPicked_Downloads_ManagesPartialFiles() throws Exception {
+        mActivity.currentRoot = TestProvidersAccess.DOWNLOADS;
+        TestEnv.FILE_PARTIAL.authority = TestProvidersAccess.DOWNLOADS.authority;
+
+        mHandler.openDocument(TestEnv.FILE_PARTIAL, ActionHandler.VIEW_TYPE_PREVIEW,
+                ActionHandler.VIEW_TYPE_REGULAR);
+        mActivity.assertActivityStarted(DocumentsContract.ACTION_MANAGE_DOCUMENT);
+    }
+
+    @Test
+    public void testDocumentPicked_Recent_ManagesApks() throws Exception {
+        mActivity.currentRoot = TestProvidersAccess.RECENTS;
+        TestEnv.FILE_APK.authority = TestProvidersAccess.DOWNLOADS.authority;
 
         mHandler.openDocument(TestEnv.FILE_APK, ActionHandler.VIEW_TYPE_PREVIEW,
                 ActionHandler.VIEW_TYPE_REGULAR);
@@ -347,15 +369,6 @@
     }
 
     @Test
-    public void testDocumentPicked_Downloads_ManagesPartialFiles() throws Exception {
-        mActivity.currentRoot = TestProvidersAccess.DOWNLOADS;
-
-        mHandler.openDocument(TestEnv.FILE_PARTIAL, ActionHandler.VIEW_TYPE_PREVIEW,
-                ActionHandler.VIEW_TYPE_REGULAR);
-        mActivity.assertActivityStarted(DocumentsContract.ACTION_MANAGE_DOCUMENT);
-    }
-
-    @Test
     public void testDocumentPicked_OpensArchives() throws Exception {
         mActivity.currentRoot = TestProvidersAccess.HOME;
         mEnv.docs.nextDocument = TestEnv.FILE_ARCHIVE;
@@ -642,12 +655,14 @@
     @Test
     public void testShowInspector_DebugEnabled() throws Exception {
         mFeatures.debugSupport = true;
+        DebugFlags.setDocumentDetailsEnabled(true);
 
         mHandler.showInspector(TestEnv.FILE_GIF);
         Intent intent = mActivity.startActivity.getLastValue();
 
         assertHasExtra(intent, Shared.EXTRA_SHOW_DEBUG);
         assertTrue(intent.getExtras().getBoolean(Shared.EXTRA_SHOW_DEBUG));
+        DebugFlags.setDocumentDetailsEnabled(false);
     }
 
     @Test
diff --git a/tests/unit/com/android/documentsui/queries/SearchHistoryManagerTest.java b/tests/unit/com/android/documentsui/queries/SearchHistoryManagerTest.java
index 1f2a974..3c216c7 100644
--- a/tests/unit/com/android/documentsui/queries/SearchHistoryManagerTest.java
+++ b/tests/unit/com/android/documentsui/queries/SearchHistoryManagerTest.java
@@ -19,21 +19,21 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import android.content.Context;
+
 import androidx.test.InstrumentationRegistry;
 import androidx.test.filters.MediumTest;
 import androidx.test.runner.AndroidJUnit4;
 
-import com.android.documentsui.queries.SearchHistoryManager;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.List;
-
-import org.junit.Before;
 import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
 @RunWith(AndroidJUnit4.class)
 @MediumTest
 public final class SearchHistoryManagerTest {
@@ -49,7 +49,7 @@
     public void setUp() throws Exception {
         mContext = InstrumentationRegistry.getTargetContext();
         mManager = SearchHistoryManager.getInstance(mContext);
-        clearData();
+        //clearData();
         mIntResult = -1;
         mLongResult = -1;
     }
@@ -57,7 +57,7 @@
     @After
     public void tearDown() {
         mListener = null;
-        clearData();
+        //clearData();
     }
 
     private void clearData() {
@@ -68,6 +68,7 @@
     }
 
     @Test
+    @Ignore
     public void testAddHistory() throws Exception {
         mLatch = new CountDownLatch(2);
         mListener = new SearchHistoryManager.DatabaseChangedListener() {
@@ -90,6 +91,7 @@
     }
 
     @Test
+    @Ignore
     public void testDeleteHistory() throws Exception {
         mLatch = new CountDownLatch(2);
         mListener = new SearchHistoryManager.DatabaseChangedListener() {
@@ -125,6 +127,7 @@
     }
 
     @Test
+    @Ignore
     public void testGetHistoryList() throws Exception {
         mLatch = new CountDownLatch(2);
         mListener = new SearchHistoryManager.DatabaseChangedListener() {