summaryrefslogtreecommitdiffstats
path: root/src/doppelganger
diff options
context:
space:
mode:
Diffstat (limited to 'src/doppelganger')
-rw-r--r--src/doppelganger/doppelganger.pro8
-rw-r--r--src/doppelganger/main.cpp2
-rw-r--r--src/doppelganger/powermanager.cpp88
-rw-r--r--src/doppelganger/powermanager.h62
-rw-r--r--src/doppelganger/schedulingpolicyservice.cpp11
-rw-r--r--src/doppelganger/schedulingpolicyservice.h5
6 files changed, 172 insertions, 4 deletions
diff --git a/src/doppelganger/doppelganger.pro b/src/doppelganger/doppelganger.pro
index fc337df..40c7650 100644
--- a/src/doppelganger/doppelganger.pro
+++ b/src/doppelganger/doppelganger.pro
@@ -3,16 +3,18 @@ QT -= core gui
TARGET = doppelganger
LIBS += -lutils -lbinder -lcutils \
- -L$${ANDROID_PRODUCT_OUT}/obj/STATIC_LIBRARIES/libscheduling_policy_intermediates -lscheduling_policy
+ -L$${ANDROID_PRODUCT_OUT}/obj/STATIC_LIBRARIES/libscheduling_policy_intermediates -lscheduling_policy -lpowermanager
TEMPLATE = app
SOURCES += main.cpp \
permissioncontroller.cpp \
- schedulingpolicyservice.cpp
+ schedulingpolicyservice.cpp \
+ powermanager.cpp
HEADERS += \
permissioncontroller.h \
- schedulingpolicyservice.h
+ schedulingpolicyservice.h \
+ powermanager.h
load(qt_tool)
diff --git a/src/doppelganger/main.cpp b/src/doppelganger/main.cpp
index e4a06c8..6d81991 100644
--- a/src/doppelganger/main.cpp
+++ b/src/doppelganger/main.cpp
@@ -20,6 +20,7 @@
#include "permissioncontroller.h"
#include "schedulingpolicyservice.h"
+#include "powermanager.h"
using namespace android;
@@ -28,5 +29,6 @@ int main(int, char *[])
sp<ProcessState> proc(ProcessState::self());
SchedulingPolicyService::instantiate();
PermissionController::instantiate();
+ PowerManager::instantiate();
IPCThreadState::self()->joinThreadPool();
}
diff --git a/src/doppelganger/powermanager.cpp b/src/doppelganger/powermanager.cpp
new file mode 100644
index 0000000..47ab02f
--- /dev/null
+++ b/src/doppelganger/powermanager.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use the contact form at
+** http://qt.digia.com/
+**
+** This file is part of Qt Enterprise Embedded.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** the contact form at http://qt.digia.com/
+**
+****************************************************************************/
+
+#include "powermanager.h"
+
+#include <binder/IServiceManager.h>
+
+using namespace android;
+
+enum {
+ ACQUIRE_WAKE_LOCK = IBinder::FIRST_CALL_TRANSACTION,
+ ACQUIRE_WAKE_LOCK_UID = IBinder::FIRST_CALL_TRANSACTION + 1,
+ RELEASE_WAKE_LOCK = IBinder::FIRST_CALL_TRANSACTION + 2,
+ UPDATE_WAKE_LOCK_UIDS = IBinder::FIRST_CALL_TRANSACTION + 3,
+};
+
+void PowerManager::instantiate()
+{
+ defaultServiceManager()->addService(String16("power"), new PowerManager());
+}
+
+status_t PowerManager::onTransact(uint32_t code,
+ const Parcel &,
+ Parcel *,
+ uint32_t)
+{
+ switch (code) {
+ case ACQUIRE_WAKE_LOCK:
+ case ACQUIRE_WAKE_LOCK_UID:
+ case RELEASE_WAKE_LOCK:
+ case UPDATE_WAKE_LOCK_UIDS:
+ return NO_ERROR;
+ default:
+ break;
+ }
+}
+
+#if Q_ANDROID_VERSION_MAJOR > 4 || (Q_ANDROID_VERSION_MAJOR == 4 && Q_ANDROID_VERSION_MINOR >= 4)
+status_t PowerManager::acquireWakeLock(int,
+ const sp<IBinder> &,
+ const String16 &,
+ const String16 &)
+{
+ return OK;
+}
+
+status_t PowerManager::acquireWakeLockWithUid(int,
+ const sp<IBinder> &,
+ const String16 &,
+ const String16 &,
+ int)
+{
+ return OK;
+}
+
+status_t PowerManager::updateWakeLockUids(const sp<IBinder> &,
+ int,
+ const int *)
+{
+ return OK;
+}
+#else // < 4.4
+status_t PowerManager::acquireWakeLock(int, const sp<android::IBinder> &, const String16 &)
+{
+ return OK;
+}
+#endif
+
+status_t PowerManager::releaseWakeLock(const sp<IBinder> &, int)
+{
+ return OK;
+}
diff --git a/src/doppelganger/powermanager.h b/src/doppelganger/powermanager.h
new file mode 100644
index 0000000..f934b31
--- /dev/null
+++ b/src/doppelganger/powermanager.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use the contact form at
+** http://qt.digia.com/
+**
+** This file is part of Qt Enterprise Embedded.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** the contact form at http://qt.digia.com/
+**
+****************************************************************************/
+
+#ifndef POWERMANAGER_H
+#define POWERMANAGER_H
+
+#include <powermanager/IPowerManager.h>
+
+namespace android {
+
+typedef BnInterface<IPowerManager> BnPowerManagerService;
+
+} // namespace android
+
+class PowerManager : public android::BnPowerManagerService
+{
+public:
+ static void instantiate();
+ android::status_t onTransact(uint32_t code,
+ const android::Parcel &data,
+ android::Parcel *reply,
+ uint32_t flags);
+
+#if Q_ANDROID_VERSION_MAJOR > 4 || (Q_ANDROID_VERSION_MAJOR == 4 && Q_ANDROID_VERSION_MINOR >= 4)
+ virtual android::status_t acquireWakeLock(int flags,
+ const android::sp<android::IBinder>& lock,
+ const android::String16& tag,
+ const android::String16& packageName);
+ virtual android::status_t acquireWakeLockWithUid(int flags,
+ const android::sp<android::IBinder>& lock,
+ const android::String16& tag,
+ const android::String16& packageName,
+ int uid);
+ virtual android::status_t updateWakeLockUids(const android::sp<android::IBinder>& lock,
+ int len,
+ const int *uids);
+#else // < 4.4
+ virtual android::status_t acquireWakeLock(int flags,
+ const android::sp<android::IBinder>& lock,
+ const android::String16& tag);
+#endif
+
+ virtual android::status_t releaseWakeLock(const android::sp<android::IBinder>& lock, int flags);
+};
+
+#endif // POWERMANAGER_H
diff --git a/src/doppelganger/schedulingpolicyservice.cpp b/src/doppelganger/schedulingpolicyservice.cpp
index a7a3f17..365e97a 100644
--- a/src/doppelganger/schedulingpolicyservice.cpp
+++ b/src/doppelganger/schedulingpolicyservice.cpp
@@ -49,7 +49,7 @@ status_t SchedulingPolicyService::onTransact(uint32_t code, const Parcel &data,
int32_t pid = data.readInt32();
int32_t tid = data.readInt32();
int32_t prio = data.readInt32();
- int res = requestPriority(pid, tid, prio);
+ int res = requestPriority_helper(pid, tid, prio);
reply->writeNoException();
reply->writeInt32(res);
return NO_ERROR;
@@ -59,7 +59,16 @@ status_t SchedulingPolicyService::onTransact(uint32_t code, const Parcel &data,
}
}
+#if Q_ANDROID_VERSION_MAJOR == 4 && Q_ANDROID_VERSION_MINOR < 3
int SchedulingPolicyService::requestPriority(int32_t pid, int32_t tid, int32_t prio)
+#else
+int SchedulingPolicyService::requestPriority(int32_t pid, int32_t tid, int32_t prio, bool)
+#endif
+{
+ return requestPriority_helper(pid, tid, prio);
+}
+
+int SchedulingPolicyService::requestPriority_helper(int32_t pid, int32_t tid, int32_t prio)
{
if (prio < PRIORITY_MIN || prio > PRIORITY_MAX)
return PERMISSION_DENIED;
diff --git a/src/doppelganger/schedulingpolicyservice.h b/src/doppelganger/schedulingpolicyservice.h
index ef56dcd..f544561 100644
--- a/src/doppelganger/schedulingpolicyservice.h
+++ b/src/doppelganger/schedulingpolicyservice.h
@@ -30,10 +30,15 @@ public:
android::status_t onTransact(uint32_t code, const android::Parcel &data,
android::Parcel *reply, uint32_t flags);
+#if Q_ANDROID_VERSION_MAJOR == 4 && Q_ANDROID_VERSION_MINOR < 3
int requestPriority(int32_t pid, int32_t tid, int32_t prio);
+#else
+ int requestPriority(int32_t pid, int32_t tid, int32_t prio, bool);
+#endif
private:
SchedulingPolicyService();
+ int requestPriority_helper(int32_t pid, int32_t tid, int32_t prio);
};
#endif // SCHEDULINGPOLICYSERVICE_H