display: Create QService binder interface.
Add QService binder interface to enable communication
to display by the mediaserver for Securing/Unsecuring start and end
notifications.
Create separate lib for external.
Clear reserved field before applying format.
Change-Id: I463c9c6deac7587bd0c4e0b84513b5d0b5dd7e98
diff --git a/Android.mk b/Android.mk
index 9a17e5f..80d5f46 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,7 +1,7 @@
ifneq ($(filter msm8960,$(TARGET_BOARD_PLATFORM)),)
display-hals := libgralloc libgenlock libcopybit liblight
-display-hals +=libhwcomposer liboverlay libqdutils
+display-hals += libhwcomposer liboverlay libqdutils libexternal libqservice
include $(call all-named-subdir-makefiles,$(display-hals))
endif
diff --git a/common.mk b/common.mk
index ecf5d66..30896a8 100644
--- a/common.mk
+++ b/common.mk
@@ -4,6 +4,9 @@
common_includes += hardware/qcom/display/liboverlay
common_includes += hardware/qcom/display/libcopybit
common_includes += hardware/qcom/display/libqdutils
+common_includes += hardware/qcom/display/libhwcomposer
+common_includes += hardware/qcom/display/libexternal
+common_includes += hardware/qcom/display/libqservice
ifeq ($(TARGET_USES_POST_PROCESSING),true)
common_flags += -DUSES_POST_PROCESSING
@@ -24,10 +27,9 @@
common_deps :=
kernel_includes :=
-#Kernel includes
+
+#Kernel includes. Not being executed on JB+
ifeq ($(call is-vendor-board-platform,QCOM),true)
common_deps += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
kernel_includes += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
endif
-
-
diff --git a/libexternal/Android.mk b/libexternal/Android.mk
new file mode 100644
index 0000000..cdbbd5c
--- /dev/null
+++ b/libexternal/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+include $(LOCAL_PATH)/../common.mk
+include $(CLEAR_VARS)
+LOCAL_MODULE := libexternal
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(common_includes) $(kernel_includes)
+LOCAL_SHARED_LIBRARIES := $(common_libs) liboverlay
+LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"external\"
+LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
+LOCAL_SRC_FILES := external.cpp
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/libhwcomposer/hwc_external.cpp b/libexternal/external.cpp
similarity index 90%
rename from libhwcomposer/hwc_external.cpp
rename to libexternal/external.cpp
index d35a622..2142125 100644
--- a/libhwcomposer/hwc_external.cpp
+++ b/libexternal/external.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
*
* Not a Contribution, Apache license notifications and license are
* retained for attribution purposes only.
@@ -34,7 +34,10 @@
#include <sys/resource.h>
#include <cutils/properties.h>
#include "hwc_utils.h"
-#include "hwc_external.h"
+#include "external.h"
+#include "overlayUtils.h"
+
+using namespace android;
namespace qhwc {
@@ -47,13 +50,55 @@
ExternalDisplay::ExternalDisplay(hwc_context_t* ctx):mFd(-1),
- mCurrentMode(-1), mHwcContext(ctx)
+ mCurrentMode(-1), mExternalDisplay(0), mModeCount(0), mHwcContext(ctx)
{
memset(&mVInfo, 0, sizeof(mVInfo));
//Enable HPD for HDMI
writeHPDOption(1);
}
+void ExternalDisplay::setEDIDMode(int resMode) {
+ ALOGD_IF(DEBUG,"resMode=%d ", resMode);
+ int extDispType;
+ {
+ Mutex::Autolock lock(mExtDispLock);
+ extDispType = mExternalDisplay;
+ setExternalDisplay(0);
+ setResolution(resMode);
+ }
+ setExternalDisplay(extDispType);
+}
+
+void ExternalDisplay::setHPD(uint32_t startEnd) {
+ ALOGD_IF(DEBUG,"HPD enabled=%d", startEnd);
+ writeHPDOption(startEnd);
+}
+
+void ExternalDisplay::setActionSafeDimension(int w, int h) {
+ ALOGD_IF(DEBUG,"ActionSafe w=%d h=%d", w, h);
+ Mutex::Autolock lock(mExtDispLock);
+ overlay::utils::ActionSafe::getInstance()->setDimension(w, h);
+ setExternalDisplay(mExternalDisplay);
+}
+
+int ExternalDisplay::getModeCount() const {
+ ALOGD_IF(DEBUG,"HPD mModeCount=%d", mModeCount);
+ Mutex::Autolock lock(mExtDispLock);
+ return mModeCount;
+}
+
+void ExternalDisplay::getEDIDModes(int *out) const {
+ Mutex::Autolock lock(mExtDispLock);
+ for(int i = 0;i < mModeCount;i++) {
+ out[i] = mEDIDModes[i];
+ }
+}
+
+int ExternalDisplay::getExternalDisplay() const {
+ Mutex::Autolock lock(mExtDispLock);
+ return mExternalDisplay;
+}
+
ExternalDisplay::~ExternalDisplay()
{
closeFrameBuffer();
@@ -84,7 +129,7 @@
info.reserved[0] = 0;
info.reserved[1] = 0;
info.reserved[2] = 0;
- info.reserved[3] = info.reserved[3] | (video_format << 16);
+ info.reserved[3] = (info.reserved[3] & 0xFFFF) | (video_format << 16);
info.xoffset = 0;
info.yoffset = 0;
@@ -272,7 +317,7 @@
int ExternalDisplay::getBestMode() {
int bestOrder = 0;
int bestMode = m640x480p60_4_3;
-
+ Mutex::Autolock lock(mExtDispLock);
// for all the edid read, get the best mode
for(int i = 0; i < mModeCount; i++) {
int mode = mEDIDModes[i];
@@ -354,12 +399,6 @@
}
}
-
-int ExternalDisplay::getExternalDisplay() const
-{
- return mExternalDisplay;
-}
-
void ExternalDisplay::setExternalDisplay(int connected)
{
diff --git a/libhwcomposer/hwc_external.h b/libexternal/external.h
similarity index 83%
rename from libhwcomposer/hwc_external.h
rename to libexternal/external.h
index 55773c0..09cde3b 100644
--- a/libhwcomposer/hwc_external.h
+++ b/libexternal/external.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
*
* Not a Contribution, Apache license notifications and license are
* retained for attribution purposes only.
@@ -21,7 +21,8 @@
#ifndef HWC_EXTERNAL_DISPLAY_H
#define HWC_EXTERNAL_DISPLAY_H
-#include <fb_priv.h>
+#include <utils/threads.h>
+#include <linux/fb.h>
struct hwc_context_t;
@@ -41,15 +42,20 @@
EXT_MIRRORING_OFF,
EXT_MIRRORING_ON,
};
- public:
+public:
ExternalDisplay(hwc_context_t* ctx);
~ExternalDisplay();
+ int getModeCount() const;
+ void getEDIDModes(int *out) const;
int getExternalDisplay() const;
void setExternalDisplay(int connected);
bool commit();
int enableHDMIVsync(int enable);
+ void setHPD(uint32_t startEnd);
+ void setEDIDMode(int resMode);
+ void setActionSafeDimension(int w, int h);
- private:
+private:
bool readResolution();
int parseResolution(char* edidStr, int* edidModes);
void setResolution(int ID);
@@ -62,9 +68,11 @@
int getBestMode();
void resetInfo();
+ mutable android::Mutex mExtDispLock;
int mFd;
- int mExternalDisplay;
int mCurrentMode;
+ int mExternalDisplay;
+ int mResolutionMode;
char mEDIDs[128];
int mEDIDModes[64];
int mModeCount;
diff --git a/libhwcomposer/Android.mk b/libhwcomposer/Android.mk
index 51f1e00..343686c 100644
--- a/libhwcomposer/Android.mk
+++ b/libhwcomposer/Android.mk
@@ -6,14 +6,15 @@
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes) $(kernel_includes)
LOCAL_SHARED_LIBRARIES := $(common_libs) libEGL liboverlay libgenlock \
- libqdutils libhardware_legacy libdl libmemalloc
+ libexternal libqdutils libhardware_legacy \
+ libdl libmemalloc libqservice
+
LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"hwcomposer\"
LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
LOCAL_SRC_FILES := hwc.cpp \
hwc_video.cpp \
hwc_utils.cpp \
hwc_uimirror.cpp \
- hwc_external.cpp \
hwc_uevents.cpp \
hwc_copybit.cpp \
hwc_mdpcomp.cpp \
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 3de74b0..a28750d 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@
#include "hwc_video.h"
#include "hwc_uimirror.h"
#include "hwc_copybit.h"
-#include "hwc_external.h"
+#include "external.h"
#include "hwc_mdpcomp.h"
#include "hwc_extonly.h"
@@ -81,14 +81,19 @@
hwc_context_t* ctx = (hwc_context_t*)(dev);
ctx->overlayInUse = false;
+ //reset for this draw round
+ VideoOverlay::reset();
+ ExtOnly::reset();
+ UIMirrorOverlay::reset();
+
+ //If securing of h/w in progress skip comp using overlay.
+ if(ctx->mSecuring == true) return 0;
+
for (uint32_t i = 0; i < numDisplays; i++) {
hwc_display_contents_1_t *list = displays[i];
//XXX: Actually handle the multiple displays
if (LIKELY(list && list->numHwLayers)) {
ctx->dpys[i] = list->dpy;
- //reset for this draw round
- VideoOverlay::reset();
- ExtOnly::reset();
if(ctx->isPoweredDown)
ALOGW("SF called %s after a POWERDOWN", __FUNCTION__);
diff --git a/libhwcomposer/hwc_extonly.cpp b/libhwcomposer/hwc_extonly.cpp
index ab50972..bc8bfe0 100644
--- a/libhwcomposer/hwc_extonly.cpp
+++ b/libhwcomposer/hwc_extonly.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
*/
#include "hwc_extonly.h"
-#include "hwc_external.h"
+#include "external.h"
#include "hwc_qbuf.h"
namespace qhwc {
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 894da1f..146b6f2 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
* Not a Contribution, Apache license notifications and license are retained
* for attribution purposes only.
*
@@ -18,7 +18,7 @@
#include "hwc_mdpcomp.h"
#include "hwc_qbuf.h"
-#include "hwc_external.h"
+#include "external.h"
#define SUPPORT_4LAYER 0
diff --git a/libhwcomposer/hwc_uevents.cpp b/libhwcomposer/hwc_uevents.cpp
index 8c833f7..f9e8a2d 100644
--- a/libhwcomposer/hwc_uevents.cpp
+++ b/libhwcomposer/hwc_uevents.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
*
* Not a Contribution, Apache license notifications and license are
* retained for attribution purposes only.
@@ -26,7 +26,7 @@
#include <string.h>
#include <stdlib.h>
#include "hwc_utils.h"
-#include "hwc_external.h"
+#include "external.h"
namespace qhwc {
diff --git a/libhwcomposer/hwc_uimirror.cpp b/libhwcomposer/hwc_uimirror.cpp
index c5f22af..f904d69 100644
--- a/libhwcomposer/hwc_uimirror.cpp
+++ b/libhwcomposer/hwc_uimirror.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
*
* Not a Contribution, Apache license notifications and license are
* retained for attribution purposes only.
@@ -22,7 +22,7 @@
#include <gralloc_priv.h>
#include <fb_priv.h>
#include "hwc_uimirror.h"
-#include "hwc_external.h"
+#include "external.h"
namespace qhwc {
@@ -54,6 +54,10 @@
ovutils::eOverlayState UIMirrorOverlay::sState = ovutils::OV_CLOSED;
bool UIMirrorOverlay::sIsUiMirroringOn = false;
+void UIMirrorOverlay::reset() {
+ sIsUiMirroringOn = false;
+ sState = ovutils::OV_CLOSED;
+}
//Prepare the overlay for the UI mirroring
bool UIMirrorOverlay::prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list) {
@@ -101,12 +105,10 @@
}
ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_FLAGS_NONE;
- /* - TODO: Secure content
- if (hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER) {
- ovutils::setMdpFlags(mdpFlags,
- ovutils::OV_MDP_SECURE_OVERLAY_SESSION);
- }
- */
+ if(ctx->mSecureMode) {
+ ovutils::setMdpFlags(mdpFlags,
+ ovutils::OV_MDP_SECURE_OVERLAY_SESSION);
+ }
ovutils::PipeArgs parg(mdpFlags,
info,
diff --git a/libhwcomposer/hwc_uimirror.h b/libhwcomposer/hwc_uimirror.h
index da03c5f..a1bf9ba 100644
--- a/libhwcomposer/hwc_uimirror.h
+++ b/libhwcomposer/hwc_uimirror.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
*
* Not a Contribution, Apache license notifications and license are
* retained for attribution purposes only.
@@ -33,6 +33,8 @@
static bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list);
// Draws layer if this feature is on
static bool draw(hwc_context_t *ctx);
+ //Reset values
+ static void reset();
private:
//Configures overlay
static bool configure(hwc_context_t *ctx, hwc_display_contents_1_t *list);
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index f523856..350684b 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,9 +25,10 @@
#include "hwc_video.h"
#include "hwc_qbuf.h"
#include "hwc_copybit.h"
-#include "hwc_external.h"
+#include "external.h"
#include "hwc_mdpcomp.h"
#include "hwc_extonly.h"
+#include "QService.h"
namespace qhwc {
@@ -44,6 +45,7 @@
{
openFramebufferDevice(ctx);
ctx->mOverlay = overlay::Overlay::getInstance();
+ ctx->mQService = qService::QService::getInstance(ctx);
ctx->qbuf = new QueuedBufferStore();
ctx->mMDP.version = qdutils::MDPVersion::getInstance().getMDPVersion();
ctx->mMDP.hasOverlay = qdutils::MDPVersion::getInstance().hasOverlay();
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index 9cb6e15..184d967 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,6 +32,10 @@
struct hwc_context_t;
struct framebuffer_device_t;
+namespace qService {
+class QService;
+}
+
namespace overlay {
class Overlay;
}
@@ -151,12 +155,21 @@
//QueuedBufferStore to hold buffers for overlay
qhwc::QueuedBufferStore *qbuf;
+ //QService object
+ qService::QService *mQService;
+
// External display related information
qhwc::ExternalDisplay *mExtDisplay;
qhwc::MDPInfo mMDP;
bool isPoweredDown;
+
+ //Securing in progress indicator
+ bool mSecuring;
+
+ //Display in secure mode indicator
+ bool mSecureMode;
};
#endif //HWC_UTILS_H
diff --git a/libhwcomposer/hwc_video.cpp b/libhwcomposer/hwc_video.cpp
index bedd9e9..141d83b 100644
--- a/libhwcomposer/hwc_video.cpp
+++ b/libhwcomposer/hwc_video.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
#include <overlay.h>
#include "hwc_qbuf.h"
#include "hwc_video.h"
-#include "hwc_external.h"
+#include "external.h"
namespace qhwc {
diff --git a/liboverlay/overlayCtrl.cpp b/liboverlay/overlayCtrl.cpp
index bb91529..9047f3e 100644
--- a/liboverlay/overlayCtrl.cpp
+++ b/liboverlay/overlayCtrl.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008 The Android Open Source Project
-* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
+* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,6 +75,8 @@
return true;
}
+utils::ActionSafe* utils::ActionSafe::sActionSafe = NULL;
+
utils::Dim Ctrl::getAspectRatio(const utils::Whf& whf) const
{
utils::Whf inWhf(whf.w, whf.h, mMdp.getSrcWhf().format);
@@ -107,11 +109,9 @@
if (inWhf.w > fbWidth) inWhf.w = fbWidth;
if (inWhf.h > fbHeight) inWhf.h = fbHeight;
- char value[PROPERTY_VALUE_MAX];
- property_get("hw.actionsafe.width", value, "0");
- float asWidth = atof(value);
- property_get("hw.actionsafe.height", value, "0");
- float asHeight = atof(value);
+ float asWidth = utils::ActionSafe::getInstance()->getHeight();
+ float asHeight = utils::ActionSafe::getInstance()->getWidth();
+
inWhf.w = inWhf.w * (1.0f - asWidth / 100.0f);
inWhf.h = inWhf.h * (1.0f - asHeight / 100.0f);
diff --git a/liboverlay/overlayUtils.h b/liboverlay/overlayUtils.h
index e5f7119..f308b95 100644
--- a/liboverlay/overlayUtils.h
+++ b/liboverlay/overlayUtils.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
+* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -238,6 +238,28 @@
uint32_t size;
};
+class ActionSafe {
+private:
+ ActionSafe() : mWidth(0.0f), mHeight(0.0f) { };
+ float mWidth;
+ float mHeight;
+ static ActionSafe *sActionSafe;
+public:
+ ~ActionSafe() { };
+ static ActionSafe* getInstance() {
+ if(!sActionSafe) {
+ sActionSafe = new ActionSafe();
+ }
+ return sActionSafe;
+ }
+ void setDimension(int w, int h) {
+ mWidth = (float)w;
+ mHeight = (float)h;
+ }
+ float getWidth() { return mWidth; }
+ float getHeight() { return mHeight; }
+};
+
enum { MAX_PATH_LEN = 256 };
/**
diff --git a/libqservice/Android.mk b/libqservice/Android.mk
new file mode 100644
index 0000000..ee1fe21
--- /dev/null
+++ b/libqservice/Android.mk
@@ -0,0 +1,14 @@
+LOCAL_PATH := $(call my-dir)
+include $(LOCAL_PATH)/../common.mk
+include $(CLEAR_VARS)
+LOCAL_MODULE := libqservice
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(common_includes) $(kernel_includes)
+LOCAL_SHARED_LIBRARIES := $(common_libs) libexternal libbinder
+LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"qService\"
+LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
+LOCAL_SRC_FILES := QService.cpp \
+ IQService.cpp
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/libqservice/IQService.cpp b/libqservice/IQService.cpp
new file mode 100644
index 0000000..5f71732
--- /dev/null
+++ b/libqservice/IQService.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
+ *
+ * Not a Contribution, Apache license notifications and license are
+ * retained for attribution purposes only.
+
+ * 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.
+ */
+
+#include <fcntl.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <binder/Parcel.h>
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+#include <binder/IPCThreadState.h>
+#include <utils/Errors.h>
+
+#include <IQService.h>
+
+using namespace android;
+
+// ---------------------------------------------------------------------------
+
+namespace qService {
+
+class BpQService : public BpInterface<IQService>
+{
+public:
+ BpQService(const sp<IBinder>& impl)
+ : BpInterface<IQService>(impl) {}
+
+ virtual void securing(uint32_t startEnd) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IQService::getInterfaceDescriptor());
+ data.writeInt32(startEnd);
+ remote()->transact(SECURING, data, &reply);
+ }
+
+ virtual void unsecuring(uint32_t startEnd) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IQService::getInterfaceDescriptor());
+ data.writeInt32(startEnd);
+ remote()->transact(UNSECURING, data, &reply);
+ }
+};
+
+IMPLEMENT_META_INTERFACE(QService, "android.display.IQService");
+
+// ----------------------------------------------------------------------
+
+static void getProcName(int pid, char *buf, int size);
+
+status_t BnQService::onTransact(
+ uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
+{
+ // IPC should be from mediaserver only
+ IPCThreadState* ipc = IPCThreadState::self();
+ const int callerPid = ipc->getCallingPid();
+ const size_t MAX_BUF_SIZE = 1024;
+ const char *mediaServer = "/system/bin/mediaserver";
+ char callingProcName[MAX_BUF_SIZE] = {0};
+
+ getProcName(callerPid, callingProcName, MAX_BUF_SIZE);
+ if(strcmp(callingProcName, mediaServer) != 0 ) { //Some rogue process
+ ALOGE("No Permission:can't access display.qservice pid=%d process=%s",
+ callerPid, callingProcName);
+ return PERMISSION_DENIED;
+ }
+
+ switch(code) {
+ case SECURING: {
+ CHECK_INTERFACE(IQService, data, reply);
+ uint32_t startEnd = data.readInt32();
+ securing(startEnd);
+ return NO_ERROR;
+ } break;
+ case UNSECURING: {
+ CHECK_INTERFACE(IQService, data, reply);
+ uint32_t startEnd = data.readInt32();
+ unsecuring(startEnd);
+ return NO_ERROR;
+ } break;
+ default:
+ return BBinder::onTransact(code, data, reply, flags);
+ }
+}
+
+//Helper
+static void getProcName(int pid, char *buf, int size) {
+ int fd = -1;
+ snprintf(buf, size, "/proc/%d/cmdline", pid);
+ fd = open(buf, O_RDONLY);
+ if (fd < 0) {
+ strcpy(buf, "Unknown");
+ } else {
+ int len = read(fd, buf, size - 1);
+ buf[len] = 0;
+ close(fd);
+ }
+}
+
+}; // namespace qService
diff --git a/libqservice/IQService.h b/libqservice/IQService.h
new file mode 100644
index 0000000..8647efa
--- /dev/null
+++ b/libqservice/IQService.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2012, The Linux Foundation. All rights reserved.
+ *
+ * Not a Contribution, Apache license notifications and license are
+ * retained for attribution purposes only.
+
+ * 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.
+ */
+
+#ifndef ANDROID_IQSERVICE_H
+#define ANDROID_IQSERVICE_H
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <utils/Errors.h>
+#include <utils/RefBase.h>
+#include <binder/IInterface.h>
+
+namespace qService {
+// ----------------------------------------------------------------------------
+class IQService : public android::IInterface
+{
+public:
+ DECLARE_META_INTERFACE(QService);
+ enum {
+ SECURING = 0, // Hardware securing start/end notification
+ UNSECURING, // Hardware unsecuring start/end notification
+ };
+ enum {
+ END = 0,
+ START,
+ };
+ virtual void securing(uint32_t startEnd) = 0;
+ virtual void unsecuring(uint32_t startEnd) = 0;
+};
+
+// ----------------------------------------------------------------------------
+
+class BnQService : public android::BnInterface<IQService>
+{
+public:
+ virtual android::status_t onTransact( uint32_t code,
+ const android::Parcel& data,
+ android::Parcel* reply,
+ uint32_t flags = 0);
+};
+
+// ----------------------------------------------------------------------------
+}; // namespace qService
+
+#endif // ANDROID_IQSERVICE_H
diff --git a/libqservice/QService.cpp b/libqservice/QService.cpp
new file mode 100644
index 0000000..77a9518
--- /dev/null
+++ b/libqservice/QService.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of Code Aurora Forum, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <QService.h>
+#include <hwc_utils.h>
+
+#define QSERVICE_DEBUG 0
+
+using namespace android;
+
+namespace qService {
+
+QService* QService::sQService = NULL;
+// ----------------------------------------------------------------------------
+QService::QService(hwc_context_t *ctx):mHwcContext(ctx)
+{
+ ALOGD_IF(QSERVICE_DEBUG, "QService Constructor invoked");
+}
+
+QService::~QService()
+{
+ ALOGD_IF(QSERVICE_DEBUG,"QService Destructor invoked");
+}
+
+void QService::securing(uint32_t startEnd) {
+ mHwcContext->mSecuring = startEnd;
+ //We're done securing
+ if(startEnd == END)
+ mHwcContext->mSecureMode = true;
+ if(mHwcContext->proc)
+ mHwcContext->proc->invalidate(mHwcContext->proc);
+}
+
+void QService::unsecuring(uint32_t startEnd) {
+ mHwcContext->mSecuring = startEnd;
+ //We're done unsecuring
+ if(startEnd == END)
+ mHwcContext->mSecureMode = false;
+ if(mHwcContext->proc)
+ mHwcContext->proc->invalidate(mHwcContext->proc);
+}
+
+QService* QService::getInstance(hwc_context_t *ctx)
+{
+ if(!sQService) {
+ sQService = new QService(ctx);
+ sp<IServiceManager> sm = defaultServiceManager();
+ sm->addService(String16("display.qservice"), sQService);
+ if(sm->checkService(String16("display.qservice")) != NULL)
+ ALOGD_IF(QSERVICE_DEBUG, "adding display.qservice succeeded");
+ else
+ ALOGD_IF(QSERVICE_DEBUG, "adding display.qservice failed");
+ }
+ return sQService;
+}
+
+}
diff --git a/libqservice/QService.h b/libqservice/QService.h
new file mode 100644
index 0000000..a6b37f3
--- /dev/null
+++ b/libqservice/QService.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of Code Aurora Forum, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ANDROID_QSERVICE_H
+#define ANDROID_QSERVICE_H
+
+#include <utils/Errors.h>
+#include <sys/types.h>
+#include <cutils/log.h>
+#include <binder/IServiceManager.h>
+#include <IQService.h>
+
+struct hwc_context_t;
+
+namespace qService {
+// ----------------------------------------------------------------------------
+
+class QService : public BnQService {
+public:
+ virtual ~QService();
+ virtual void securing(uint32_t startEnd);
+ virtual void unsecuring(uint32_t startEnd);
+ static QService* getInstance(hwc_context_t *ctx);
+private:
+ QService(hwc_context_t *ctx);
+ static QService *sQService;
+ hwc_context_t *mHwcContext;
+};
+}; // namespace qService
+#endif // ANDROID_QSERVICE_H