Factor out remoteauth dependencies to variables

This will allow using different values for the variables without having
merge conflicts in the dependencies list for each build rule.

Bug: 295788084
Test: m
Change-Id: I7b64a5a01d1f8139e7ce30ce95903d71cb09de9f
This commit is contained in:
Remi NGUYEN VAN
2023-08-14 15:34:20 +09:00
parent c022bd47a8
commit c41daa4106
7 changed files with 31 additions and 12 deletions

View File

@@ -19,6 +19,14 @@ package {
default_applicable_licenses: ["Android-Apache-2.0"], default_applicable_licenses: ["Android-Apache-2.0"],
} }
framework_remoteauth_srcs = [":framework-remoteauth-java-sources"]
framework_remoteauth_api_srcs = []
java_defaults {
name: "enable-remoteauth-targets",
enabled: true,
}
// Include build rules from Sources.bp // Include build rules from Sources.bp
build = ["Sources.bp"] build = ["Sources.bp"]
@@ -43,8 +51,7 @@ java_defaults {
":framework-connectivity-tiramisu-updatable-sources", ":framework-connectivity-tiramisu-updatable-sources",
":framework-nearby-java-sources", ":framework-nearby-java-sources",
":framework-thread-sources", ":framework-thread-sources",
":framework-remoteauth-java-sources", ] + framework_remoteauth_srcs,
],
libs: [ libs: [
"unsupportedappusage", "unsupportedappusage",
"app-compat-annotations", "app-compat-annotations",
@@ -115,6 +122,7 @@ java_sdk_library {
"framework-connectivity-t-defaults", "framework-connectivity-t-defaults",
"enable-framework-connectivity-t-targets", "enable-framework-connectivity-t-targets",
], ],
api_srcs: framework_remoteauth_api_srcs,
// Do not add static_libs to this library: put them in framework-connectivity instead. // Do not add static_libs to this library: put them in framework-connectivity instead.
// The jarjar rules are only so that references to jarjared utils in // The jarjar rules are only so that references to jarjared utils in
// framework-connectivity-pre-jarjar match at runtime. // framework-connectivity-pre-jarjar match at runtime.

View File

@@ -27,6 +27,7 @@ java_library {
srcs: [":remoteauth-service-srcs"], srcs: [":remoteauth-service-srcs"],
required: ["libremoteauth_jni_rust_defaults"], required: ["libremoteauth_jni_rust_defaults"],
defaults: [ defaults: [
"enable-remoteauth-targets",
"framework-system-server-module-defaults", "framework-system-server-module-defaults",
], ],
libs: [ libs: [

View File

@@ -27,6 +27,7 @@ import com.android.internal.util.Preconditions;
/** Service implementing remoteauth functionality. */ /** Service implementing remoteauth functionality. */
public class RemoteAuthService extends IRemoteAuthService.Stub { public class RemoteAuthService extends IRemoteAuthService.Stub {
public static final String TAG = "RemoteAuthService"; public static final String TAG = "RemoteAuthService";
public static final String SERVICE_NAME = Context.REMOTE_AUTH_SERVICE;
public RemoteAuthService(Context context) { public RemoteAuthService(Context context) {
Preconditions.checkNotNull(context); Preconditions.checkNotNull(context);

View File

@@ -18,7 +18,10 @@ package {
android_test { android_test {
name: "RemoteAuthUnitTests", name: "RemoteAuthUnitTests",
defaults: ["mts-target-sdk-version-current"], defaults: [
"enable-remoteauth-targets",
"mts-target-sdk-version-current"
],
sdk_version: "test_current", sdk_version: "test_current",
min_sdk_version: "31", min_sdk_version: "31",

View File

@@ -19,6 +19,8 @@ package {
default_applicable_licenses: ["Android-Apache-2.0"], default_applicable_licenses: ["Android-Apache-2.0"],
} }
service_remoteauth_pre_jarjar_lib = "service-remoteauth-pre-jarjar"
// Include build rules from Sources.bp // Include build rules from Sources.bp
build = ["Sources.bp"] build = ["Sources.bp"]
@@ -56,7 +58,7 @@ java_library {
"service-connectivity-pre-jarjar", "service-connectivity-pre-jarjar",
"service-nearby-pre-jarjar", "service-nearby-pre-jarjar",
"service-thread-pre-jarjar", "service-thread-pre-jarjar",
"service-remoteauth-pre-jarjar", service_remoteauth_pre_jarjar_lib,
"ServiceConnectivityResources", "ServiceConnectivityResources",
"unsupportedappusage", "unsupportedappusage",
], ],

View File

@@ -17,7 +17,6 @@
package com.android.server; package com.android.server;
import android.content.Context; import android.content.Context;
import android.remoteauth.RemoteAuthManager;
import android.util.Log; import android.util.Log;
import com.android.modules.utils.build.SdkLevel; import com.android.modules.utils.build.SdkLevel;
@@ -90,8 +89,8 @@ public final class ConnectivityServiceInitializer extends SystemService {
} }
if (mRemoteAuthService != null) { if (mRemoteAuthService != null) {
Log.i(TAG, "Registering " + RemoteAuthManager.REMOTE_AUTH_SERVICE); Log.i(TAG, "Registering " + RemoteAuthService.SERVICE_NAME);
publishBinderService(RemoteAuthManager.REMOTE_AUTH_SERVICE, mRemoteAuthService, publishBinderService(RemoteAuthService.SERVICE_NAME, mRemoteAuthService,
/* allowIsolated= */ false); /* allowIsolated= */ false);
} }
} }
@@ -157,8 +156,7 @@ public final class ConnectivityServiceInitializer extends SystemService {
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
// RemoteAuth is not yet supported in all branches // RemoteAuth is not yet supported in all branches
// TODO: remove catch clause when it is available. // TODO: remove catch clause when it is available.
Log.i(TAG, "Skipping unsupported service " Log.i(TAG, "Skipping unsupported service " + RemoteAuthService.SERVICE_NAME);
+ RemoteAuthManager.REMOTE_AUTH_SERVICE);
return null; return null;
} }
} }

View File

@@ -19,6 +19,12 @@ package {
default_applicable_licenses: ["Android-Apache-2.0"], default_applicable_licenses: ["Android-Apache-2.0"],
} }
service_remoteauth_pre_jarjar_lib = "service-remoteauth-pre-jarjar"
// The above variables may have different values
// depending on the branch, and this comment helps
// separate them from the rest of the file to avoid merge conflicts
aidl_interface { aidl_interface {
name: "connectivity_native_aidl_interface", name: "connectivity_native_aidl_interface",
local_include_dir: "binder", local_include_dir: "binder",
@@ -236,7 +242,7 @@ java_defaults {
"service-connectivity-pre-jarjar", "service-connectivity-pre-jarjar",
"service-connectivity-tiramisu-pre-jarjar", "service-connectivity-tiramisu-pre-jarjar",
"service-nearby-pre-jarjar", "service-nearby-pre-jarjar",
"service-remoteauth-pre-jarjar", service_remoteauth_pre_jarjar_lib,
"service-thread-pre-jarjar", "service-thread-pre-jarjar",
], ],
// The below libraries are not actually needed to build since no source is compiled // The below libraries are not actually needed to build since no source is compiled
@@ -361,7 +367,7 @@ java_genrule {
java_genrule { java_genrule {
name: "service-remoteauth-jarjar-gen", name: "service-remoteauth-jarjar-gen",
tool_files: [ tool_files: [
":service-remoteauth-pre-jarjar{.jar}", ":" + service_remoteauth_pre_jarjar_lib + "{.jar}",
"jarjar-excludes.txt", "jarjar-excludes.txt",
], ],
tools: [ tools: [
@@ -369,7 +375,7 @@ java_genrule {
], ],
out: ["service_remoteauth_jarjar_rules.txt"], out: ["service_remoteauth_jarjar_rules.txt"],
cmd: "$(location jarjar-rules-generator) " + cmd: "$(location jarjar-rules-generator) " +
"$(location :service-remoteauth-pre-jarjar{.jar}) " + "$(location :" + service_remoteauth_pre_jarjar_lib + "{.jar}) " +
"--prefix com.android.server.remoteauth " + "--prefix com.android.server.remoteauth " +
"--excludes $(location jarjar-excludes.txt) " + "--excludes $(location jarjar-excludes.txt) " +
"--output $(out)", "--output $(out)",