Improve the structure of NNAPI AIDL Memory am: dd53d04d8c

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1666281

Change-Id: Ibcf677a263deaee456d311f8656df442c2aafada
This commit is contained in:
Michael Butler 2021-04-13 17:13:36 +00:00 committed by Automerger Merge Worker
commit a0f169b2c4
9 changed files with 213 additions and 18 deletions

View file

@ -0,0 +1,39 @@
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.common;
@VintfStability
parcelable Ashmem {
ParcelFileDescriptor fd;
long size;
}

View file

@ -0,0 +1,41 @@
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.common;
@VintfStability
parcelable MappableFile {
long length;
int prot;
ParcelFileDescriptor fd;
long offset;
}

View file

@ -1,14 +1,30 @@
/*
* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
// edit this file. It looks like you are doing that because you have modified
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
// from an interface or a field from a parcelable and it broke the build. That
// breakage is intended.
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible changes to the AIDL files built
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped

View file

@ -0,0 +1,34 @@
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.common;
import android.os.ParcelFileDescriptor;
/**
* Type that holds same memory as the "ashmem" hidl_memory type from HIDL.
*/
@VintfStability
parcelable Ashmem {
/**
* A handle to a memory region.
*/
ParcelFileDescriptor fd;
/**
* Size of the memory region in bytes.
*/
long size;
}

View file

@ -0,0 +1,53 @@
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.common;
import android.os.ParcelFileDescriptor;
/**
* A region of a file that can be mapped into memory.
*
* In Linux, MappableFile may be used with mmap as `MAP_SHARED`.
*
* MappableFile is compatible with ::android::base::MappedFile.
*/
@VintfStability
parcelable MappableFile {
/**
* Length of the mapping region in bytes.
*/
long length;
/**
* The desired memory protection for the mapping.
*
* In Linux, prot is either `PROT_NONE` (indicating that mapped pages may not be accessed) or
* the bitwise OR of one or more of the following flags:
* - `PROT_READ` (indicating that the mapped pages may be read)
* - `PROT_WRITE` (indicating that the mapped pages may be written)
*/
int prot;
/**
* A handle to a mappable file.
*/
ParcelFileDescriptor fd;
/**
* The offset in the file to the beginning of the mapping region in number of bytes.
*
* Note: Some mapping functions require that the offset is aligned to the page size.
*/
long offset;
}

View file

@ -34,6 +34,7 @@ aidl_interface {
apex_available: [
"//apex_available:platform",
"com.android.media.swcodec",
"com.android.neuralnetworks",
],
min_sdk_version: "29",
},

View file

@ -16,6 +16,7 @@ aidl_interface {
stability: "vintf",
imports: [
"android.hardware.common",
"android.hardware.graphics.common",
],
backend: {
java: {

View file

@ -33,8 +33,8 @@
package android.hardware.neuralnetworks;
@VintfStability
parcelable Memory {
android.hardware.common.NativeHandle handle;
long size;
String name;
union Memory {
android.hardware.common.Ashmem ashmem;
android.hardware.common.MappableFile mappableFile;
android.hardware.graphics.common.HardwareBuffer hardwareBuffer;
}

View file

@ -15,16 +15,26 @@
*/
package android.hardware.neuralnetworks;
import android.hardware.common.NativeHandle;
import android.os.ParcelFileDescriptor;
import android.hardware.common.Ashmem;
import android.hardware.common.MappableFile;
import android.hardware.graphics.common.HardwareBuffer;
/**
* A type that is used to pass pieces of shared memory between processes.
* The type structure mimics hidl_memory type from HIDL.
* The different types of memory that can be shared across processes.
*/
@VintfStability
parcelable Memory {
NativeHandle handle;
long size;
String name;
union Memory {
/**
* Ashmem hidl_memory type from HIDL.
*/
Ashmem ashmem;
/**
* File that can be mapped.
*/
MappableFile mappableFile;
/**
* AIDL representation of AHardwareBuffer.
*/
HardwareBuffer hardwareBuffer;
}