跳转至

CarServiceUpdatable引用hide接口

CarServiceUpdatable

先看 CarServiceUpdatable 的 bp 文件,在 packages/services/Car/service/Android.bp 中定义如下:

// Added to car.framework module
android_app {
    name: "CarServiceUpdatable",

    defaults: ["carservice-updatable-java-defaults"],
    privileged: true,

    apex_available: ["com.android.car.framework"],
}

carservice-updatable-java-defaults

java_defaults {
    name: "carservice-updatable-java-defaults",

    visibility: [
        "//packages/services/Car:__subpackages__",
    ],

    defaults: [ "carservice-updatable-min-java-defaults" ],

    min_sdk_version: "33",
}

carservice-updatable-min-java-defaults

java_defaults {
    name: "carservice-updatable-min-java-defaults",

    srcs: [
        // add full source for all codes under p/s/Car to reduce unnecessary library allow listing.
        ":IVehicleGeneratedJavaFiles",
        ":android.car.cluster.navigation-src",
        ":android.car.watchdoglib-src",
        ":cartelemetry-cardata-proto-srcs",
        ":cartelemetryservice-proto-srcs",
        ":com.android.car.procfsinspector-client-src",
        ":statslog-Car-java-gen",
        ":iscriptexecutor_aidl",
        "proto/**/*.proto",
        "src/**/*.java",
        ],

    aidl: {
        include_dirs: [
            "packages/services/Car/procfs-inspector/client/src",
        ],
    },

    resource_dirs: ["res"],

    // Resource is still com.android.car.R
    aaptflags: [
        "--custom-package com.android.car",
    ],

    libs: [
        "android.car-module.impl",
        "android.car.builtin",
        "framework-annotations-lib",
        "framework-bluetooth",
        "framework-connectivity",
        "framework-connectivity-t.stubs.module_lib",
        "framework-statsd",
        "framework-tethering",
        "framework-wifi",
        "modules-utils-os",
        "modules-utils-preconditions",
        "modules-utils-shell-command-handler",
    ],

    static_libs: [
        "android.automotive.telemetry.internal-V2-java",  // ICarTelemetryInternal
        "android.automotive.watchdog.internal-V3-java",
        "android.frameworks.automotive.powerpolicy.internal-V1-java",
        "android.frameworks.automotive.powerpolicy-V2-java",
        "android.hidl.base-V1.0-java",
        "android.hardware.automotive.audiocontrol-V1.0-java",
        "android.hardware.automotive.audiocontrol-V2.0-java",
        "android.hardware.automotive.audiocontrol-V3-java",
        "android.hardware.automotive.remoteaccess-V1-java",
        "android.hardware.automotive.vehicle-V2-java",
        "android.hardware.automotive.vehicle.property-V2-java",
        "android.hardware.automotive.vehicle-V2.0-java",
        "android.hardware.health-V1.0-java",
        "android.hardware.health-V2.0-java",
        "android.hardware.automotive.occupant_awareness-V1-java",
    ],

    proto: {
        type: "lite",
    },

    optimize: {
        proguard_flags_files: ["proguard.flags"],
        enabled: false,
    },

    // Disable build in PDK, missing aidl import breaks build
    product_variables: {
        pdk: {
            enabled: false,
        },
    },

    sdk_version: "module_current",    

    java_resources: [
        ":VehicleHalDefaultProperties_JSON",
    ],
}

这里可以看到 sdk_version 设置了 module_current,表明:

允许访问平台API,包括当前开发版本中未发布的API;但不包括 隐藏的API,也就是 hide 接口。

需要改成 platform_apis: true,如下:

//sdk_version: "module_current",
platform_apis: true,

这样改之后,会报一些 aidl 错误,还需要在 aidl 的 include_dirs 里新增:"frameworks/native/aidl/binder"

改动如下:

aidl: {
    include_dirs: [
        "packages/services/Car/procfs-inspector/client/src",
        "frameworks/native/aidl/binder",
    ],
},

改完之后,CarServiceUpdatable 模块就可以使用 hide 接口了。

评论