Merge "Fix the translation doesn't work" into udc-dev

This commit is contained in:
Joanne Chung
2023-03-16 02:16:25 +00:00
committed by Android (Google) Code Review

View File

@@ -37,6 +37,7 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo; import android.content.pm.ServiceInfo;
import android.os.Binder;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.os.IRemoteCallback; import android.os.IRemoteCallback;
@@ -160,11 +161,20 @@ final class TranslationManagerServiceImpl extends
return null; return null;
} }
final ComponentName serviceComponent = ComponentName.unflattenFromString(serviceName); final ComponentName serviceComponent = ComponentName.unflattenFromString(serviceName);
if (!isServiceAvailableForUser(serviceComponent)) { boolean isServiceAvailableForUser;
final long identity = Binder.clearCallingIdentity();
try {
isServiceAvailableForUser = isServiceAvailableForUser(serviceComponent);
if (mMaster.verbose) { if (mMaster.verbose) {
Slog.v(TAG, "ensureRemoteServiceLocked(): " + serviceComponent Slog.v(TAG, "ensureRemoteServiceLocked(): isServiceAvailableForUser="
+ " is not available,"); + isServiceAvailableForUser);
} }
} finally {
Binder.restoreCallingIdentity(identity);
}
if (!isServiceAvailableForUser) {
Slog.w(TAG, "ensureRemoteServiceLocked(): " + serviceComponent
+ " is not available,");
return null; return null;
} }
mRemoteTranslationService = new RemoteTranslationService(getContext(), serviceComponent, mRemoteTranslationService = new RemoteTranslationService(getContext(), serviceComponent,