cordova-plugin-mserviceinterface-2.0 1.0.46 → 1.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/android/mInterfaceService.java +30 -50
- package/src/ios/mInterface.h +1 -0
- package/src/ios/mInterface.m +28 -0
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
3
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
4
|
id="cordova-plugin-mserviceinterface-2.0"
|
|
5
|
-
version="1.0.
|
|
5
|
+
version="1.0.48">
|
|
6
6
|
<name>mserviceinterface-2.0</name>
|
|
7
7
|
<description>This plugin establishes the connection to the native interface and performs the requested task.</description>
|
|
8
8
|
<author>selfservit@gmail.com</author>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package com.selfservit.util;
|
|
2
2
|
|
|
3
|
+
import static com.selfservit.util.mInterfaceUtil.decrypt;
|
|
4
|
+
|
|
3
5
|
import android.Manifest;
|
|
4
6
|
import android.annotation.TargetApi;
|
|
5
7
|
import android.app.AlarmManager;
|
|
@@ -20,11 +22,15 @@ import android.net.Uri;
|
|
|
20
22
|
import android.os.AsyncTask;
|
|
21
23
|
import android.os.Build;
|
|
22
24
|
import android.os.Bundle;
|
|
23
|
-
import android.os.Environment;
|
|
24
25
|
import android.os.IBinder;
|
|
25
26
|
import android.os.Looper;
|
|
26
27
|
import android.os.SystemClock;
|
|
27
28
|
|
|
29
|
+
import androidx.annotation.NonNull;
|
|
30
|
+
import androidx.annotation.Nullable;
|
|
31
|
+
import androidx.annotation.RequiresApi;
|
|
32
|
+
import androidx.core.app.NotificationCompat;
|
|
33
|
+
|
|
28
34
|
import com.google.android.gms.common.ConnectionResult;
|
|
29
35
|
import com.google.android.gms.common.GooglePlayServicesUtil;
|
|
30
36
|
import com.google.android.gms.common.api.GoogleApiClient;
|
|
@@ -57,13 +63,6 @@ import java.util.TimerTask;
|
|
|
57
63
|
import javax.xml.parsers.DocumentBuilder;
|
|
58
64
|
import javax.xml.parsers.DocumentBuilderFactory;
|
|
59
65
|
|
|
60
|
-
import static com.selfservit.util.mInterfaceUtil.decrypt;
|
|
61
|
-
|
|
62
|
-
import androidx.annotation.NonNull;
|
|
63
|
-
import androidx.annotation.Nullable;
|
|
64
|
-
import androidx.annotation.RequiresApi;
|
|
65
|
-
import androidx.core.app.NotificationCompat;
|
|
66
|
-
|
|
67
66
|
@TargetApi(Build.VERSION_CODES.O)
|
|
68
67
|
public class mInterfaceService extends Service implements com.google.android.gms.location.LocationListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
|
|
69
68
|
public Timer setQueueInterval,
|
|
@@ -81,13 +80,15 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
81
80
|
public static boolean appStateTimerStatus = false;
|
|
82
81
|
String notification_icon, notification_color, app_name;
|
|
83
82
|
int imageResource, app_name_id, notification_color_id;
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
String locationUpdateInd = "false";
|
|
84
|
+
|
|
85
|
+
@Override
|
|
86
86
|
public IBinder onBind(Intent intent) {
|
|
87
87
|
// TODO: Return the communication channel to the service.
|
|
88
88
|
throw new UnsupportedOperationException("Not yet implemented");
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
|
|
91
|
+
@Override
|
|
91
92
|
@TargetApi(Build.VERSION_CODES.O)
|
|
92
93
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
93
94
|
try {
|
|
@@ -95,12 +96,12 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
95
96
|
if (mInterfaceUtil.packageName.equals("")) {
|
|
96
97
|
mInterfaceUtil.packageName = getApplicationContext().getPackageName().split("\\.")[2];
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
notification_icon = "@drawable/ic_notification";
|
|
100
|
+
notification_color = "@color/notification_accent";
|
|
101
|
+
app_name = "@string/app_name";
|
|
102
|
+
imageResource = getResources().getIdentifier(notification_icon, null, getPackageName());
|
|
103
|
+
app_name_id = getResources().getIdentifier(app_name, null, getPackageName());
|
|
104
|
+
notification_color_id = getResources().getIdentifier(notification_color, null, getPackageName());
|
|
104
105
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
105
106
|
String NOTIFICATION_CHANNEL_ID = "com.selfservit.msdoubleointeg";
|
|
106
107
|
String channelName = "DoubleO Background Service";
|
|
@@ -111,23 +112,23 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
111
112
|
assert manager != null;
|
|
112
113
|
manager.createNotificationChannel(chan);
|
|
113
114
|
|
|
114
|
-
Uri uri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
|
115
|
+
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
|
115
116
|
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
|
|
116
117
|
Notification notification = notificationBuilder.setOngoing(true)
|
|
117
|
-
.setContentTitle(getResources().getString(app_name_id)+" is running")
|
|
118
|
-
|
|
118
|
+
.setContentTitle(getResources().getString(app_name_id) + " is running")
|
|
119
|
+
.setSmallIcon(imageResource)
|
|
119
120
|
.setColor(getResources().getColor(notification_color_id))
|
|
120
121
|
.setPriority(NotificationManager.IMPORTANCE_MIN)
|
|
121
122
|
.setCategory(Notification.CATEGORY_SERVICE)
|
|
122
123
|
.setChannelId(NOTIFICATION_CHANNEL_ID)
|
|
123
|
-
.setVibrate(new long[]
|
|
124
|
+
.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000})
|
|
124
125
|
.setSound(uri)
|
|
125
126
|
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
|
126
127
|
.build();
|
|
127
128
|
startForeground(2, notification);
|
|
128
129
|
} else {
|
|
129
130
|
Notification notification = new NotificationCompat.Builder(this)
|
|
130
|
-
.setContentTitle(getResources().getString(app_name_id)+" is running")
|
|
131
|
+
.setContentTitle(getResources().getString(app_name_id) + " is running")
|
|
131
132
|
.setSmallIcon(imageResource)
|
|
132
133
|
.setColor(getResources().getColor(notification_color_id))
|
|
133
134
|
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
|
@@ -140,8 +141,7 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
140
141
|
TimerTask setQueueIntervalObj, setTimerIntervelObj;
|
|
141
142
|
Intent serviceIntent = new Intent(getApplicationContext(), mInterfaceReceiver.class);
|
|
142
143
|
serviceIntent.setAction("com.example.checkservice");
|
|
143
|
-
final PendingIntent pIntent = PendingIntent.getBroadcast(getApplicationContext(), 0,
|
|
144
|
-
serviceIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
144
|
+
final PendingIntent pIntent = PendingIntent.getBroadcast(getApplicationContext(), 0,serviceIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
145
145
|
long firstMillis = System.currentTimeMillis();
|
|
146
146
|
AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
|
147
147
|
alarm.setRepeating(AlarmManager.RTC_WAKEUP, firstMillis,
|
|
@@ -210,9 +210,9 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
|
-
if(setLocationTimeInterval == null){
|
|
213
|
+
if (setLocationTimeInterval == null) {
|
|
214
214
|
setLocationTimeInterval = new Timer();
|
|
215
|
-
setLocationTimeInterval.schedule(timerTask, Integer.parseInt(serverDateObj.optString("location_fetch_interval_in_seconds")), Integer.parseInt(serverDateObj.optString("location_fetch_interval_in_seconds")));
|
|
215
|
+
setLocationTimeInterval.schedule(timerTask, (Integer.parseInt(serverDateObj.optString("location_fetch_interval_in_seconds")) * 1000L), (Integer.parseInt(serverDateObj.optString("location_fetch_interval_in_seconds")) * 1000L));
|
|
216
216
|
MINIMUM_INTERVAL = Long.parseLong(serverDateObj.optString("location_fetch_interval_in_seconds").toString());
|
|
217
217
|
createLocationRequest();
|
|
218
218
|
this.mGoogleApiClient = new GoogleApiClient.Builder(this)
|
|
@@ -314,7 +314,7 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
314
314
|
new SendLocation().execute();
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
|
-
String string = ("
|
|
317
|
+
String string = ("Latitude : " + lat + "Longitude : " + lng + "\n");
|
|
318
318
|
System.out.println(string);
|
|
319
319
|
}
|
|
320
320
|
}
|
|
@@ -327,7 +327,7 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
327
327
|
String[] lastKnownLocation;
|
|
328
328
|
boolean result = false;
|
|
329
329
|
try {
|
|
330
|
-
|
|
330
|
+
baseDirectory = mInterfaceUtil.rootDirectory;
|
|
331
331
|
locationData = new StringBuilder();
|
|
332
332
|
File lastKnownLocationFile = new File(baseDirectory, "/" + mInterfaceUtil.packageName + "/LastKnownLocation_encrypted.txt");
|
|
333
333
|
if (lastKnownLocationFile.exists()) {
|
|
@@ -524,8 +524,6 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
524
524
|
DocumentBuilder dbObj;
|
|
525
525
|
Document docObj;
|
|
526
526
|
OutputStreamWriter oStreamObj;
|
|
527
|
-
|
|
528
|
-
|
|
529
527
|
JSONObject userObj;
|
|
530
528
|
HttpURLConnection urlConObj;
|
|
531
529
|
URL requestPath;
|
|
@@ -578,7 +576,7 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
578
576
|
int responseCode = urlConObj.getResponseCode();
|
|
579
577
|
|
|
580
578
|
urlConObj.disconnect();
|
|
581
|
-
if(responseCode == HttpURLConnection.HTTP_OK){
|
|
579
|
+
if (responseCode == HttpURLConnection.HTTP_OK) {
|
|
582
580
|
/* CLEARING THE LOCATION POINTS */
|
|
583
581
|
if (serverData != "") {
|
|
584
582
|
writerObj = new BufferedWriter(new FileWriter(new File(baseDirectory, "/" + mInterfaceUtil.packageName + "/MyLocation_encrypted.txt")));
|
|
@@ -706,29 +704,11 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
706
704
|
}
|
|
707
705
|
}
|
|
708
706
|
|
|
709
|
-
public class CoresTimerTask extends TimerTask {
|
|
710
|
-
private boolean hasStarted = false;
|
|
711
|
-
|
|
712
|
-
public void run() {
|
|
713
|
-
this.hasStarted = true;
|
|
714
|
-
setLocationTimeInterval = new Timer();
|
|
715
|
-
try {
|
|
716
|
-
getPeriodicalLocationUpdates();
|
|
717
|
-
} catch (Exception e) {
|
|
718
|
-
e.printStackTrace();
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
public boolean hasRunStarted() {
|
|
723
|
-
return this.hasStarted;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
707
|
|
|
727
708
|
public void update() throws IOException, JSONException {
|
|
728
709
|
TimerTask timerTask = new TimerTask() {
|
|
729
710
|
@Override
|
|
730
711
|
public void run() {
|
|
731
|
-
System.out.println("Updated timer");
|
|
732
712
|
try {
|
|
733
713
|
getPeriodicalLocationUpdates();
|
|
734
714
|
} catch (Exception e) {
|
|
@@ -749,7 +729,7 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
749
729
|
JSONObject serverDateObj = new JSONObject(decrypt(locConfigObj.toString()));
|
|
750
730
|
setLocationTimeInterval.cancel();
|
|
751
731
|
setLocationTimeInterval = new Timer();
|
|
752
|
-
setLocationTimeInterval.schedule(timerTask,
|
|
732
|
+
setLocationTimeInterval.schedule(timerTask, (Integer.parseInt(serverDateObj.optString("location_fetch_interval_in_seconds")) * 1000L), (Integer.parseInt(serverDateObj.optString("location_fetch_interval_in_seconds")) * 1000L));
|
|
753
733
|
}
|
|
754
734
|
}
|
|
755
735
|
|
package/src/ios/mInterface.h
CHANGED
|
@@ -99,6 +99,7 @@
|
|
|
99
99
|
- (void)GetNewDate:(CDVInvokedUrlCommand*)command;
|
|
100
100
|
- (id)getCurrentDateTime;
|
|
101
101
|
-(void)timeValues:(NSString *)date hour:(NSString *)hour minute:(NSString *)minute;
|
|
102
|
+
-(void)SendChatAttachment:(CDVInvokedUrlCommand*)command;
|
|
102
103
|
- (void)KillTimers;
|
|
103
104
|
//- (void)AuthenticationRefresh;
|
|
104
105
|
//- (void)triggerAuthenticationServices:(NSString *)clientId countryCode:(NSString *)countryCode userId:(NSString *)userId sessionId:(NSString *)sessionId localeId:(NSString *)localeId deviceID:(NSString *)deviceID clientUrl:(NSString *)clientUrl cvsUrl:(NSString *)cvsUrl authIndFilePath:(NSString *)authIndFilePath;
|
package/src/ios/mInterface.m
CHANGED
|
@@ -1490,6 +1490,34 @@
|
|
|
1490
1490
|
}
|
|
1491
1491
|
}
|
|
1492
1492
|
|
|
1493
|
+
- (void)SendChatAttachment:(CDVInvokedUrlCommand*)command {
|
|
1494
|
+
CDVPluginResult *result = nil;
|
|
1495
|
+
@try {
|
|
1496
|
+
NSString *statusIndication = @"false";
|
|
1497
|
+
NSMutableDictionary *inputObject = [[command arguments] objectAtIndex:0];
|
|
1498
|
+
NSString *filePath = inputObject[@"filePath"];
|
|
1499
|
+
NSString *serverPath = inputObject[@"serverPath"];
|
|
1500
|
+
NSString *fileName = inputObject[@"fileName"];
|
|
1501
|
+
NSString *attachURL = [NSString stringWithFormat:@"%@/common/components/msvFileHandler/UploadFiles.aspx?&client_id=%@&country_code=%@&path=%@", clientUrl, clientID, countryCode, serverPath];
|
|
1502
|
+
|
|
1503
|
+
statusIndication = [self sendFilesToServer:filePath fileName:fileName requestURL:attachURL];
|
|
1504
|
+
if ([statusIndication isEqualToString:@"true"]) {
|
|
1505
|
+
NSString *serviceResult = [NSString stringWithFormat:@"%s", "success"];
|
|
1506
|
+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:serviceResult];
|
|
1507
|
+
} else {
|
|
1508
|
+
NSString *serviceResult = [NSString stringWithFormat:@"%s", "failure"];
|
|
1509
|
+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:serviceResult];
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
|
1513
|
+
} @catch (NSException *exception) {
|
|
1514
|
+
NSString *fail_reason = [NSString stringWithFormat:@"%@\n%@\n%@",exception.name, exception.reason, exception.description ];
|
|
1515
|
+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:fail_reason];
|
|
1516
|
+
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
|
1517
|
+
NSLog(@"CheckLocation Exception is : %@", exception.description);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1493
1521
|
#pragma mark - MapViewDelegate
|
|
1494
1522
|
- (void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
|
|
1495
1523
|
|