send hash to firebase
This commit is contained in:
parent
dd00230e69
commit
ecbfd294a8
7 changed files with 58 additions and 15 deletions
|
@ -54,7 +54,7 @@ import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
|||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus;
|
||||
import info.nightscout.androidaps.plugins.general.versionChecker.VersionCheckerUtilsKt;
|
||||
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtilsKt;
|
||||
import info.nightscout.androidaps.setupwizard.SetupWizardActivity;
|
||||
import info.nightscout.androidaps.tabs.TabPageAdapter;
|
||||
import info.nightscout.androidaps.utils.AndroidPermission;
|
||||
|
|
|
@ -49,9 +49,9 @@ import info.nightscout.androidaps.plugins.general.nsclient.receivers.AckAlarmRec
|
|||
import info.nightscout.androidaps.plugins.general.nsclient.receivers.DBAccessReceiver;
|
||||
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.signatureVerifier.SignatureVerifier;
|
||||
import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifier;
|
||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.versionChecker.VersionCheckerPlugin;
|
||||
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.wear.WearPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.xdripStatusline.StatuslinePlugin;
|
||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin;
|
||||
|
@ -91,7 +91,7 @@ import info.nightscout.androidaps.services.Intents;
|
|||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
|
||||
import static info.nightscout.androidaps.plugins.general.versionChecker.VersionCheckerUtilsKt.triggerCheckVersion;
|
||||
import static info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtilsKt.triggerCheckVersion;
|
||||
|
||||
|
||||
public class MainApp extends Application {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.plugins.general.signatureVerifier;
|
||||
package info.nightscout.androidaps.plugins.constraints.signatureVerifier;
|
||||
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.Signature;
|
||||
|
@ -124,14 +124,51 @@ public class SignatureVerifier extends PluginBase implements ConstraintsInterfac
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
log.error("Error in SignatureVerifier", e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
} catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) {
|
||||
log.error("Error in SignatureVerifier", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String> shortHashes() {
|
||||
List<String> hashes = new ArrayList<>();
|
||||
try {
|
||||
Signature[] signatures = MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), PackageManager.GET_SIGNATURES).signatures;
|
||||
if (signatures != null) {
|
||||
for (Signature signature : signatures) {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA256");
|
||||
byte[] fingerprint = digest.digest(signature.toByteArray());
|
||||
String hash = Hex.toHexString(fingerprint);
|
||||
log.debug("Found signature: " + hash);
|
||||
log.debug("Found signature (short): " + singleCharMap(fingerprint));
|
||||
hashes.add(singleCharMap(fingerprint));
|
||||
}
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) {
|
||||
log.error("Error in SignatureVerifier", e);
|
||||
}
|
||||
return hashes;
|
||||
}
|
||||
|
||||
String map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"§$%&/()=?,.-;:_<>|°^`´\\@€*'#+~{}[]¿¡áéíóúàèìòùöäü`ÁÉÍÓÚÀÈÌÒÙÖÄÜßÆÇÊËÎÏԌ۟æçêëîïôœûÿĆČĐŠŽćđšžñΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡ\u03A2ΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϨϩϪϫϬϭϮϯϰϱϲϳϴϵ϶ϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗ";
|
||||
|
||||
private String singleCharMap(byte[] array) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : array) {
|
||||
sb.append(map.charAt(b & 0xFF));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String singleCharUnMap(String shortHash) {
|
||||
byte[] array = new byte[shortHash.length()];
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
sb.append(String.format("%02x",(int) map.charAt(map.indexOf(shortHash.charAt(i)))));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private boolean shouldDownloadCerts() {
|
||||
return System.currentTimeMillis() - SP.getLong(R.string.key_last_revoked_certs_check, 0L) >= UPDATE_INTERVAL;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.plugins.general.versionChecker
|
||||
package info.nightscout.androidaps.plugins.constraints.versionChecker
|
||||
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.plugins.general.versionChecker
|
||||
package info.nightscout.androidaps.plugins.constraints.versionChecker
|
||||
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
|
@ -8,10 +8,13 @@ import com.google.firebase.analytics.FirebaseAnalytics;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifier;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 21/02/2018.
|
||||
|
@ -112,9 +115,9 @@ public class FabricPrivacy {
|
|||
|
||||
String closedLoopEnabled = MainApp.getConstraintChecker().isClosedLoopAllowed().value() ? "CLOSED_LOOP_ENABLED" : "CLOSED_LOOP_DISABLED";
|
||||
// Size is limited to 36 chars
|
||||
String remote = BuildConfig.REMOTE
|
||||
.replace("https://","")
|
||||
.replace("http://","")
|
||||
String remote = BuildConfig.REMOTE.toLowerCase()
|
||||
.replace("https://", "")
|
||||
.replace("http://", "")
|
||||
.replace(".git", "")
|
||||
.replace(".com/", ":")
|
||||
.replace(".org/", ":")
|
||||
|
@ -125,6 +128,10 @@ public class FabricPrivacy {
|
|||
MainApp.getFirebaseAnalytics().setUserProperty("Version", BuildConfig.VERSION);
|
||||
MainApp.getFirebaseAnalytics().setUserProperty("HEAD", BuildConfig.HEAD);
|
||||
MainApp.getFirebaseAnalytics().setUserProperty("Remote", remote);
|
||||
List<String> hashes = SignatureVerifier.getPlugin().shortHashes();
|
||||
if (hashes.size() > 1)
|
||||
MainApp.getFirebaseAnalytics().setUserProperty("Hash", hashes.get(0));
|
||||
|
||||
if (ConfigBuilderPlugin.getPlugin().getActivePump() != null)
|
||||
MainApp.getFirebaseAnalytics().setUserProperty("Pump", ConfigBuilderPlugin.getPlugin().getActivePump().getClass().getSimpleName());
|
||||
if (ConfigBuilderPlugin.getPlugin().getActiveAPS() != null)
|
||||
|
@ -137,7 +144,6 @@ public class FabricPrivacy {
|
|||
MainApp.getFirebaseAnalytics().setUserProperty("Sensitivity", ConfigBuilderPlugin.getPlugin().getActiveSensitivity().getClass().getSimpleName());
|
||||
if (ConfigBuilderPlugin.getPlugin().getActiveInsulin() != null)
|
||||
MainApp.getFirebaseAnalytics().setUserProperty("Insulin", ConfigBuilderPlugin.getPlugin().getActiveInsulin().getClass().getSimpleName());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.plugins.general.versionChecker
|
||||
package info.nightscout.androidaps.plugins.constraints.versionChecker
|
||||
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
Loading…
Reference in a new issue