Merge "Extract out common busy wait function" into main
diff --git a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
index 165a945..1e723b5 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
@@ -204,9 +204,7 @@
                                             serviceIntent,
                                             targetUser,
                                             safeExecuteAppFunctionCallback,
-                                            /* bindFlags= */ Context.BIND_AUTO_CREATE,
-                                            /* timeoutInMillis= */ mServiceConfig
-                                                    .getExecuteAppFunctionTimeoutMillis());
+                                            /* bindFlags= */ Context.BIND_AUTO_CREATE);
                                 })
                         .exceptionally(
                                 ex -> {
@@ -221,13 +219,11 @@
             @NonNull Intent serviceIntent,
             @NonNull UserHandle targetUser,
             @NonNull SafeOneTimeExecuteAppFunctionCallback safeExecuteAppFunctionCallback,
-            int bindFlags,
-            long timeoutInMillis) {
+            int bindFlags) {
         boolean bindServiceResult =
                 mRemoteServiceCaller.runServiceCall(
                         serviceIntent,
                         bindFlags,
-                        timeoutInMillis,
                         targetUser,
                         new RunServiceCallCallback<IAppFunctionService>() {
                             @Override
@@ -268,16 +264,6 @@
                                                 "Failed to connect to AppFunctionService",
                                                 /* extras= */ null));
                             }
-
-                            @Override
-                            public void onTimedOut() {
-                                Slog.e(TAG, "Timed out");
-                                safeExecuteAppFunctionCallback.onResult(
-                                        ExecuteAppFunctionResponse.newFailure(
-                                                ExecuteAppFunctionResponse.RESULT_TIMED_OUT,
-                                                "Binding to AppFunctionService timed out.",
-                                                /* extras= */ null));
-                            }
                         });
 
         if (!bindServiceResult) {
diff --git a/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java b/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java
index 58597c3..cd5c383 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java
@@ -43,7 +43,6 @@
      * @param intent An Intent object that describes the service that should be bound.
      * @param bindFlags Flags used to control the binding process See {@link
      *     android.content.Context#bindService}.
-     * @param timeoutInMillis The maximum time in milliseconds to wait for the service connection.
      * @param userHandle The UserHandle of the user for which the service should be bound.
      * @param callback A callback to be invoked for various events. See {@link
      *     RunServiceCallCallback}.
@@ -51,7 +50,6 @@
     boolean runServiceCall(
             @NonNull Intent intent,
             int bindFlags,
-            long timeoutInMillis,
             @NonNull UserHandle userHandle,
             @NonNull RunServiceCallCallback<T> callback);
 
@@ -75,11 +73,5 @@
 
         /** Called when the service connection was failed to establish. */
         void onFailedToConnect();
-
-        /**
-         * Called when the whole operation(i.e. binding and the service call) takes longer than
-         * allowed.
-         */
-        void onTimedOut();
     }
 }
diff --git a/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java b/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java
index eea17ee..070a99d 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java
@@ -62,12 +62,11 @@
     public boolean runServiceCall(
             @NonNull Intent intent,
             int bindFlags,
-            long timeoutInMillis,
             @NonNull UserHandle userHandle,
             @NonNull RunServiceCallCallback<T> callback) {
         OneOffServiceConnection serviceConnection =
                 new OneOffServiceConnection(
-                        intent, bindFlags, timeoutInMillis, userHandle, callback);
+                        intent, bindFlags, userHandle, callback);
 
         return serviceConnection.bindAndRun();
     }
@@ -76,28 +75,17 @@
             implements ServiceConnection, ServiceUsageCompleteListener {
         private final Intent mIntent;
         private final int mFlags;
-        private final long mTimeoutMillis;
         private final UserHandle mUserHandle;
         private final RunServiceCallCallback<T> mCallback;
-        private final Runnable mTimeoutCallback;
 
         OneOffServiceConnection(
                 @NonNull Intent intent,
                 int flags,
-                long timeoutMillis,
                 @NonNull UserHandle userHandle,
                 @NonNull RunServiceCallCallback<T> callback) {
             mIntent = intent;
             mFlags = flags;
-            mTimeoutMillis = timeoutMillis;
             mCallback = callback;
-            mTimeoutCallback =
-                    () ->
-                            mExecutor.execute(
-                                    () -> {
-                                        safeUnbind();
-                                        mCallback.onTimedOut();
-                                    });
             mUserHandle = userHandle;
         }
 
@@ -105,9 +93,7 @@
             boolean bindServiceResult =
                     mContext.bindServiceAsUser(mIntent, this, mFlags, mUserHandle);
 
-            if (bindServiceResult) {
-                mHandler.postDelayed(mTimeoutCallback, mTimeoutMillis);
-            } else {
+            if(!bindServiceResult) {
                 safeUnbind();
             }
 
@@ -141,7 +127,6 @@
 
         private void safeUnbind() {
             try {
-                mHandler.removeCallbacks(mTimeoutCallback);
                 mContext.unbindService(this);
             } catch (Exception ex) {
                 Log.w(TAG, "Failed to unbind", ex);
diff --git a/tools/lint/global/checks/src/main/java/com/google/android/lint/aidl/ExemptAidlInterfaces.kt b/tools/lint/global/checks/src/main/java/com/google/android/lint/aidl/ExemptAidlInterfaces.kt
index 675a59e..caa018d 100644
--- a/tools/lint/global/checks/src/main/java/com/google/android/lint/aidl/ExemptAidlInterfaces.kt
+++ b/tools/lint/global/checks/src/main/java/com/google/android/lint/aidl/ExemptAidlInterfaces.kt
@@ -256,7 +256,7 @@
     "android.devicelock.IGetDeviceIdCallback",
     "android.devicelock.IGetKioskAppsCallback",
     "android.devicelock.IIsDeviceLockedCallback",
-    "android.devicelock.IVoidResultCallback",
+    "android.devicelock.ILockUnlockDeviceCallback",
     "android.federatedcompute.aidl.IExampleStoreCallback",
     "android.federatedcompute.aidl.IExampleStoreIterator",
     "android.federatedcompute.aidl.IExampleStoreIteratorCallback",
@@ -364,8 +364,6 @@
     "android.health.connect.aidl.IGetPriorityResponseCallback",
     "android.health.connect.aidl.IHealthConnectService",
     "android.health.connect.aidl.IInsertRecordsResponseCallback",
-    "android.health.connect.aidl.IMedicalDataSourceResponseCallback",
-    "android.health.connect.aidl.IMedicalResourcesResponseCallback",
     "android.health.connect.aidl.IMigrationCallback",
     "android.health.connect.aidl.IReadMedicalResourcesResponseCallback",
     "android.health.connect.aidl.IReadRecordsResponseCallback",
@@ -462,6 +460,7 @@
     "android.net.ipmemorystore.IOnBlobRetrievedListener",
     "android.net.ipmemorystore.IOnL2KeyResponseListener",
     "android.net.ipmemorystore.IOnNetworkAttributesRetrievedListener",
+    "android.net.ipmemorystore.IOnNetworkEventCountRetrievedListener",
     "android.net.ipmemorystore.IOnSameL3NetworkResponseListener",
     "android.net.ipmemorystore.IOnStatusAndCountListener",
     "android.net.ipmemorystore.IOnStatusListener",
diff --git a/tools/lint/global/checks/src/main/java/com/google/android/lint/aidl/PermissionAnnotationDetector.kt b/tools/lint/global/checks/src/main/java/com/google/android/lint/aidl/PermissionAnnotationDetector.kt
index d44c271..8d6e320 100644
--- a/tools/lint/global/checks/src/main/java/com/google/android/lint/aidl/PermissionAnnotationDetector.kt
+++ b/tools/lint/global/checks/src/main/java/com/google/android/lint/aidl/PermissionAnnotationDetector.kt
@@ -57,7 +57,10 @@
             ISSUE_MISSING_PERMISSION_ANNOTATION,
             node,
             context.getLocation(node),
-            "The method ${node.name} is not permission-annotated."
+            """
+                ${node.name} should be annotated with either @EnforcePermission, \
+                @RequiresNoPermission or @PermissionManuallyEnforced.
+            """.trimMargin()
         )
     }
 
diff --git a/tools/lint/global/checks/src/test/java/com/google/android/lint/aidl/PermissionAnnotationDetectorTest.kt b/tools/lint/global/checks/src/test/java/com/google/android/lint/aidl/PermissionAnnotationDetectorTest.kt
index 824be93..f985d02 100644
--- a/tools/lint/global/checks/src/test/java/com/google/android/lint/aidl/PermissionAnnotationDetectorTest.kt
+++ b/tools/lint/global/checks/src/test/java/com/google/android/lint/aidl/PermissionAnnotationDetectorTest.kt
@@ -73,7 +73,7 @@
             .run()
             .expect(
                 """
-                src/frameworks/base/services/java/com/android/server/Bar.java:3: Error: The method testMethod is not permission-annotated. [MissingPermissionAnnotation]
+                src/frameworks/base/services/java/com/android/server/Bar.java:3: Error: testMethod should be annotated with either @EnforcePermission, @RequiresNoPermission or @PermissionManuallyEnforced. [MissingPermissionAnnotation]
                     public void testMethod(int parameter1, int parameter2) { }
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                 1 errors, 0 warnings