gralloc: Fix "Return an error if the buffer was not mapped"

Let graphics map the buffer in registerBuffer, except secure
buffers. Avoid map in register (and at allocation time) can be
done when retain/release is implemented in gralloc 1.0

Bug: 28526999
Bug: 30404840
Change-Id: I208316b89edffc7486fe74deb1b9e3352d230223
CRs-fixed: 1010697
This commit is contained in:
Naseer Ahmed 2016-05-03 15:25:02 -04:00 committed by Steve Pfetsch
parent 8dde137e44
commit 51b4299f42
1 changed files with 7 additions and 6 deletions

View File

@ -108,7 +108,7 @@ static int gralloc_map(gralloc_module_t const* module,
// metadata for secure buffers.
// If mapping a secure buffers fails, the framework needs to get
// an error code.
err = -EINVAL;
err = -EACCES;
}
//Allow mapping of metadata for all buffers including secure ones, but not
@ -170,11 +170,12 @@ int gralloc_register_buffer(gralloc_module_t const* module,
ATRACE_CALL();
if (!module || private_handle_t::validate(handle) < 0)
return -EINVAL;
// The base address received via IPC is invalid in this process
// Reset it to 0 here since it will be mapped in lock()
private_handle_t* hnd = (private_handle_t*)handle;
hnd->base = 0;
return gralloc_map_metadata(handle);
int err = gralloc_map(module, handle);
/* Do not fail register_buffer for secure buffers*/
if (err == -EACCES)
err = 0;
return err;
}
int gralloc_unregister_buffer(gralloc_module_t const* module,