diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-15 09:35:23 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-15 09:35:23 +0000 |
commit | 4f73884441d6a5c6ba4af7e5026807822aa034a0 (patch) | |
tree | 0329901240818b16106c9a391165d84c2ba2f236 /adservices/framework/java/android/adservices/appsetid/AppSetIdManager.java | |
parent | 0856715d45086bed852b1cade242e59c57d36912 (diff) | |
parent | b76a4baee27df1f378c4bdfbf8853dff806b27a0 (diff) | |
download | AdServices-4f73884441d6a5c6ba4af7e5026807822aa034a0.tar.gz |
Snap for 11224086 from b76a4baee27df1f378c4bdfbf8853dff806b27a0 to mainline-tzdata5-release
Change-Id: I95c339f285645996dcabbcdad85dd1a9be945531
Diffstat (limited to 'adservices/framework/java/android/adservices/appsetid/AppSetIdManager.java')
-rw-r--r-- | adservices/framework/java/android/adservices/appsetid/AppSetIdManager.java | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/adservices/framework/java/android/adservices/appsetid/AppSetIdManager.java b/adservices/framework/java/android/adservices/appsetid/AppSetIdManager.java index 1308979755..b305dbb18a 100644 --- a/adservices/framework/java/android/adservices/appsetid/AppSetIdManager.java +++ b/adservices/framework/java/android/adservices/appsetid/AppSetIdManager.java @@ -23,7 +23,6 @@ import android.annotation.NonNull; import android.app.sdksandbox.SandboxedSdkContext; import android.content.Context; import android.os.Build; -import android.os.LimitExceededException; import android.os.OutcomeReceiver; import android.os.RemoteException; import android.os.SystemClock; @@ -102,11 +101,16 @@ public class AppSetIdManager { } @NonNull - private IAppSetIdService getService() { - IAppSetIdService service = mServiceBinder.getService(); - if (service == null) { - throw new IllegalStateException("Unable to find the service"); + private IAppSetIdService getService( + @CallbackExecutor Executor executor, OutcomeReceiver<AppSetId, Exception> callback) { + IAppSetIdService service = null; + try { + service = mServiceBinder.getService(); + } catch (RuntimeException e) { + LogUtil.e(e, "Failed binding to AppSetId service"); + executor.execute(() -> callback.onError(e)); } + return service; } @@ -120,9 +124,6 @@ public class AppSetIdManager { * * @param executor The executor to run callback. * @param callback The callback that's called after appsetid are available or an error occurs. - * @throws SecurityException if caller is not authorized to call this API. - * @throws IllegalStateException if this API is not available. - * @throws LimitExceededException if rate limit was reached. */ @NonNull public void getAppSetId( @@ -134,7 +135,7 @@ public class AppSetIdManager { new CallerMetadata.Builder() .setBinderElapsedTimestamp(SystemClock.elapsedRealtime()) .build(); - final IAppSetIdService service = getService(); + String appPackageName = ""; String sdkPackageName = ""; // First check if context is SandboxedSdkContext or not @@ -148,6 +149,12 @@ public class AppSetIdManager { appPackageName = getAppSetIdRequestContext.getPackageName(); } try { + IAppSetIdService service = getService(executor, callback); + if (service == null) { + LogUtil.d("Unable to find AppSetId service"); + return; + } + service.getAppSetId( new GetAppSetIdParam.Builder() .setAppPackageName(appPackageName) |