Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_android_sdk_maven_plugin
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Panagiotis Triantafyllou
2022-03-17 11:49:37 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8d3fd0f46f667fda30eeda246acc0624171e0820
8d3fd0f4
1 parent
9e9f614a
version 4.5.4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
164 additions
and
10 deletions
warply_android_sdk/build.gradle
warply_android_sdk/src/main/java/ly/warp/sdk/utils/PrefsUtils.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarpUtils.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyPreferences.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/constants/WarpConstants.java
warply_android_sdk/build.gradle
View file @
8d3fd0f
...
...
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext
{
PUBLISH_GROUP_ID
=
'ly.warp'
PUBLISH_VERSION
=
'4.5.
3.1
'
PUBLISH_VERSION
=
'4.5.
4
'
PUBLISH_ARTIFACT_ID
=
'warply-android-sdk'
}
...
...
@@ -37,7 +37,7 @@ dependencies {
api
'androidx.appcompat:appcompat:1.4.1'
api
'androidx.recyclerview:recyclerview:1.2.1'
api
'androidx.cardview:cardview:1.0.0'
api
"androidx.security:security-crypto:1.1.0-alpha03"
// For minSDK 23 use 1.0.0, for minSDK 21 use 1.1.0 that is currently in alpha
api
'org.altbeacon:android-beacon-library:2.19.3'
api
'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
api
"commons-logging:commons-logging:1.2"
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/PrefsUtils.java
0 → 100644
View file @
8d3fd0f
package
ly
.
warp
.
sdk
.
utils
;
import
android.app.Application
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.preference.PreferenceManager
;
import
androidx.security.crypto.EncryptedSharedPreferences
;
import
androidx.security.crypto.MasterKey
;
import
java.io.IOException
;
import
java.lang.ref.WeakReference
;
import
java.security.GeneralSecurityException
;
/**
* Created by Panagiotis Triantafyllou on 21-Nov-18.
*/
public
class
PrefsUtils
{
// ===========================================================
// Constants
// ===========================================================
private
static
final
String
FILE_SECURE_SHARED_PREFS
=
"com.gr.gapp.obfuscatepreferences"
;
private
static
final
String
KEY_ACC_TOKEN
=
"key_acc_token"
;
private
static
final
String
KEY_REF_TOKEN
=
"key_ref_token"
;
private
static
final
String
KEY_CL_SECRET
=
"key_cl_secret"
;
private
static
final
String
KEY_CID
=
"key_cid"
;
// ===========================================================
// Fields
// ===========================================================
private
static
WeakReference
<
Application
>
sContext
;
private
static
SharedPreferences
mSecurePref
;
// ===========================================================
// Methods
// ===========================================================
public
static
void
initialize
(
Application
application
)
{
sContext
=
new
WeakReference
<>(
application
);
}
private
static
SharedPreferences
getPrefs
()
{
return
PreferenceManager
.
getDefaultSharedPreferences
(
sContext
.
get
());
}
private
static
SharedPreferences
getPrefs
(
Context
context
)
{
try
{
MasterKey
masterKey
=
new
MasterKey
.
Builder
(
context
,
MasterKey
.
DEFAULT_MASTER_KEY_ALIAS
).
setKeyScheme
(
MasterKey
.
KeyScheme
.
AES256_GCM
).
build
();
SharedPreferences
encryptedSharedPreferences
=
EncryptedSharedPreferences
.
create
(
context
,
context
.
getPackageName
()
+
"_preferences"
,
masterKey
,
EncryptedSharedPreferences
.
PrefKeyEncryptionScheme
.
AES256_SIV
,
EncryptedSharedPreferences
.
PrefValueEncryptionScheme
.
AES256_GCM
);
return
encryptedSharedPreferences
;
}
catch
(
GeneralSecurityException
|
IOException
e
)
{
WarpUtils
.
log
(
"PrefUtils Get Encrypted Shared Preferences Error"
,
e
);
return
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
}
}
// ===========================================================
// Getter & Setter
// ===========================================================
/**
* Removes all user preferences.
*/
public
static
void
clearPrefs
()
{
getPrefs
().
edit
().
clear
().
apply
();
}
public
static
String
getAccToken
(
Context
context
)
{
return
getPrefs
(
context
).
getString
(
KEY_ACC_TOKEN
,
""
);
}
public
static
void
setAccToken
(
Context
context
,
String
at
)
{
getPrefs
(
context
).
edit
().
putString
(
KEY_ACC_TOKEN
,
at
).
apply
();
}
public
static
String
getRefToken
(
Context
context
)
{
return
getPrefs
(
context
).
getString
(
KEY_REF_TOKEN
,
""
);
}
public
static
void
setRefToken
(
Context
context
,
String
rt
)
{
getPrefs
(
context
).
edit
().
putString
(
KEY_REF_TOKEN
,
rt
).
apply
();
}
public
static
String
getClSecret
(
Context
context
)
{
return
getPrefs
(
context
).
getString
(
KEY_CL_SECRET
,
""
);
}
public
static
void
setClSecret
(
Context
context
,
String
cs
)
{
getPrefs
(
context
).
edit
().
putString
(
KEY_CL_SECRET
,
cs
).
apply
();
}
public
static
String
getCid
(
Context
context
)
{
return
getPrefs
(
context
).
getString
(
KEY_CID
,
""
);
}
public
static
void
setCid
(
Context
context
,
String
cid
)
{
getPrefs
(
context
).
edit
().
putString
(
KEY_CID
,
cid
).
apply
();
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarpUtils.java
View file @
8d3fd0f
...
...
@@ -49,6 +49,9 @@ import android.view.View;
import
android.view.animation.Animation
;
import
android.view.animation.ScaleAnimation
;
import
androidx.security.crypto.EncryptedSharedPreferences
;
import
androidx.security.crypto.MasterKey
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.methods.HttpRequestBase
;
import
org.apache.http.params.HttpProtocolParams
;
...
...
@@ -59,6 +62,7 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.nio.charset.Charset
;
import
java.security.GeneralSecurityException
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.zip.GZIPInputStream
;
...
...
@@ -190,11 +194,26 @@ public class WarpUtils {
}
private
static
SharedPreferences
getPreferences
(
Context
context
)
{
if
(
_prefs
==
null
)
{
_prefs
=
context
.
getSharedPreferences
(
PREFERENCES_NAME
,
Context
.
MODE_PRIVATE
);
try
{
MasterKey
masterKey
=
new
MasterKey
.
Builder
(
context
,
MasterKey
.
DEFAULT_MASTER_KEY_ALIAS
).
setKeyScheme
(
MasterKey
.
KeyScheme
.
AES256_GCM
).
build
();
SharedPreferences
encryptedSharedPreferences
=
EncryptedSharedPreferences
.
create
(
context
,
PREFERENCES_NAME
,
masterKey
,
EncryptedSharedPreferences
.
PrefKeyEncryptionScheme
.
AES256_SIV
,
EncryptedSharedPreferences
.
PrefValueEncryptionScheme
.
AES256_GCM
);
_prefs
=
encryptedSharedPreferences
;
}
catch
(
GeneralSecurityException
|
IOException
e
)
{
WarpUtils
.
log
(
"WarpUtils Get Encrypted Shared Preferences Error"
,
e
);
_prefs
=
context
.
getSharedPreferences
(
PREFERENCES_NAME
,
Context
.
MODE_PRIVATE
);
}
}
return
_prefs
;
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyPreferences.java
View file @
8d3fd0f
...
...
@@ -5,10 +5,15 @@ import android.content.Context;
import
android.content.SharedPreferences
;
import
android.text.TextUtils
;
import
androidx.security.crypto.EncryptedSharedPreferences
;
import
androidx.security.crypto.MasterKey
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.IOException
;
import
java.security.GeneralSecurityException
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -20,8 +25,25 @@ public class WarplyPreferences {
private
SharedPreferences
warplySharedPrefs
;
public
WarplyPreferences
(
Context
context
)
{
this
.
warplySharedPrefs
=
context
.
getSharedPreferences
(
WARPLY_SHARED_PREFS
,
Activity
.
MODE_PRIVATE
);
try
{
MasterKey
masterKey
=
new
MasterKey
.
Builder
(
context
,
MasterKey
.
DEFAULT_MASTER_KEY_ALIAS
).
setKeyScheme
(
MasterKey
.
KeyScheme
.
AES256_GCM
).
build
();
SharedPreferences
encryptedSharedPreferences
=
EncryptedSharedPreferences
.
create
(
context
,
WARPLY_SHARED_PREFS
,
masterKey
,
EncryptedSharedPreferences
.
PrefKeyEncryptionScheme
.
AES256_SIV
,
EncryptedSharedPreferences
.
PrefValueEncryptionScheme
.
AES256_GCM
);
this
.
warplySharedPrefs
=
encryptedSharedPreferences
;
}
catch
(
GeneralSecurityException
|
IOException
e
)
{
WarpUtils
.
log
(
"WarplyPreferences Encrypted Shared Preferences Error"
,
e
);
this
.
warplySharedPrefs
=
context
.
getSharedPreferences
(
WARPLY_SHARED_PREFS
,
Activity
.
MODE_PRIVATE
);
}
}
public
void
saveLocationChangedReceiverStatus
(
String
status
)
{
...
...
@@ -48,7 +70,8 @@ public class WarplyPreferences {
public
String
getAppStatus
()
{
return
warplySharedPrefs
.
getString
(
"appStatus"
,
"background"
);
}
public
boolean
isForeground
(){
public
boolean
isForeground
()
{
return
!
getAppStatus
().
equals
(
"background"
);
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/constants/WarpConstants.java
View file @
8d3fd0f
...
...
@@ -30,7 +30,7 @@ public class WarpConstants {
/**
* The version of the SDK installed in the device
*/
public
static
final
String
SDK_VERSION
=
"4.5.
3
"
;
public
static
final
String
SDK_VERSION
=
"4.5.
4
"
;
/**
* The URL of the server where it should ping
...
...
Please
register
or
login
to post a comment