Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
df7f5059
Commit
df7f5059
authored
Oct 19, 2017
by
Benjamin REIS
Browse files
add getPaths method to platform helpers
parent
079cfcfb
Changes
5
Hide whitespace changes
Inline
Side-by-side
coreapi/android-helpers.cpp
View file @
df7f5059
...
...
@@ -17,6 +17,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "linphone/utils/utils.h"
#include "private.h"
#include "platform-helpers.h"
...
...
@@ -24,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <jni.h>
namespace
LinphonePrivate
{
LINPHONE_BEGIN_NAMESPACE
class
AndroidPlatformHelpers
:
public
PlatformHelpers
{
public:
...
...
@@ -36,6 +38,8 @@ public:
virtual
void
releaseMcastLock
();
virtual
void
acquireCpuLock
();
virtual
void
releaseCpuLock
();
virtual
std
::
string
getDataPath
();
virtual
std
::
string
getConfigPath
();
~
AndroidPlatformHelpers
();
private:
int
callVoidMethod
(
jmethodID
id
);
...
...
@@ -49,9 +53,20 @@ private:
jmethodID
mCpuLockReleaseId
;
jmethodID
mGetDnsServersId
;
jmethodID
mGetPowerManagerId
;
jmethodID
mGetDataPathId
;
jmethodID
mGetConfigPathId
;
};
static
const
char
*
GetStringUTFChars
(
JNIEnv
*
env
,
jstring
string
)
{
const
char
*
cstring
=
string
?
env
->
GetStringUTFChars
(
string
,
NULL
)
:
NULL
;
return
cstring
;
}
static
void
ReleaseStringUTFChars
(
JNIEnv
*
env
,
jstring
string
,
const
char
*
cstring
)
{
if
(
string
)
env
->
ReleaseStringUTFChars
(
string
,
cstring
);
}
jmethodID
AndroidPlatformHelpers
::
getMethodId
(
JNIEnv
*
env
,
jclass
klass
,
const
char
*
method
,
const
char
*
signature
){
jmethodID
id
=
env
->
GetMethodID
(
klass
,
method
,
signature
);
if
(
id
==
0
){
...
...
@@ -83,6 +98,8 @@ AndroidPlatformHelpers::AndroidPlatformHelpers(LinphoneCore *lc, void *system_co
mCpuLockReleaseId
=
getMethodId
(
env
,
klass
,
"releaseCpuLock"
,
"()V"
);
mGetDnsServersId
=
getMethodId
(
env
,
klass
,
"getDnsServers"
,
"()[Ljava/lang/String;"
);
mGetPowerManagerId
=
getMethodId
(
env
,
klass
,
"getPowerManager"
,
"()Ljava/lang/Object;"
);
mGetDataPathId
=
getMethodId
(
env
,
klass
,
"getDataPath"
,
"()Ljava/lang/String;"
);
mGetConfigPathId
=
getMethodId
(
env
,
klass
,
"getConfigPath"
,
"()Ljava/lang/String;"
);
jobject
pm
=
env
->
CallObjectMethod
(
mJavaHelper
,
mGetPowerManagerId
);
belle_sip_wake_lock_init
(
env
,
pm
);
...
...
@@ -152,6 +169,21 @@ void AndroidPlatformHelpers::releaseCpuLock(){
callVoidMethod
(
mCpuLockReleaseId
);
}
std
::
string
AndroidPlatformHelpers
::
getDataPath
(){
jstring
jdata_path
=
(
jstring
)
env
->
CallObjectMethod
(
mJavaHelper
,
mGetDataPathId
);
const
char
*
data_path
=
GetStringUTFChars
(
env
,
jdata_path
);
string
dataPath
=
data_path
;
ReleaseStringUTFChars
(
env
,
jdata_path
,
data_path
);
return
dataPath
;
}
std
::
string
AndroidPlatformHelpers
::
getConfigPath
(){
jstring
jconfig_path
=
(
jstring
)
env
->
CallObjectMethod
(
mJavaHelper
,
mGetConfigPathId
);
const
char
*
config_path
=
GetStringUTFChars
(
env
,
jconfig_path
);
string
configPath
=
config_path
;
ReleaseStringUTFChars
(
env
,
jconfig_path
,
config_path
);
return
configPath
;
}
int
AndroidPlatformHelpers
::
callVoidMethod
(
jmethodID
id
)
{
JNIEnv
*
env
=
ms_get_jni_env
();
...
...
@@ -170,10 +202,6 @@ PlatformHelpers *createAndroidPlatformHelpers(LinphoneCore *lc, void *system_con
return
new
AndroidPlatformHelpers
(
lc
,
system_context
);
}
}
//end of namespace
LINPHONE_END_NAMESPACE
#endif
coreapi/platform-helpers.cpp
View file @
df7f5059
...
...
@@ -17,11 +17,12 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "linphone/utils/utils.h"
#include "private.h"
LINPHONE_BEGIN_NAMESPACE
namespace
LinphonePrivate
{
PlatformHelpers
::~
PlatformHelpers
(){
}
...
...
@@ -42,8 +43,13 @@ void StubbedPlatformHelpers::acquireCpuLock(){
}
void
StubbedPlatformHelpers
::
releaseCpuLock
(){
}
std
::
string
StubbedPlatformHelpers
::
getDataPath
(){
return
Utils
::
getEmptyConstRefObject
<
std
::
string
>
();
}
std
::
string
StubbedPlatformHelpers
::
getConfigPath
(){
return
Utils
::
getEmptyConstRefObject
<
std
::
string
>
();
}
StubbedPlatformHelpers
::~
StubbedPlatformHelpers
(){
}
}
\ No newline at end of file
LINPHONE_END_NAMESPACE
coreapi/platform-helpers.h
View file @
df7f5059
...
...
@@ -37,6 +37,8 @@ class PlatformHelpers{
virtual
void
releaseMcastLock
()
=
0
;
virtual
void
acquireCpuLock
()
=
0
;
virtual
void
releaseCpuLock
()
=
0
;
virtual
std
::
string
getDataPath
()
=
0
;
virtual
std
::
string
getConfigPath
()
=
0
;
virtual
~
PlatformHelpers
();
protected:
PlatformHelpers
(
LinphoneCore
*
lc
)
:
mCore
(
lc
){
...
...
@@ -54,6 +56,8 @@ public:
void
releaseMcastLock
()
override
;
void
acquireCpuLock
()
override
;
void
releaseCpuLock
()
override
;
std
::
string
getDataPath
()
override
;
std
::
string
getConfigPath
()
override
;
virtual
~
StubbedPlatformHelpers
();
};
...
...
java/impl/org/linphone/core/util/AndroidPlatformHelper.java
View file @
df7f5059
...
...
@@ -52,7 +52,7 @@ public class AndroidPlatformHelper{
WifiManager
wifiMgr
=
ctx
.
getSystemService
(
WifiManager
.
class
);
mPowerManager
=
(
PowerManager
)
ctx
.
getSystemService
(
Context
.
POWER_SERVICE
);
mConnectivityManager
=
(
ConnectivityManager
)
ctx
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
mWakeLock
=
mPowerManager
.
newWakeLock
(
PowerManager
.
PARTIAL_WAKE_LOCK
,
"AndroidPlatformHelper"
);
mWakeLock
.
setReferenceCounted
(
true
);
mMcastLock
=
wifiMgr
.
createMulticastLock
(
"AndroidPlatformHelper"
);
...
...
@@ -60,11 +60,11 @@ public class AndroidPlatformHelper{
mWifiLock
=
wifiMgr
.
createWifiLock
(
WifiManager
.
WIFI_MODE_FULL_HIGH_PERF
,
"AndroidPlatformHelper"
);
mWifiLock
.
setReferenceCounted
(
true
);
}
public
Object
getPowerManager
(){
return
mPowerManager
;
}
public
String
[]
getDnsServers
()
{
if
(
mConnectivityManager
==
null
||
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
M
)
return
null
;
...
...
src/utils/paths/paths-android.cpp
View file @
df7f5059
...
...
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <jni.h>
#include "linphone/utils/utils.h"
#include "paths-android.h"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment