Skip to content
Browse files

[droid] implement CAndroidPowerSyscall which uses CXBMCApp::GetBatter…

…yLevel() to poll the battery level
  • Loading branch information...
1 parent 7decc93 commit a8a9bdb2c81add47362f73137d057341ec2525cc @Montellese Montellese committed with Cory Fields Jun 24, 2012
View
6 Makefile.in
@@ -110,7 +110,13 @@ DIRECTORY_ARCHIVES += xbmc/windowing/osx/windowing_osx.a
else
DIRECTORY_ARCHIVES += xbmc/input/linux/input_linux.a
DIRECTORY_ARCHIVES += xbmc/network/linux/network_linux.a
+
+ifeq (@USE_ANDROID@,1)
+DIRECTORY_ARCHIVES += xbmc/powermanagement/android/powermanagement_android.a
+else
DIRECTORY_ARCHIVES += xbmc/powermanagement/linux/powermanagement_linux.a
+endif
+
DIRECTORY_ARCHIVES += xbmc/storage/linux/storage_linux.a
DIRECTORY_ARCHIVES += xbmc/windowing/X11/windowing_X11.a
endif
View
4 xbmc/powermanagement/PowerManager.cpp
@@ -39,6 +39,8 @@
#if defined(TARGET_DARWIN)
#include "osx/CocoaPowerSyscall.h"
+#elif defined(TARGET_ANDROID)
+#include "android/AndroidPowerSyscall.h"
#elif defined(_LINUX) && defined(HAS_DBUS)
#include "linux/ConsoleUPowerSyscall.h"
#include "linux/ConsoleDeviceKitPowerSyscall.h"
@@ -68,6 +70,8 @@ void CPowerManager::Initialize()
{
#if defined(TARGET_DARWIN)
m_instance = new CCocoaPowerSyscall();
+#elif defined(TARGET_ANDROID)
+ m_instance = new CAndroidPowerSyscall();
#elif defined(_LINUX) && defined(HAS_DBUS)
if (CConsoleUPowerSyscall::HasDeviceConsoleKit())
m_instance = new CConsoleUPowerSyscall();
View
42 xbmc/powermanagement/android/AndroidPowerSyscall.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#if defined (TARGET_ANDROID)
+
+#include "AndroidPowerSyscall.h"
+#include "android/activity/XBMCApp.h"
+
+CAndroidPowerSyscall::CAndroidPowerSyscall()
+{ }
+
+CAndroidPowerSyscall::~CAndroidPowerSyscall()
+{ }
+
+int CAndroidPowerSyscall::BatteryLevel(void)
+{
+ return CXBMCApp::GetBatteryLevel();
+}
+
+bool CAndroidPowerSyscall::PumpPowerEvents(IPowerEventsCallback *callback)
+{
+ return true;
+}
+
+#endif
View
44 xbmc/powermanagement/android/AndroidPowerSyscall.h
@@ -0,0 +1,44 @@
+#pragma once
+/*
+ * Copyright (C) 2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#if defined (TARGET_ANDROID)
+#include "powermanagement/IPowerSyscall.h"
+
+class CAndroidPowerSyscall : public CPowerSyscallWithoutEvents
+{
+public:
+ CAndroidPowerSyscall();
+ ~CAndroidPowerSyscall();
+
+ virtual bool Powerdown(void) { return false; }
+ virtual bool Suspend(void) { return false; }
+ virtual bool Hibernate(void) { return false; }
+ virtual bool Reboot(void) { return false; }
+
+ virtual bool CanPowerdown(void) { return false; }
+ virtual bool CanSuspend(void) { return false; }
+ virtual bool CanHibernate(void) { return false; }
+ virtual bool CanReboot(void) { return false; }
+ virtual int BatteryLevel(void);
+
+ virtual bool PumpPowerEvents(IPowerEventsCallback *callback);
+};
+#endif
View
6 xbmc/powermanagement/android/Makefile
@@ -0,0 +1,6 @@
+SRCS=AndroidPowerSyscall.cpp
+
+LIB=powermanagement_android.a
+
+include ../../../Makefile.include
+-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))

0 comments on commit a8a9bdb

Please sign in to comment.
Something went wrong with that request. Please try again.