gralloc1: Do not delete on close
gralloc device is a singleton, initialize it in the constructor
and never close it.
CRs-Fixed: 2022072
Change-Id: I216c235e05c5e60a85a9bd91825a47200d0ab8b0
diff --git a/libgralloc1/gr_device_impl.h b/libgralloc1/gr_device_impl.h
index 80c3182..5a3e7e9 100644
--- a/libgralloc1/gr_device_impl.h
+++ b/libgralloc1/gr_device_impl.h
@@ -44,8 +44,6 @@
class GrallocImpl : public gralloc1_device_t {
public:
- ~GrallocImpl();
- bool Init();
static int CloseDevice(hw_device_t *device);
static void GetCapabilities(struct gralloc1_device *device, uint32_t *out_count,
int32_t * /*gralloc1_capability_t*/ out_capabilities);
@@ -54,7 +52,11 @@
static GrallocImpl* GetInstance(const struct hw_module_t *module) {
static GrallocImpl *instance = new GrallocImpl(module);
- return instance;
+ if (instance->IsInitialized()) {
+ return instance;
+ } else {
+ return nullptr;
+ }
}
private:
@@ -113,7 +115,12 @@
static gralloc1_error_t Gralloc1Perform(gralloc1_device_t *device, int operation, ...);
explicit GrallocImpl(const hw_module_t *module);
+ ~GrallocImpl();
+ bool Init();
+ bool IsInitialized() const { return initalized_; }
+
BufferManager *buf_mgr_ = NULL;
+ bool initalized_ = false;
};
} // namespace gralloc1