3 * Copyright (C) 2012-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
27 #include <android/native_activity.h>
29 #include "IActivityHandler.h"
30 #include "IInputHandler.h"
33 #include "android/jni/Context.h"
34 #include "android/jni/BroadcastReceiver.h"
38 class CAESinkAUDIOTRACK;
39 typedef struct _JNIEnv JNIEnv;
50 std::string packageName;
51 std::string packageLabel;
55 class CXBMCApp : public IActivityHandler, public CJNIContext, public CJNIBroadcastReceiver
58 CXBMCApp(ANativeActivity *nativeActivity);
60 virtual void onReceive(CJNIIntent intent);
61 virtual void onNewIntent(CJNIIntent intent);
63 bool isValid() { return m_activity != NULL; }
71 void onSaveState(void **data, size_t *size);
72 void onConfigurationChanged();
75 void onCreateWindow(ANativeWindow* window);
76 void onResizeWindow();
77 void onDestroyWindow();
82 static ANativeWindow* GetNativeWindow() { return m_window; };
83 static int SetBuffersGeometry(int width, int height, int format);
84 static int android_printf(const char *format, ...);
86 static int GetBatteryLevel();
87 static bool StartActivity(const std::string &package, const std::string &intent = std::string(), const std::string &dataType = std::string(), const std::string &dataURI = std::string());
88 static bool ListApplications(std::vector <androidPackage> *applications);
89 static bool GetIconSize(const std::string &packageName, int *width, int *height);
90 static bool GetIcon(const std::string &packageName, void* buffer, unsigned int bufSize);
93 * \brief If external storage is available, it returns the path for the external storage (for the specified type)
94 * \param path will contain the path of the external storage (for the specified type)
95 * \param type optional type. Possible values are "", "files", "music", "videos", "pictures", "photos, "downloads"
96 * \return true if external storage is available and a valid path has been stored in the path parameter
98 static bool GetExternalStorage(std::string &path, const std::string &type = "");
99 static bool GetStorageUsage(const std::string &path, std::string &usage);
100 static int GetMaxSystemVolume();
104 // limit who can access Volume
105 friend class CAESinkAUDIOTRACK;
107 static int GetMaxSystemVolume(JNIEnv *env);
108 static void SetSystemVolume(JNIEnv *env, float percent);
111 static bool HasLaunchIntent(const std::string &package);
113 std::string GetFilenameFromIntent(const CJNIIntent &intent);
117 static ANativeActivity *m_activity;
118 CJNIWakeLock *m_wakeLock;
119 static int m_batteryLevel;
124 static ANativeWindow* m_window;
126 void XBMC_Pause(bool pause);
128 bool XBMC_DestroyDisplay();
129 bool XBMC_SetupDisplay();