Skip to content

Commit d53e8a9

Browse files
Merged in uat (pull request #227)
Stroy - MRN-907 and bug-fixes, task - MRN-945 Approved-by: vanitha.g
2 parents 9d66be5 + fb76255 commit d53e8a9

File tree

2,361 files changed

+1061394
-1052
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,361 files changed

+1061394
-1052
lines changed

android/app/build.gradle

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ apply plugin: "com.facebook.react"
44

55
/** Add this Firebase intialize */
66
apply plugin: 'com.google.gms.google-services'
7+
/** Add this for Firebase crashlytics */
8+
apply plugin: 'com.google.firebase.crashlytics'
79

810
apply plugin: "kotlin-android"
911

@@ -78,7 +80,15 @@ def enableProguardInReleaseBuilds = false
7880
def jscFlavor = 'org.webkit:android-jsc:+'
7981

8082
android {
81-
ndkVersion rootProject.ext.ndkVersion
83+
84+
ndkVersion "21.4.7075529"
85+
// ndkVersion rootProject.ext.ndkVersion
86+
87+
externalNativeBuild {
88+
cmake {
89+
path 'jni/CMakeLists.txt'
90+
}
91+
}
8292
buildToolsVersion rootProject.ext.buildToolsVersion
8393
compileSdk rootProject.ext.compileSdkVersion
8494

@@ -88,7 +98,7 @@ android {
8898
minSdkVersion rootProject.ext.minSdkVersion
8999
targetSdkVersion rootProject.ext.targetSdkVersion
90100
versionCode 1
91-
versionName "3.0.16"
101+
versionName "3.2.7"
92102
/** Add this for react-native-camera */
93103
missingDimensionStrategy 'react-native-camera', 'general'
94104
multiDexEnabled true
@@ -118,10 +128,26 @@ android {
118128
signingConfig signingConfigs.release
119129
minifyEnabled enableProguardInReleaseBuilds
120130
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
131+
132+
/* Add the firebaseCrashlytics extension (by default,
133+
* it's disabled to improve build speeds) and set
134+
* nativeSymbolUploadEnabled to true along with a pointer to native libs. */
135+
firebaseCrashlytics {
136+
nativeSymbolUploadEnabled true
137+
unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
138+
}
121139
}
122140
}
123141
}
124142

143+
allprojects {
144+
repositories {
145+
google()
146+
mavenCentral()
147+
maven { url "https://repo.mirrorfly.com/snapshot" }
148+
}
149+
}
150+
125151
dependencies {
126152
// The version of react-native is set by the React Native Gradle Plugin
127153
implementation("com.facebook.react:react-android")
@@ -131,6 +157,16 @@ dependencies {
131157
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
132158
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
133159

160+
configurations {
161+
all {
162+
exclude group: 'org.json', module: 'json'
163+
exclude group: 'xpp3', module: 'xpp3'
164+
}
165+
}
166+
implementation fileTree(include: ['*.jar'], dir: 'libs')
167+
168+
api 'com.mirrorfly.sdk:mirrorfly-utilities:0.0.1'
169+
134170
// exclude group:'com.squareup.okhttp3', module:'okhttp'
135171

136172
if (hermesEnabled.toBoolean()) {

android/app/jni/BuffersStorage.cpp

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
2+
#include "BuffersStorage.h"
3+
#include "FileLog.h"
4+
#include "NativeByteBuffer.h"
5+
6+
BuffersStorage &BuffersStorage::getInstance() {
7+
static BuffersStorage instance(true);
8+
return instance;
9+
}
10+
11+
BuffersStorage::BuffersStorage(bool threadSafe) {
12+
isThreadSafe = threadSafe;
13+
if (isThreadSafe) {
14+
pthread_mutex_init(&mutex, NULL);
15+
}
16+
for (uint32_t a = 0; a < 4; a++) {
17+
freeBuffers8.push_back(new NativeByteBuffer((uint32_t) 8));
18+
}
19+
for (uint32_t a = 0; a < 5; a++) {
20+
freeBuffers128.push_back(new NativeByteBuffer((uint32_t) 128));
21+
}
22+
}
23+
24+
NativeByteBuffer *BuffersStorage::getFreeBuffer(uint32_t size) {
25+
uint32_t byteCount = 0;
26+
std::vector<NativeByteBuffer *> *arrayToGetFrom = nullptr;
27+
NativeByteBuffer *buffer = nullptr;
28+
if (size <= 8) {
29+
arrayToGetFrom = &freeBuffers8;
30+
byteCount = 8;
31+
} else if (size <= 128) {
32+
arrayToGetFrom = &freeBuffers128;
33+
byteCount = 128;
34+
} else if (size <= 1024 + 200) {
35+
arrayToGetFrom = &freeBuffers1024;
36+
byteCount = 1024 + 200;
37+
} else if (size <= 4096 + 200) {
38+
arrayToGetFrom = &freeBuffers4096;
39+
byteCount = 4096 + 200;
40+
} else if (size <= 16384 + 200) {
41+
arrayToGetFrom = &freeBuffers16384;
42+
byteCount = 16384 + 200;
43+
} else if (size <= 40000) {
44+
arrayToGetFrom = &freeBuffers32768;
45+
byteCount = 40000;
46+
} else if (size <= 160000) {
47+
arrayToGetFrom = &freeBuffersBig;
48+
byteCount = 160000;
49+
} else {
50+
buffer = new NativeByteBuffer(size);
51+
}
52+
53+
if (arrayToGetFrom != nullptr) {
54+
if (isThreadSafe) {
55+
pthread_mutex_lock(&mutex);
56+
}
57+
if (arrayToGetFrom->size() > 0) {
58+
buffer = (*arrayToGetFrom)[0];
59+
arrayToGetFrom->erase(arrayToGetFrom->begin());
60+
}
61+
if (isThreadSafe) {
62+
pthread_mutex_unlock(&mutex);
63+
}
64+
if (buffer == nullptr) {
65+
buffer = new NativeByteBuffer(byteCount);
66+
if (LOGS_ENABLED) DEBUG_D("create new %u buffer", byteCount);
67+
}
68+
}
69+
if (buffer != nullptr) {
70+
buffer->limit(size);
71+
buffer->rewind();
72+
}
73+
return buffer;
74+
}
75+
76+
void BuffersStorage::reuseFreeBuffer(NativeByteBuffer *buffer) {
77+
if (buffer == nullptr) {
78+
return;
79+
}
80+
std::vector<NativeByteBuffer *> *arrayToReuse = nullptr;
81+
uint32_t capacity = buffer->capacity();
82+
uint32_t maxCount = 10;
83+
if (capacity == 8) {
84+
arrayToReuse = &freeBuffers8;
85+
maxCount = 80;
86+
} else if (capacity == 128) {
87+
arrayToReuse = &freeBuffers128;
88+
maxCount = 80;
89+
} else if (capacity == 1024 + 200) {
90+
arrayToReuse = &freeBuffers1024;
91+
} else if (capacity == 4096 + 200) {
92+
arrayToReuse = &freeBuffers4096;
93+
} else if (capacity == 16384 + 200) {
94+
arrayToReuse = &freeBuffers16384;
95+
} else if (capacity == 40000) {
96+
arrayToReuse = &freeBuffers32768;
97+
} else if (capacity == 160000) {
98+
arrayToReuse = &freeBuffersBig;
99+
}
100+
if (arrayToReuse != nullptr) {
101+
if (isThreadSafe) {
102+
pthread_mutex_lock(&mutex);
103+
}
104+
if (arrayToReuse->size() < maxCount) {
105+
arrayToReuse->push_back(buffer);
106+
} else {
107+
// if (LOGS_ENABLED) DEBUG_D("too much %d buffers", capacity);
108+
delete buffer;
109+
}
110+
if (isThreadSafe) {
111+
pthread_mutex_unlock(&mutex);
112+
}
113+
} else {
114+
delete buffer;
115+
}
116+
}

android/app/jni/BuffersStorage.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This is the source code of tgnet library v. 1.1
3+
* It is licensed under GNU GPL v. 2 or later.
4+
* You should have received a copy of the license in this archive (see LICENSE).
5+
*
6+
* Copyright Nikolai Kudashov, 2015-2018.
7+
*/
8+
9+
#ifndef BUFFERSSTORAGE_H
10+
#define BUFFERSSTORAGE_H
11+
12+
#include <vector>
13+
#include <pthread.h>
14+
#include <stdint.h>
15+
16+
class NativeByteBuffer;
17+
18+
class BuffersStorage {
19+
20+
public:
21+
BuffersStorage(bool threadSafe);
22+
NativeByteBuffer *getFreeBuffer(uint32_t size);
23+
void reuseFreeBuffer(NativeByteBuffer *buffer);
24+
static BuffersStorage &getInstance();
25+
26+
private:
27+
std::vector<NativeByteBuffer *> freeBuffers8;
28+
std::vector<NativeByteBuffer *> freeBuffers128;
29+
std::vector<NativeByteBuffer *> freeBuffers1024;
30+
std::vector<NativeByteBuffer *> freeBuffers4096;
31+
std::vector<NativeByteBuffer *> freeBuffers16384;
32+
std::vector<NativeByteBuffer *> freeBuffers32768;
33+
std::vector<NativeByteBuffer *> freeBuffersBig;
34+
bool isThreadSafe = true;
35+
pthread_mutex_t mutex;
36+
};
37+
38+
#endif

android/app/jni/ByteArray.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
#include <stdlib.h>
3+
#include <memory.h>
4+
#include "ByteArray.h"
5+
#include "FileLog.h"
6+
7+
ByteArray::ByteArray() {
8+
bytes = nullptr;
9+
length = 0;
10+
}
11+
12+
ByteArray::ByteArray(uint32_t len) {
13+
bytes = new uint8_t[len];
14+
if (bytes == nullptr) {
15+
if (LOGS_ENABLED) DEBUG_E("unable to allocate byte buffer %u", len);
16+
exit(1);
17+
}
18+
length = len;
19+
}
20+
21+
22+
ByteArray::ByteArray(ByteArray *byteArray) {
23+
bytes = new uint8_t[byteArray->length];
24+
if (bytes == nullptr) {
25+
if (LOGS_ENABLED) DEBUG_E("unable to allocate byte buffer %u", byteArray->length);
26+
exit(1);
27+
}
28+
length = byteArray->length;
29+
memcpy(bytes, byteArray->bytes, length);
30+
}
31+
32+
ByteArray::ByteArray(uint8_t *buffer, uint32_t len) {
33+
bytes = new uint8_t[len];
34+
if (bytes == nullptr) {
35+
if (LOGS_ENABLED) DEBUG_E("unable to allocate byte buffer %u", len);
36+
exit(1);
37+
}
38+
length = len;
39+
memcpy(bytes, buffer, length);
40+
}
41+
42+
ByteArray::~ByteArray() {
43+
if (bytes != nullptr) {
44+
delete[] bytes;
45+
bytes = nullptr;
46+
}
47+
}
48+
49+
void ByteArray::alloc(uint32_t len) {
50+
if (bytes != nullptr) {
51+
delete[] bytes;
52+
bytes = nullptr;
53+
}
54+
bytes = new uint8_t[len];
55+
if (bytes == nullptr) {
56+
if (LOGS_ENABLED) DEBUG_E("unable to allocate byte buffer %u", len);
57+
exit(1);
58+
}
59+
length = len;
60+
}
61+
62+
bool ByteArray::isEqualTo(ByteArray *byteArray) {
63+
return byteArray->length == length && !memcmp(byteArray->bytes, bytes, length);
64+
}

android/app/jni/ByteArray.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This is the source code of tgnet library v. 1.1
3+
* It is licensed under GNU GPL v. 2 or later.
4+
* You should have received a copy of the license in this archive (see LICENSE).
5+
*
6+
* Copyright Nikolai Kudashov, 2015-2018.
7+
*/
8+
9+
#ifndef BYTEARRAY_H
10+
#define BYTEARRAY_H
11+
12+
#include <stdint.h>
13+
14+
class ByteArray {
15+
16+
public:
17+
ByteArray();
18+
ByteArray(uint32_t len);
19+
ByteArray(ByteArray *byteArray);
20+
ByteArray(uint8_t *buffer, uint32_t len);
21+
~ByteArray();
22+
void alloc(uint32_t len);
23+
24+
uint32_t length;
25+
uint8_t *bytes;
26+
27+
bool isEqualTo(ByteArray *byteArray);
28+
29+
};
30+
31+
#endif

0 commit comments

Comments
 (0)