Panagiotis Triantafyllou

crash fixes

...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2 2
3 ext { 3 ext {
4 PUBLISH_GROUP_ID = 'ly.warp' 4 PUBLISH_GROUP_ID = 'ly.warp'
5 - PUBLISH_VERSION = '4.5.4.6rc30' 5 + PUBLISH_VERSION = '4.5.4.6rc31'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
...@@ -32,6 +32,12 @@ android { ...@@ -32,6 +32,12 @@ android {
32 abortOnError false 32 abortOnError false
33 } 33 }
34 34
35 + sourceSets {
36 + main {
37 + jniLibs.srcDirs = ['src/main/jniLibs']
38 + }
39 + }
40 +
35 buildTypes { 41 buildTypes {
36 release { 42 release {
37 minifyEnabled false 43 minifyEnabled false
...@@ -85,8 +91,9 @@ dependencies { ...@@ -85,8 +91,9 @@ dependencies {
85 implementation 'com.huawei.hms:ads-identifier:3.4.56.300' 91 implementation 'com.huawei.hms:ads-identifier:3.4.56.300'
86 92
87 //------------------------------ SQLCipher -----------------------------// 93 //------------------------------ SQLCipher -----------------------------//
88 - api "net.zetetic:android-database-sqlcipher:4.5.0" 94 + api "net.zetetic:android-database-sqlcipher:4.5.2"
89 api "androidx.sqlite:sqlite:2.2.0" 95 api "androidx.sqlite:sqlite:2.2.0"
96 + api 'com.getkeepsafe.relinker:relinker:1.4.4'
90 97
91 //------------------------------ Calligraphy -----------------------------// 98 //------------------------------ Calligraphy -----------------------------//
92 api 'io.github.inflationx:calligraphy3:3.1.1' 99 api 'io.github.inflationx:calligraphy3:3.1.1'
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 android:name="android.permission.REQUEST_INSTALL_PACKAGES" 13 android:name="android.permission.REQUEST_INSTALL_PACKAGES"
14 tools:node="remove" /> 14 tools:node="remove" />
15 15
16 - <application> 16 + <application android:largeHeap="true">
17 <!-- <meta-data--> 17 <!-- <meta-data-->
18 <!-- android:name="com.google.android.geo.API_KEY"--> 18 <!-- android:name="com.google.android.geo.API_KEY"-->
19 <!-- android:value="@string/google_maps_key" />--> 19 <!-- android:value="@string/google_maps_key" />-->
...@@ -207,14 +207,14 @@ ...@@ -207,14 +207,14 @@
207 android:name="ly.warp.sdk.receivers.LocationChangedReceiver" 207 android:name="ly.warp.sdk.receivers.LocationChangedReceiver"
208 android:exported="false" /> 208 android:exported="false" />
209 209
210 - <receiver 210 +<!-- <receiver-->
211 - android:name="ly.warp.sdk.receivers.ConnectivityChangedReceiver" 211 +<!-- android:name="ly.warp.sdk.receivers.ConnectivityChangedReceiver"-->
212 - android:exported="false"> 212 +<!-- android:exported="false">-->
213 - <intent-filter> 213 +<!-- <intent-filter>-->
214 - <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> 214 +<!-- <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />-->
215 - <category android:name="${applicationId}" /> 215 +<!-- <category android:name="${applicationId}" />-->
216 - </intent-filter> 216 +<!-- </intent-filter>-->
217 - </receiver> 217 +<!-- </receiver>-->
218 218
219 <receiver 219 <receiver
220 android:name="ly.warp.sdk.receivers.BluetoothStateChangeReceiver" 220 android:name="ly.warp.sdk.receivers.BluetoothStateChangeReceiver"
......
...@@ -129,7 +129,9 @@ public enum Warply { ...@@ -129,7 +129,9 @@ public enum Warply {
129 129
130 @Override 130 @Override
131 public void onInit(Context context) { 131 public void onInit(Context context) {
132 - INSTANCE.mContext = new WeakReference<>(context.getApplicationContext()); 132 + if (context != null) {
133 + INSTANCE.mContext = new WeakReference<>(context.getApplicationContext());
134 + }
133 initInternal(context); 135 initInternal(context);
134 } 136 }
135 }); 137 });
...@@ -140,7 +142,8 @@ public enum Warply { ...@@ -140,7 +142,8 @@ public enum Warply {
140 INSTANCE.check(); 142 INSTANCE.check();
141 return; 143 return;
142 } 144 }
143 - INSTANCE.mRequestQueue = Volley.newRequestQueue(context); 145 + if (INSTANCE.mRequestQueue == null)
146 + INSTANCE.mRequestQueue = Volley.newRequestQueue(context);
144 INSTANCE.mContext = new WeakReference<>(context.getApplicationContext()); 147 INSTANCE.mContext = new WeakReference<>(context.getApplicationContext());
145 WarpConstants.DEBUG = WarplyProperty.isDebugMode(INSTANCE.mContext.get()); 148 WarpConstants.DEBUG = WarplyProperty.isDebugMode(INSTANCE.mContext.get());
146 INSTANCE.isInitializedOrThrow(); 149 INSTANCE.isInitializedOrThrow();
......
...@@ -11,6 +11,8 @@ import android.util.Log; ...@@ -11,6 +11,8 @@ import android.util.Log;
11 11
12 import androidx.annotation.Nullable; 12 import androidx.annotation.Nullable;
13 13
14 +import com.getkeepsafe.relinker.ReLinker;
15 +
14 import net.sqlcipher.DatabaseUtils; 16 import net.sqlcipher.DatabaseUtils;
15 import net.sqlcipher.database.SQLiteDatabase; 17 import net.sqlcipher.database.SQLiteDatabase;
16 import net.sqlcipher.database.SQLiteOpenHelper; 18 import net.sqlcipher.database.SQLiteOpenHelper;
...@@ -35,7 +37,7 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -35,7 +37,7 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
35 } 37 }
36 38
37 private static final String DB_NAME = "warply.db"; 39 private static final String DB_NAME = "warply.db";
38 - private static final int DB_VERSION = 7; 40 + private static final int DB_VERSION = 8;
39 private static final String KEY_CIPHER = "tn#mpOl3v3Dy1pr@W"; 41 private static final String KEY_CIPHER = "tn#mpOl3v3Dy1pr@W";
40 42
41 //------------------------------ Fields -----------------------------// 43 //------------------------------ Fields -----------------------------//
...@@ -110,7 +112,12 @@ public class WarplyDBHelper extends SQLiteOpenHelper { ...@@ -110,7 +112,12 @@ public class WarplyDBHelper extends SQLiteOpenHelper {
110 112
111 public static synchronized WarplyDBHelper getInstance(Context context) { 113 public static synchronized WarplyDBHelper getInstance(Context context) {
112 if (mDBHelperInstance == null) { 114 if (mDBHelperInstance == null) {
113 - SQLiteDatabase.loadLibs(context); 115 +// SQLiteDatabase.loadLibs(context); //old implementation
116 + SQLiteDatabase.loadLibs(context, libraries -> {
117 + for (String library : libraries) {
118 + ReLinker.loadLibrary(context, library);
119 + }
120 + });
114 mDBHelperInstance = new WarplyDBHelper(context); 121 mDBHelperInstance = new WarplyDBHelper(context);
115 } 122 }
116 return mDBHelperInstance; 123 return mDBHelperInstance;
......
...@@ -113,7 +113,7 @@ public class DiskBasedCache implements Cache { ...@@ -113,7 +113,7 @@ public class DiskBasedCache implements Cache {
113 try { 113 try {
114 cis = new CountingInputStream(new FileInputStream(file)); 114 cis = new CountingInputStream(new FileInputStream(file));
115 CacheHeader.readHeader(cis); // eat header 115 CacheHeader.readHeader(cis); // eat header
116 - byte[] data = streamToBytes(cis, (int) (file.length() - cis.bytesRead)); 116 + byte[] data = streamToBytes(cis, (int) Math.abs((int)(file.length() - cis.bytesRead)));
117 return entry.toCacheEntry(data); 117 return entry.toCacheEntry(data);
118 } catch (IOException e) { 118 } catch (IOException e) {
119 VolleyLog.d("%s: %s", file.getAbsolutePath(), e.toString()); 119 VolleyLog.d("%s: %s", file.getAbsolutePath(), e.toString());
......
...@@ -256,7 +256,7 @@ public class UpdateUserLocationService extends Worker { ...@@ -256,7 +256,7 @@ public class UpdateUserLocationService extends Worker {
256 && backgroundProvider == WarpConstants.LocationModes.OFF.ordinal()) { 256 && backgroundProvider == WarpConstants.LocationModes.OFF.ordinal()) {
257 257
258 WarplyLocationManager.stopReportingLocation(context); 258 WarplyLocationManager.stopReportingLocation(context);
259 - WarplyLocationManager.disableConnectivityChangedReceiver(context); 259 +// WarplyLocationManager.disableConnectivityChangedReceiver(context);
260 260
261 } else if (foregroundProvider == WarpConstants.LocationModes.OFF.ordinal()) { 261 } else if (foregroundProvider == WarpConstants.LocationModes.OFF.ordinal()) {
262 /* 262 /*
......
...@@ -172,6 +172,7 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ ...@@ -172,6 +172,7 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ
172 } 172 }
173 173
174 public synchronized void initWithPermissions(Activity activity) { 174 public synchronized void initWithPermissions(Activity activity) {
175 + mContext = activity;
175 // this.mPermissionsActivity = activity; 176 // this.mPermissionsActivity = activity;
176 // 177 //
177 // int result; 178 // int result;
......
...@@ -74,7 +74,7 @@ public class WarplySessionManager { ...@@ -74,7 +74,7 @@ public class WarplySessionManager {
74 */ 74 */
75 public static void onStartActivity(Activity activity) { 75 public static void onStartActivity(Activity activity) {
76 synchronized (_activities) { 76 synchronized (_activities) {
77 - Warply.getInitializer(activity).init(); 77 +// Warply.getInitializer(activity).init();
78 _activities.add(activity); 78 _activities.add(activity);
79 if (_activities.size() == 1) 79 if (_activities.size() == 1)
80 onApplicationEnterForeground(); 80 onApplicationEnterForeground();
......