Merge Android U (ab/10368041)

Bug: 291102124
Merged-In: I7efbfd50628298c436cb86d5d84af6cbfa7918da
Change-Id: Ic95053849a83d3c13510c05d5fd03cc6863f3b65
diff --git a/java/AndroidManifest.xml b/java/AndroidManifest.xml
index ac84c33..633c68b 100644
--- a/java/AndroidManifest.xml
+++ b/java/AndroidManifest.xml
@@ -54,6 +54,13 @@
     <permission android:name="com.android.inputmethod.latin.HIDE_SOFT_INPUT"
          android:protectionLevel="signature"/>
 
+    <!-- To query enabled input methods. -->
+    <queries>
+        <intent>
+            <action android:name="android.view.InputMethod" />
+        </intent>
+    </queries>
+
     <application android:label="@string/english_ime_name"
          android:icon="@drawable/ic_launcher_keyboard"
          android:supportsRtl="true"
@@ -65,7 +72,8 @@
         <service android:name="LatinIME"
              android:label="@string/english_ime_name"
              android:permission="android.permission.BIND_INPUT_METHOD"
-             android:exported="true">
+             android:exported="true"
+             android:visibleToInstantApps="true">
             <intent-filter>
                 <action android:name="android.view.InputMethod"/>
             </intent-filter>
@@ -149,7 +157,7 @@
         <activity android:name="com.android.inputmethod.dictionarypack.DownloadOverMeteredDialog"
              android:theme="@style/platformActivityTheme"
              android:label="@string/dictionary_install_over_metered_network_prompt"
-             android:exported="true">
+             android:exported="false">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
             </intent-filter>
diff --git a/java/lint-baseline.xml b/java/lint-baseline.xml
index 02f41f4..dbb81ca 100644
--- a/java/lint-baseline.xml
+++ b/java/lint-baseline.xml
@@ -26,50 +26,6 @@
     <issue
         id="NewApi"
         message="Call requires API level 23 (current min is 21): `android.content.Context#getSystemService`"
-        errorLine1="        final WindowManager wm = getSystemService(WindowManager.class);"
-        errorLine2="                                 ~~~~~~~~~~~~~~~~">
-        <location
-            file="packages/inputmethods/LatinIME/java/src/com/android/inputmethod/latin/LatinIME.java"
-            line="606"
-            column="34"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 23 (current min is 21): `android.content.Context#getSystemService`"
-        errorLine1="        final WindowManager wm = getSystemService(WindowManager.class);"
-        errorLine2="                                 ~~~~~~~~~~~~~~~~">
-        <location
-            file="packages/inputmethods/LatinIME/java/src/com/android/inputmethod/latin/LatinIME.java"
-            line="804"
-            column="34"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 23 (current min is 21): `android.app.ActivityOptions#makeBasic`"
-        errorLine1="                ActivityOptions.makeBasic().setLaunchDisplayId(currentDisplayId).toBundle());"
-        errorLine2="                                ~~~~~~~~~">
-        <location
-            file="packages/inputmethods/LatinIME/java/src/com/android/inputmethod/latin/LatinIME.java"
-            line="1823"
-            column="33"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 26 (current min is 21): `android.app.ActivityOptions#setLaunchDisplayId`"
-        errorLine1="                ActivityOptions.makeBasic().setLaunchDisplayId(currentDisplayId).toBundle());"
-        errorLine2="                                            ~~~~~~~~~~~~~~~~~~">
-        <location
-            file="packages/inputmethods/LatinIME/java/src/com/android/inputmethod/latin/LatinIME.java"
-            line="1823"
-            column="45"/>
-    </issue>
-
-    <issue
-        id="NewApi"
-        message="Call requires API level 23 (current min is 21): `android.content.Context#getSystemService`"
         errorLine1="        final UserManager userManager = context.getSystemService(UserManager.class);"
         errorLine2="                                                ~~~~~~~~~~~~~~~~">
         <location
@@ -78,4 +34,28 @@
             column="49"/>
     </issue>
 
-</issues>
+    <issue
+        id="NewApi"
+        message="Call requires API level 23 (current min is 21): `android.app.ActivityOptions#makeBasic`">
+        <location
+            file="packages/inputmethods/LatinIME/java/src/com/android/inputmethod/latin/LatinIME.java"
+            line="1842"/>
+    </issue>
+
+    <issue
+        id="NewApi"
+        message="Call requires API level 23 (current min is 21): `android.content.Context#getSystemService`">
+        <location
+            file="packages/inputmethods/LatinIME/java/src/com/android/inputmethod/latin/LatinIME.java"
+            line="605"/>
+    </issue>
+
+    <issue
+        id="NewApi"
+        message="Call requires API level 26 (current min is 21): `android.app.ActivityOptions#setLaunchDisplayId`">
+        <location
+            file="packages/inputmethods/LatinIME/java/src/com/android/inputmethod/latin/LatinIME.java"
+            line="1842"/>
+    </issue>
+
+</issues>
\ No newline at end of file
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 8ed3a59..e68b43b 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -628,16 +628,31 @@
 
         final IntentFilter newDictFilter = new IntentFilter();
         newDictFilter.addAction(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION);
-        registerReceiver(mDictionaryPackInstallReceiver, newDictFilter);
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+            registerReceiver(mDictionaryPackInstallReceiver, newDictFilter,
+                    Context.RECEIVER_NOT_EXPORTED);
+        } else {
+            registerReceiver(mDictionaryPackInstallReceiver, newDictFilter);
+        }
 
         final IntentFilter dictDumpFilter = new IntentFilter();
         dictDumpFilter.addAction(DictionaryDumpBroadcastReceiver.DICTIONARY_DUMP_INTENT_ACTION);
-        registerReceiver(mDictionaryDumpBroadcastReceiver, dictDumpFilter);
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+            registerReceiver(mDictionaryDumpBroadcastReceiver, dictDumpFilter,
+                    Context.RECEIVER_NOT_EXPORTED);
+        } else {
+            registerReceiver(mDictionaryDumpBroadcastReceiver, dictDumpFilter);
+        }
 
         final IntentFilter hideSoftInputFilter = new IntentFilter();
         hideSoftInputFilter.addAction(ACTION_HIDE_SOFT_INPUT);
-        registerReceiver(mHideSoftInputReceiver, hideSoftInputFilter, PERMISSION_HIDE_SOFT_INPUT,
-                null /* scheduler */);
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+            registerReceiver(mHideSoftInputReceiver, hideSoftInputFilter,
+                    PERMISSION_HIDE_SOFT_INPUT, null /* scheduler */, Context.RECEIVER_EXPORTED);
+        } else {
+            registerReceiver(mHideSoftInputReceiver, hideSoftInputFilter,
+                    PERMISSION_HIDE_SOFT_INPUT, null /* scheduler */);
+        }
 
         StatsUtils.onCreate(mSettings.getCurrent(), mRichImm);
     }
diff --git a/tests/AndroidTest.xml b/tests/AndroidTest.xml
index 41334d5..60e9a01 100644
--- a/tests/AndroidTest.xml
+++ b/tests/AndroidTest.xml
@@ -26,7 +26,7 @@
         hence we cannot rely on "test-file-name" to install LatinIME.apk
     -->
 
-    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
         <option name="cleanup-apks" value="true" />
         <option name="test-file-name" value="LatinIMETests.apk" />
     </target_preparer>