1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/*
* MWMService.cpp
*
* Created on: May 11, 2012
* Author: siarheirachytski
*/
#include "Framework.hpp"
#include "../core/jni_helper.hpp"
#include "../platform/Platform.hpp"
#include "map/information_display.hpp"
#include "map/location_state.hpp"
#include "platform/settings.hpp"
extern "C"
{
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_MwmApplication_nativeInit(
JNIEnv * env, jobject thiz,
jstring apkPath, jstring storagePath, jstring tmpPath, jstring obbGooglePath,
jstring flavorName, jstring buildType, jboolean isYota, jboolean isTablet)
{
android::Platform::Instance().Initialize(
env, apkPath, storagePath, tmpPath, obbGooglePath, flavorName, buildType, isYota, isTablet);
LOG(LDEBUG, ("Creating android::Framework instance ..."));
if (!g_framework)
g_framework = new android::Framework();
LOG(LDEBUG, ("android::Framework created"));
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_MwmApplication_nativeIsBenchmarking(JNIEnv * env, jobject thiz)
{
return static_cast<jboolean>(g_framework->NativeFramework()->IsBenchmarking());
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_MwmApplication_nativeGetBoolean(JNIEnv * env,
jobject thiz,
jstring name,
jboolean defaultVal)
{
bool val = defaultVal;
Settings::Get(jni::ToNativeString(env, name), val);
return val;
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_MwmApplication_nativeSetBoolean(JNIEnv * env,
jobject thiz,
jstring name,
jboolean val)
{
bool flag = val;
(void)Settings::Set(jni::ToNativeString(env, name), flag);
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_MwmApplication_hasFreeSpace(JNIEnv * env, jobject thiz, jlong size)
{
return android::Platform::Instance().HasAvailableSpaceForWriting(size);
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_MwmApplication_nativeAddLocalization(JNIEnv * env, jobject thiz, jstring name, jstring value)
{
g_framework->AddString(jni::ToNativeString(env, name),
jni::ToNativeString(env, value));
}
JNIEXPORT jint JNICALL
Java_com_mapswithme_maps_MwmApplication_nativeGetInt(JNIEnv * env, jobject thiz, jstring name, jint defaultValue)
{
jint value;
if (Settings::Get(jni::ToNativeString(env, name), value))
return value;
return defaultValue;
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_MwmApplication_nativeSetInt(JNIEnv * env, jobject thiz, jstring name, jint value)
{
(void)Settings::Set(jni::ToNativeString(env, name), value);
}
JNIEXPORT jlong JNICALL
Java_com_mapswithme_maps_MwmApplication_nativeGetLong(JNIEnv * env, jobject thiz, jstring name, jlong defaultValue)
{
jlong value;
if (Settings::Get(jni::ToNativeString(env, name), value))
return value;
return defaultValue;
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_MwmApplication_nativeSetLong(JNIEnv * env, jobject thiz, jstring name, jlong value)
{
(void)Settings::Set(jni::ToNativeString(env, name), value);
}
JNIEXPORT jdouble JNICALL
Java_com_mapswithme_maps_MwmApplication_nativeGetDouble(JNIEnv * env, jobject thiz, jstring name, jdouble defaultValue)
{
jdouble value;
if (Settings::Get(jni::ToNativeString(env, name), value))
return value;
return defaultValue;
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_MwmApplication_nativeSetDouble(JNIEnv * env, jobject thiz, jstring name, jdouble value)
{
(void)Settings::Set(jni::ToNativeString(env, name), value);
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_MwmApplication_nativeSetString(JNIEnv * env, jobject thiz, jstring name, jstring value)
{
(void)Settings::Set(jni::ToNativeString(env, name), jni::ToNativeString(env, value));
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_MwmApplication_nativeGetString(JNIEnv * env, jobject thiz, jstring name, jstring defaultValue)
{
string value;
if (Settings::Get(jni::ToNativeString(env, name), value))
return jni::ToJavaString(env, value);
return defaultValue;
}
}
|