Merge pull request #2948 from ace20022/blu_lang_fix
[vuplus_xbmc] / xbmc / android / jni / Context.h
1 #pragma once
2 /*
3  *      Copyright (C) 2013 Team XBMC
4  *      http://www.xbmc.org
5  *
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)
9  *  any later version.
10  *
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.
15  *
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/>.
19  *
20  */
21
22 #include "JNIBase.h"
23 #include "BroadcastReceiver.h"
24
25 struct ANativeActivity;
26 class CJNIIntent;
27 class CJNIPackageManager;
28 class CJNIBroadcastReceiver;
29 class CJNIIntentFilter;
30 class CJNIClassLoader;
31 class CJNIApplicationInfo;
32 class CJNIFile;
33 class CJNIContentResolver;
34
35 class CJNIContext
36 {
37 public:
38   static CJNIPackageManager GetPackageManager();
39   static void startActivity(const CJNIIntent &intent);
40   static jni::jhobject getSystemService(const std::string &service);
41   static int checkCallingOrSelfPermission(const std::string &permission);
42   static CJNIIntent registerReceiver(const CJNIBroadcastReceiver &receiver, const CJNIIntentFilter &filter);
43   static CJNIIntent registerReceiver(const CJNIIntentFilter &filter);
44   static void unregisterReceiver(const CJNIBroadcastReceiver &receiver);
45   static CJNIIntent sendBroadcast(const CJNIIntent &intent);
46   static CJNIIntent getIntent();
47   static CJNIClassLoader getClassLoader();
48   static CJNIApplicationInfo getApplicationInfo();
49   static std::string getPackageResourcePath();
50   static CJNIFile getCacheDir();
51   static CJNIFile getDir(const std::string &path, int mode);
52   static CJNIFile getExternalFilesDir(const std::string &path);
53   static CJNIContentResolver getContentResolver();
54   static CJNIContext* GetAppInstance() { return m_appInstance; };
55   static void _onNewIntent(JNIEnv *env, jobject context, jobject intent);
56
57 protected:
58   CJNIContext(const ANativeActivity *nativeActivity);
59   ~CJNIContext();
60
61   virtual void onNewIntent(CJNIIntent intent)=0;
62
63 private:
64   CJNIContext();
65
66   void PopulateStaticFields();
67   void operator=(CJNIContext const&){};
68   static jni::jhobject m_context;
69   static CJNIContext *m_appInstance;
70 };
71