Merge "Fix broken @see/@link references controls" into main
diff --git a/api/OWNERS b/api/OWNERS
index bf6216c..965093c 100644
--- a/api/OWNERS
+++ b/api/OWNERS
@@ -3,7 +3,10 @@
 # Modularization team
 file:platform/packages/modules/common:/OWNERS
 
+# Soong plugin owned by Soong team.
+per-file *.go,go.mod,go.work,go.work.sum = file:platform/build/soong:/OWNERS
+
 per-file Android.bp = file:platform/build/soong:/OWNERS #{LAST_RESORT_SUGGESTION}
 
 # For metalava team to disable lint checks in platform
-per-file Android.bp = aurimas@google.com,emberrose@google.com,sjgilbert@google.com
+per-file Android.bp = aurimas@google.com,emberrose@google.com
diff --git a/api/StubLibraries.bp b/api/StubLibraries.bp
index 8b53592..180a41c 100644
--- a/api/StubLibraries.bp
+++ b/api/StubLibraries.bp
@@ -357,13 +357,15 @@
     ],
     srcs: [":module-lib-api-stubs-docs-non-updatable"],
     libs: [
+        // We cannot depend on all-modules-module-lib-stubs, because the module-lib stubs
+        // depend on this stub. We resolve dependencies on APIs in modules by depending
+        // on a prebuilt of the whole platform (sdk_system_current_android).
+        // That prebuilt does not include module-lib APIs, so use the prebuilt module-lib
+        // stubs for modules that export module-lib stubs that the non-updatable part
+        // depends on.
         "sdk_module-lib_current_framework-tethering",
         "sdk_module-lib_current_framework-connectivity-t",
-        "sdk_public_current_framework-bluetooth",
-        // NOTE: The below can be removed once the prebuilt stub contains bluetooth.
         "sdk_system_current_android",
-        // NOTE: The below can be removed once the prebuilt stub contains IKE.
-        "sdk_system_current_android.net.ipsec.ike",
     ],
     dist: {
         dir: "apistubs/android/module-lib",
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index eda6057..ebf5f5e 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -3027,7 +3027,7 @@
     field public static final String ACTION_MANAGE_PERMISSION_APPS = "android.intent.action.MANAGE_PERMISSION_APPS";
     field @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) public static final String ACTION_MANAGE_PERMISSION_USAGE = "android.intent.action.MANAGE_PERMISSION_USAGE";
     field @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES = "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES";
-    field public static final String ACTION_MASTER_CLEAR_NOTIFICATION = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
+    field @RequiresPermission(android.Manifest.permission.MASTER_CLEAR) public static final String ACTION_MASTER_CLEAR_NOTIFICATION = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
     field public static final String ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_INTEGRITY_VERIFICATION";
     field public static final String ACTION_PACKAGE_UNSUSPENDED_MANUALLY = "android.intent.action.PACKAGE_UNSUSPENDED_MANUALLY";
     field public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED = "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED";
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 4549c30..2e3f1c0 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -4356,6 +4356,7 @@
      */
     @SystemApi
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+    @RequiresPermission(Manifest.permission.MASTER_CLEAR)
     public static final String ACTION_MASTER_CLEAR_NOTIFICATION
             = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
 
diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java
index a9eb672..1307dfc 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -484,7 +484,6 @@
     /**
      * A callback to be invoked when the system successfully delivers your {@link NdefMessage}
      * to another device.
-     * @see #setOnNdefPushCompleteCallback
      * @deprecated this feature is removed. File sharing can work using other technology like
      * Bluetooth.
      */
@@ -496,7 +495,6 @@
          * <p>This callback is usually made on a binder thread (not the UI thread).
          *
          * @param event {@link NfcEvent} with the {@link NfcEvent#nfcAdapter} field set
-         * @see #setNdefPushMessageCallback
          */
         public void onNdefPushComplete(NfcEvent event);
     }
@@ -504,11 +502,11 @@
     /**
      * A callback to be invoked when another NFC device capable of NDEF push (Android Beam)
      * is within range.
-     * <p>Implement this interface and pass it to {@link
+     * <p>Implement this interface and pass it to {@code
      * NfcAdapter#setNdefPushMessageCallback setNdefPushMessageCallback()} in order to create an
      * {@link NdefMessage} at the moment that another device is within range for NFC. Using this
      * callback allows you to create a message with data that might vary based on the
-     * content currently visible to the user. Alternatively, you can call {@link
+     * content currently visible to the user. Alternatively, you can call {@code
      * #setNdefPushMessage setNdefPushMessage()} if the {@link NdefMessage} always contains the
      * same data.
      * @deprecated this feature is removed. File sharing can work using other technology like
diff --git a/core/java/android/service/watchdog/ExplicitHealthCheckService.java b/core/java/android/service/watchdog/ExplicitHealthCheckService.java
index 49e00d6..7befbfb 100644
--- a/core/java/android/service/watchdog/ExplicitHealthCheckService.java
+++ b/core/java/android/service/watchdog/ExplicitHealthCheckService.java
@@ -151,7 +151,7 @@
      */
     @NonNull public abstract List<String> onGetRequestedPackages();
 
-    private final Handler mHandler = new Handler(Looper.getMainLooper(), null, true);
+    private final Handler mHandler = Handler.createAsync(Looper.getMainLooper());
     @Nullable private RemoteCallback mCallback;
 
     @Override
diff --git a/core/java/android/view/textclassifier/TextClassifierEvent.java b/core/java/android/view/textclassifier/TextClassifierEvent.java
index 195565c..33db671 100644
--- a/core/java/android/view/textclassifier/TextClassifierEvent.java
+++ b/core/java/android/view/textclassifier/TextClassifierEvent.java
@@ -551,8 +551,8 @@
          * Sets the entity types. e.g. {@link TextClassifier#TYPE_ADDRESS}.
          * <p>
          * Supported types:
-         * <p>See {@link TextClassifier.EntityType}
-         * <p>See {@link ConversationAction.ActionType}
+         * <p>See {@link TextClassifier} types
+         * <p>See {@link ConversationAction} types
          * <p>See {@link ULocale#toLanguageTag()}
          */
         @NonNull
diff --git a/core/java/android/view/translation/TranslationCapability.java b/core/java/android/view/translation/TranslationCapability.java
index b7e13dd..52760f7 100644
--- a/core/java/android/view/translation/TranslationCapability.java
+++ b/core/java/android/view/translation/TranslationCapability.java
@@ -207,7 +207,7 @@
 
     /**
      * Translation flags for settings that are supported by the
-     * {@link android.service.translation.TranslationService} between the {@link TranslationSpec}s
+     * translation service between the {@link TranslationSpec}s
      * provided in this capability.
      */
     @DataClass.Generated.Member
diff --git a/core/java/android/view/translation/TranslationManager.java b/core/java/android/view/translation/TranslationManager.java
index fbaf711..4e7223e 100644
--- a/core/java/android/view/translation/TranslationManager.java
+++ b/core/java/android/view/translation/TranslationManager.java
@@ -56,7 +56,7 @@
  * translation framework.
  *
  * <p>The TranslationManager manages {@link Translator}s and help bridge client calls to
- * the server {@link android.service.translation.TranslationService} </p>
+ * the server translation service </p>
  */
 @SystemService(Context.TRANSLATION_MANAGER_SERVICE)
 public final class TranslationManager {
diff --git a/core/java/android/view/translation/TranslationRequest.java b/core/java/android/view/translation/TranslationRequest.java
index 027edc2..ff11ffa 100644
--- a/core/java/android/view/translation/TranslationRequest.java
+++ b/core/java/android/view/translation/TranslationRequest.java
@@ -27,7 +27,7 @@
 import java.util.List;
 
 /**
- * Translation request sent to the {@link android.service.translation.TranslationService} by the
+ * Translation request sent to the translation service by the
  * {@link android.view.translation.Translator} which contains the text to be translated.
  */
 @DataClass(genToString = true, genHiddenConstDefs = true, genBuilder = true)
diff --git a/core/java/android/view/translation/TranslationResponse.java b/core/java/android/view/translation/TranslationResponse.java
index b77f2e2..3362fc0 100644
--- a/core/java/android/view/translation/TranslationResponse.java
+++ b/core/java/android/view/translation/TranslationResponse.java
@@ -20,7 +20,6 @@
 import android.annotation.NonNull;
 import android.os.Parcel;
 import android.os.Parcelable;
-import android.service.translation.TranslationService;
 import android.util.SparseArray;
 
 import com.android.internal.util.DataClass;
@@ -30,17 +29,17 @@
 import java.util.Objects;
 
 /**
- * Response from the {@link TranslationService}, which contains the translated result.
+ * Response from the translation service, which contains the translated result.
  */
 @DataClass(genBuilder = true, genToString = true, genHiddenConstDefs = true)
 public final class TranslationResponse implements Parcelable {
 
     /**
-     * The {@link TranslationService} was successful in translating.
+     * The translation service was successful in translating.
      */
     public static final int TRANSLATION_STATUS_SUCCESS = 0;
     /**
-     * The {@link TranslationService} returned unknown translation result.
+     * The translation service returned unknown translation result.
      */
     public static final int TRANSLATION_STATUS_UNKNOWN_ERROR = 1;
     /**
diff --git a/core/java/android/view/translation/TranslationResponseValue.java b/core/java/android/view/translation/TranslationResponseValue.java
index 9dff2d5..18a240d 100644
--- a/core/java/android/view/translation/TranslationResponseValue.java
+++ b/core/java/android/view/translation/TranslationResponseValue.java
@@ -27,7 +27,7 @@
 import java.util.Objects;
 
 /**
- * A translated response value from {@link android.service.translation.TranslationService}.
+ * A translated response value from translation service.
  */
 @DataClass(genBuilder = true, genToString = true, genEqualsHashCode = true,
         genHiddenConstDefs = true)
diff --git a/core/java/android/view/translation/ViewTranslationRequest.java b/core/java/android/view/translation/ViewTranslationRequest.java
index a41749a..54b8ac2 100644
--- a/core/java/android/view/translation/ViewTranslationRequest.java
+++ b/core/java/android/view/translation/ViewTranslationRequest.java
@@ -33,7 +33,7 @@
 
 /**
  * Wrapper class representing a translation request associated with a {@link android.view.View} to
- * be used by {@link android.service.translation.TranslationService}.
+ * be used by translation service.
  */
 @DataClass(genBuilder = false, genToString = true, genEqualsHashCode = true, genGetters = false,
         genHiddenConstructor = true, genHiddenConstDefs = true)
diff --git a/core/java/android/view/translation/ViewTranslationResponse.java b/core/java/android/view/translation/ViewTranslationResponse.java
index d993114..134ff5a 100644
--- a/core/java/android/view/translation/ViewTranslationResponse.java
+++ b/core/java/android/view/translation/ViewTranslationResponse.java
@@ -33,7 +33,7 @@
 
 /**
  * Wrapper class representing a translation response associated with a {@link android.view.View} to
- * be used by {@link android.service.translation.TranslationService}.
+ * be used by translation service.
  */
 @DataClass(genBuilder = true, genToString = true, genEqualsHashCode = true, genGetters = false)
 public final class ViewTranslationResponse implements Parcelable {
diff --git a/services/core/java/com/android/server/ExplicitHealthCheckController.java b/services/core/java/com/android/server/ExplicitHealthCheckController.java
index 77059d9..81db70a 100644
--- a/services/core/java/com/android/server/ExplicitHealthCheckController.java
+++ b/services/core/java/com/android/server/ExplicitHealthCheckController.java
@@ -343,7 +343,7 @@
             };
 
             mContext.bindServiceAsUser(intent, mConnection,
-                    Context.BIND_AUTO_CREATE, UserHandle.of(UserHandle.USER_SYSTEM));
+                    Context.BIND_AUTO_CREATE, UserHandle.SYSTEM);
             Slog.i(TAG, "Explicit health check service is bound");
         }
     }
diff --git a/services/core/java/com/android/server/RescueParty.java b/services/core/java/com/android/server/RescueParty.java
index c1c9fbb..97f65dd 100644
--- a/services/core/java/com/android/server/RescueParty.java
+++ b/services/core/java/com/android/server/RescueParty.java
@@ -500,7 +500,8 @@
         Exception res = null;
         final ContentResolver resolver = context.getContentResolver();
         try {
-            Settings.Global.resetToDefaultsAsUser(resolver, null, mode, UserHandle.USER_SYSTEM);
+            Settings.Global.resetToDefaultsAsUser(resolver, null, mode,
+                UserHandle.SYSTEM.getIdentifier());
         } catch (Exception e) {
             res = new RuntimeException("Failed to reset global settings", e);
         }
@@ -741,12 +742,13 @@
     }
 
     private static int[] getAllUserIds() {
-        int[] userIds = { UserHandle.USER_SYSTEM };
+        int systemUserId = UserHandle.SYSTEM.getIdentifier();
+        int[] userIds = { systemUserId };
         try {
             for (File file : FileUtils.listFilesOrEmpty(Environment.getDataSystemDeDirectory())) {
                 try {
                     final int userId = Integer.parseInt(file.getName());
-                    if (userId != UserHandle.USER_SYSTEM) {
+                    if (userId != systemUserId) {
                         userIds = ArrayUtils.appendInt(userIds, userId);
                     }
                 } catch (NumberFormatException ignored) {
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index bce3173..3ed4df7 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -276,8 +276,8 @@
     // don't have an oom adj assigned by the system).
     public static final int NATIVE_ADJ = -1000;
 
-    // Memory pages are 4K.
-    static final int PAGE_SIZE = 4 * 1024;
+    // Memory page size.
+    static final int PAGE_SIZE = (int) Os.sysconf(OsConstants._SC_PAGESIZE);
 
     // Activity manager's version of Process.THREAD_GROUP_BACKGROUND
     static final int SCHED_GROUP_BACKGROUND = 0;
diff --git a/tools/lint/global/integration_tests/Android.bp b/tools/lint/global/integration_tests/Android.bp
new file mode 100644
index 0000000..ca96559
--- /dev/null
+++ b/tools/lint/global/integration_tests/Android.bp
@@ -0,0 +1,40 @@
+// Copyright (C) 2023 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.
+
+java_library {
+    name: "AndroidGlobalLintTestNoAidl",
+    srcs: ["TestNoAidl/**/*.java"],
+    libs: [
+        "framework-annotations-lib",
+    ],
+    lint: {
+        // It is expected that lint returns an error when processing this
+        // library. Silence it here, the lint output is verified in tests.py.
+        suppress_exit_code: true,
+    },
+}
+
+python_test_host {
+    name: "AndroidGlobalLintCheckerIntegrationTest",
+    srcs: ["tests.py"],
+    main: "tests.py",
+    data: [
+        ":AndroidGlobalLintTestNoAidl{.lint}",
+    ],
+    version: {
+        py3: {
+            embedded_launcher: true,
+        },
+    },
+}
diff --git a/tools/lint/global/integration_tests/TestNoAidl/TestNoAidl.java b/tools/lint/global/integration_tests/TestNoAidl/TestNoAidl.java
new file mode 100644
index 0000000..0015f95
--- /dev/null
+++ b/tools/lint/global/integration_tests/TestNoAidl/TestNoAidl.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2023 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.google.android.lint.integration_tests;
+
+import android.annotation.EnforcePermission;
+
+/**
+ * A class that use the annotation but does not rely on AIDL.
+ */
+class TestNoAidl {
+
+    @EnforcePermission("INTERNET")
+    void myMethod() {
+    }
+
+}
diff --git a/tools/lint/global/integration_tests/tests.py b/tools/lint/global/integration_tests/tests.py
new file mode 100644
index 0000000..fc3eeb4
--- /dev/null
+++ b/tools/lint/global/integration_tests/tests.py
@@ -0,0 +1,34 @@
+# Copyright 2023 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.
+
+import pkgutil
+import unittest
+import xml.etree.ElementTree
+
+class TestLinterReports(unittest.TestCase):
+    """Integration tests for the linters used by @EnforcePermission."""
+
+    def test_no_aidl(self):
+        report = pkgutil.get_data("lint", "lint-report.xml").decode()
+        issues = xml.etree.ElementTree.fromstring(report)
+        self.assertEqual(issues.tag, "issues")
+        self.assertEqual(len(issues), 1)
+
+        issue = issues[0]
+        self.assertEqual(issue.attrib["id"], "MisusingEnforcePermissionAnnotation")
+        self.assertEqual(issue.attrib["severity"], "Error")
+
+
+if __name__ == '__main__':
+    unittest.main(verbosity=2)