Commit a22ac375 authored by axet's avatar axet 🍄

Merge branch 'smsgate-1.8.18'

parents 20cf5a9c 36f6156b
Pipeline #19655119 passed with stage
in 25 seconds
......@@ -8,8 +8,8 @@ android {
applicationId "com.github.axet.smsgate"
minSdkVersion 9
targetSdkVersion 23
versionCode 201
versionName "1.8.17"
versionCode 202
versionName "1.8.18"
}
packagingOptions {
exclude 'META-INF/LICENSE'
......
......@@ -15,6 +15,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteException;
......@@ -380,6 +381,26 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
void run(JSONObject json);
}
public static class Info extends Message {
private String version;
public Info() {
}
public Info(String v, String m) {
super(m);
version = v;
}
public String getVersion() {
return version;
}
public void setVersion(String v) {
version = v;
}
}
public static class Message {
private String id;
private long date;
......@@ -1488,34 +1509,32 @@ public class FirebaseService extends Service implements FirebaseAuth.AuthStateLi
}
void info() {
final QueryBuilder b = new QueryBuilder(this);
info.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Message m = dataSnapshot.getValue(Message.class);
Object v = dataSnapshot.getValue();
try {
long l = 0;
if (m != null) {
String t = m.getText();
if (t != null) {
String text = keyPair.decrypt(t);
JSONObject obj = new JSONObject(text);
l = obj.optLong("last", 0);
}
}
if (l <= 0) { // force reupload all
b.setLastSMS(l);
messages();
if (v == null) {
QueryBuilder b = new QueryBuilder(FirebaseService.this);
b.setLastSMS(0);
}
final JSONObject json = new JSONObject();
json.put("uptime", Long.toString(SystemClock.elapsedRealtime()));
json.put("os", Build.BRAND + " " + android.os.Build.VERSION.RELEASE);
json.put("sim", sim.getCount());
json.put("battery", getBatteryLevel());
json.put("last", b.getLastSMS());
if (phone.isTelephony())
json.put("signal", getSignalLevel());
info.setValue(new Message(keyPair.encrypt(json.toString()))).addOnSuccessListener(new OnSuccessListener<Void>() {
String version = "";
try {
PackageManager pm = getPackageManager();
ApplicationInfo a = pm.getApplicationInfo(getPackageName(), 0);
PackageInfo pInfo = pm.getPackageInfo(getPackageName(), 0);
version = "v" + pInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
info.setValue(new Info(version, keyPair.encrypt(json.toString()))).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Log.d(TAG, "info updated");
......
......@@ -5,7 +5,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.1.0'
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment