Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Vasilis
2022-03-17 14:08:30 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a4443cae5c608ef1c4e5e0212877bbcafcf44eed
a4443cae
1 parent
d2a4bf8c
removal of caching and wifi
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
42 deletions
WarplySDKFrameworkIOS/Warply/Warply.m
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/MyApi.m
WarplySDKFrameworkIOS/Warply/Warply.m
View file @
a4443ca
...
...
@@ -316,36 +316,36 @@ typedef void (^FailureResponse)(NSURLSessionDataTask * _Nullable task, NSError *
AFNetworkReachabilityStatus
oldstatus
=
self
.
networkStatus
;
_networkStatus
=
networkStatus
;
switch
(
networkStatus
)
{
case
AFNetworkReachabilityStatusReachableViaWiFi
:
[
_db
executeUpdate
:
@"UPDATE netstats SET wifi = wifi + 1, wifistart_timestamp = (julianday('now') - 2440587.5)*86400.0, wifi_dirty = 1"
];
[
_db
executeUpdate
:
@"UPDATE netstats SET overall = wifi + wwan;"
];
[
self
calculateNetworkReachabilityStatisticsForStatus
:
AFNetworkReachabilityStatusReachableViaWWAN
];
break
;
case
AFNetworkReachabilityStatusReachableViaWWAN
:
[
_db
executeUpdate
:
@"UPDATE netstats SET wwan = wwan + 1, wwanstart_timestamp = (julianday('now') - 2440587.5)*86400.0, wwan_dirty = 1"
];
[
_db
executeUpdate
:
@"UPDATE netstats SET overall = wifi + wwan;"
];
[
self
calculateNetworkReachabilityStatisticsForStatus
:
AFNetworkReachabilityStatusReachableViaWiFi
];
default
:
[
self
calculateNetworkReachabilityStatisticsForStatus
:
oldstatus
];
break
;
}
//
switch (networkStatus) {
//
case AFNetworkReachabilityStatusReachableViaWiFi:
//
[_db executeUpdate:@"UPDATE netstats SET wifi = wifi + 1, wifistart_timestamp = (julianday('now') - 2440587.5)*86400.0, wifi_dirty = 1"];
//
[_db executeUpdate:@"UPDATE netstats SET overall = wifi + wwan;"];
//
[self calculateNetworkReachabilityStatisticsForStatus:AFNetworkReachabilityStatusReachableViaWWAN];
//
break;
//
case AFNetworkReachabilityStatusReachableViaWWAN:
//
[_db executeUpdate:@"UPDATE netstats SET wwan = wwan + 1, wwanstart_timestamp = (julianday('now') - 2440587.5)*86400.0, wwan_dirty = 1"];
//
[_db executeUpdate:@"UPDATE netstats SET overall = wifi + wwan;"];
//
[self calculateNetworkReachabilityStatisticsForStatus:AFNetworkReachabilityStatusReachableViaWiFi];
//
default:
//
[self calculateNetworkReachabilityStatisticsForStatus:oldstatus];
//
break;
//
}
WL_FMDBLogError
double
wifiPercentage
=
0
.
0
;
double
wwanPercentage
=
0
.
0
;
FMResultSet
*
rs
=
[
_db
executeQuery
:
@"SELECT * FROM netstats WHERE _id = 1"
];
while
([
rs
next
])
{
wifiPercentage
=
([[
rs
resultDictionary
][
@"wifi"
]
doubleValue
]
/
[[
rs
resultDictionary
][
@"overall"
]
doubleValue
])
*
100
;
wwanPercentage
=
([[
rs
resultDictionary
][
@"wwan"
]
doubleValue
]
/
[[
rs
resultDictionary
][
@"overall"
]
doubleValue
])
*
100
;
}
//
FMResultSet *rs = [_db executeQuery:@"SELECT * FROM netstats WHERE _id = 1"];
//
while ([rs next]) {
//
wifiPercentage = ([[rs resultDictionary][@"wifi"] doubleValue]/[[rs resultDictionary][@"overall"] doubleValue])*100;
//
wwanPercentage = ([[rs resultDictionary][@"wwan"] doubleValue]/[[rs resultDictionary][@"overall"] doubleValue])*100;
//
}
WL_FMDBLogError
NSDictionary
*
networkStatistics
=
@{
@"wifi"
:
@
([[
NSString
stringWithFormat
:
@"%.2f"
,
wifiPercentage
]
doubleValue
]),
@"wwan"
:
@
([[
NSString
stringWithFormat
:
@"%.2f"
,
wwanPercentage
]
doubleValue
])};
WLEventSimple
*
event
=
[[
WLEventSimple
alloc
]
initWithType
:
@"device_info"
andContext
:@{
@"device_info"
:
@{
@"usage"
:
networkStatistics
}}];
[[
Warply
sharedService
]
addEvent
:(
WLEvent
*
)
event
priority
:
NO
];
//
NSDictionary *networkStatistics = @{@"wifi": @([[NSString stringWithFormat:@"%.2f",wifiPercentage] doubleValue]), @"wwan": @([[NSString stringWithFormat:@"%.2f",wwanPercentage] doubleValue])};
//
WLEventSimple *event = [[WLEventSimple alloc] initWithType:@"device_info" andContext:@{@"device_info": @{@"usage":networkStatistics}}];
//
[[Warply sharedService] addEvent:(WLEvent*)event priority:NO];
}
#pragma mark - Public Methods
...
...
@@ -4235,11 +4235,11 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
WL_FMDBLogError
}
if
([
_db
tableExists
:
@"netstats"
]
==
NO
)
{
[
_db
executeUpdate
:
@"CREATE TABLE netstats (_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, wifi INTEGER, wwan INTEGER, overall INTEGER, wifistart_timestamp INTEGER, wifiend_timestamp INTEGER, wifi_totaltime INTEGER, wifi_dirty INTEGER, wwanstart_timestamp INTEGER, wwanend_timestamp INTEGER, wwan_totaltime INTEGER, wwan_dirty INTEGER)"
];
[
_db
executeUpdate
:
@"INSERT INTO netstats (_id, wifi, wwan, overall, wifi_totaltime, wifi_dirty, wwan_totaltime, wwan_dirty) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)"
,
@0
,
@0
,
@0
,
@0
,
@0
,
@0
,
@0
];
WL_FMDBLogError
}
//
if ([_db tableExists:@"netstats"] == NO) {
//
[_db executeUpdate:@"CREATE TABLE netstats (_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, wifi INTEGER, wwan INTEGER, overall INTEGER, wifistart_timestamp INTEGER, wifiend_timestamp INTEGER, wifi_totaltime INTEGER, wifi_dirty INTEGER, wwanstart_timestamp INTEGER, wwanend_timestamp INTEGER, wwan_totaltime INTEGER, wwan_dirty INTEGER)"];
//
[_db executeUpdate:@"INSERT INTO netstats (_id, wifi, wwan, overall, wifi_totaltime, wifi_dirty, wwan_totaltime, wwan_dirty) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)", @0, @0, @0, @0, @0, @0, @0];
//
WL_FMDBLogError
//
}
if
([
_db
tableExists
:
@"pois"
]
==
NO
)
{
[
_db
executeUpdate
:
@"CREATE TABLE pois (id INTEGER PRIMARY KEY NOT NULL UNIQUE, lat NUMERIC, lon NUMERIC, radius NUMERIC)"
];
...
...
@@ -4464,24 +4464,24 @@ static void distanceFunc(sqlite3_context *context, int argc, sqlite3_value **arg
{
NSTimeInterval
wifiTotalTime
=
0
.
0
;
NSTimeInterval
wwanTotalTime
=
0
.
0
;
if
(
status
==
AFNetworkReachabilityStatusReachableViaWiFi
)
{
[
_db
executeUpdate
:
@"UPDATE netstats SET wifiend_timestamp = (julianday('now') - 2440587.5)*86400.0 where wifi_dirty = 1"
];
[
_db
executeUpdate
:
@"UPDATE netstats SET wifi_totaltime = wifi_totaltime + (wifiend_timestamp - wifistart_timestamp), wifi_dirty = 0 where wifi_dirty = 1"
];
}
else
if
(
status
==
AFNetworkReachabilityStatusReachableViaWWAN
)
{
[
_db
executeUpdate
:
@"UPDATE netstats SET wwanend_timestamp = (julianday('now') - 2440587.5)*86400.0 where wwan_dirty = 1"
];
[
_db
executeUpdate
:
@"UPDATE netstats SET wwan_totaltime = wwan_totaltime + (wwanend_timestamp - wwanstart_timestamp), wwan_dirty = 0 where wwan_dirty = 1"
];
}
//
if (status == AFNetworkReachabilityStatusReachableViaWiFi) {
//
[_db executeUpdate:@"UPDATE netstats SET wifiend_timestamp = (julianday('now') - 2440587.5)*86400.0 where wifi_dirty = 1"];
//
[_db executeUpdate:@"UPDATE netstats SET wifi_totaltime = wifi_totaltime + (wifiend_timestamp - wifistart_timestamp), wifi_dirty = 0 where wifi_dirty = 1"];
//
} else if (status == AFNetworkReachabilityStatusReachableViaWWAN) {
//
[_db executeUpdate:@"UPDATE netstats SET wwanend_timestamp = (julianday('now') - 2440587.5)*86400.0 where wwan_dirty = 1"];
//
[_db executeUpdate:@"UPDATE netstats SET wwan_totaltime = wwan_totaltime + (wwanend_timestamp - wwanstart_timestamp), wwan_dirty = 0 where wwan_dirty = 1"];
//
}
FMResultSet
*
rs
=
[
_db
executeQuery
:
@"SELECT * FROM netstats WHERE _id = 1"
];
while
([
rs
next
])
{
wifiTotalTime
=
[[
rs
resultDictionary
][
@"wifi_totaltime"
]
doubleValue
];
wwanTotalTime
=
[[
rs
resultDictionary
][
@"wwan_totaltime"
]
doubleValue
];
}
//
FMResultSet *rs = [_db executeQuery:@"SELECT * FROM netstats WHERE _id = 1"];
//
while ([rs next]) {
//
wifiTotalTime = [[rs resultDictionary][@"wifi_totaltime"] doubleValue];
//
wwanTotalTime = [[rs resultDictionary][@"wwan_totaltime"] doubleValue];
//
}
NSDictionary
*
networkStatistics
=
@{
@"wifi"
:
@
(
round
(
wifiTotalTime
)),
@"wwan"
:
@
(
round
(
wwanTotalTime
))};
WLEventSimple
*
event
=
[[
WLEventSimple
alloc
]
initWithType
:
@"device_info"
andContext
:@{
@"device_info"
:
@{
@"time"
:
networkStatistics
}}];
[[
Warply
sharedService
]
addEvent
:(
WLEvent
*
)
event
priority
:
NO
];
//
NSDictionary *networkStatistics = @{@"wifi": @(round(wifiTotalTime)), @"wwan": @(round(wwanTotalTime))};
//
WLEventSimple *event = [[WLEventSimple alloc] initWithType:@"device_info" andContext:@{@"device_info": @{@"time":networkStatistics}}];
//
[[Warply sharedService] addEvent:(WLEvent*)event priority:NO];
}
#pragma mark - Memory Management
...
...
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/MyApi.m
View file @
a4443ca
...
...
@@ -28,6 +28,11 @@ NSString *LANG;
[[
Warply
sharedService
].
pushManager
resetBadge
];
MERCHANT_ID
=
merchantId
;
LANG
=
lang
;
//removal of caching
int
cacheSizeMemory
=
0
;
// 0MB
int
cacheSizeDisk
=
0
;
// 0MB
NSURLCache
*
sharedCache
=
[[
NSURLCache
alloc
]
initWithMemoryCapacity
:
cacheSizeMemory
diskCapacity
:
cacheSizeDisk
diskPath
:
@"nsurlcache"
];
[
NSURLCache
setSharedURLCache
:
sharedCache
];
}
-
(
void
)
setToStage
{
...
...
Please
register
or
login
to post a comment