正在查看: xDrip+ v04633772025.07.16 应用的 NSEmulatorReceiver.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: xDrip+ v04633772025.07.16 应用的 NSEmulatorReceiver.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.eveningoutpost.dexdrip;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Process;
import android.util.Base64;
import com.eveningoutpost.dexdrip.models.BgReading;
import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.models.LibreOOPAlgorithm;
import com.eveningoutpost.dexdrip.models.Sensor;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
import java.util.ArrayList;
import java.util.UUID;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class NSEmulatorReceiver extends BroadcastReceiver {
private static final Object lock = new Object();
private static SharedPreferences prefs;
@Override
public void onReceive(final Context context, final Intent intent) {
new Thread() {
@Override
public void run() {
throw new UnsupportedOperationException("Method not decompiled: com.eveningoutpost.dexdrip.NSEmulatorReceiver.AnonymousClass1.run():void");
}
}.start();
}
private double getOOP2Version(Bundle bundle) {
return Double.valueOf(bundle.getDouble("OOP2_VERSION", BgReading.BESTOFFSET)).doubleValue();
}
private JSONObject extractParams(Bundle bundle) {
if (bundle == null) {
UserError.Log.e("jamorham nsemulator", "Null bundle passed to extract params");
return null;
}
double oOP2Version = getOOP2Version(bundle);
boolean equals = Pref.getString("calibrate_external_libre_2_algorithm_type", "calibrate_raw").equals("calibrate_raw");
UserError.Log.d("jamorham nsemulator", "oop2 version = " + oOP2Version + " calibarate_raw " + equals);
if (oOP2Version < 1.2d && !equals) {
JoH.static_toast_long(xdrip.gs(2131756021));
UserError.Log.ueh("jamorham nsemulator", "OOP2 is too old to use with no calibration mode. Please update OOP2 or move to 'calibrate based on raw' mode.");
return null;
}
String string = bundle.getString("json");
if (string == null) {
UserError.Log.e("jamorham nsemulator", "json == null returning");
return null;
}
try {
JSONObject jSONObject = new JSONObject(string);
int i = jSONObject.getInt("ROW_ID");
if (i == Process.myPid()) {
return jSONObject;
}
UserError.Log.d("jamorham nsemulator", "Ignoring OOP result since process id is wrong " + i);
return null;
} catch (JSONException e) {
UserError.Log.e("jamorham nsemulator", "Got JSON exception: " + e);
return null;
}
}
public void handleOop2DecodeFramResult(Bundle bundle) {
int[] iArr;
int[] iArr2;
if (Pref.getBooleanDefaultFalse("external_blukon_algorithm")) {
UserError.Log.e("jamorham nsemulator", "External OOP algorithm is on, ignoring decoded data.");
return;
}
JSONObject extractParams = extractParams(bundle);
if (extractParams == null) {
return;
}
try {
String string = extractParams.getString("DecodedBuffer");
String string2 = extractParams.getString("PatchUid");
String string3 = extractParams.getString("PatchInfo");
String string4 = extractParams.getString("TagId");
long j = extractParams.getLong("com.eveningoutpost.dexdrip.Extras.TIMESTAMP");
if (extractParams.has("TrendBg") && extractParams.has("HistoricBg")) {
JSONArray jSONArray = extractParams.getJSONArray("TrendBg");
int[] iArr3 = new int[jSONArray.length()];
for (int i = 0; i < jSONArray.length(); i++) {
iArr3[i] = jSONArray.getInt(i);
}
JSONArray jSONArray2 = extractParams.getJSONArray("HistoricBg");
int[] iArr4 = new int[jSONArray2.length()];
for (int i2 = 0; i2 < jSONArray2.length(); i2++) {
iArr4[i2] = jSONArray2.getInt(i2);
}
iArr2 = iArr4;
iArr = iArr3;
} else {
iArr = null;
iArr2 = null;
}
if (string == null) {
UserError.Log.e("jamorham nsemulator", "Error could not get decoded_buffer");
} else {
LibreOOPAlgorithm.handleOop2DecodeFramResult(string4, j, Base64.decode(string, 2), Base64.decode(string2, 2), Base64.decode(string3, 2), iArr, iArr2);
}
} catch (JSONException e) {
UserError.Log.e("jamorham nsemulator", "Error JSONException ", e);
}
}
public void handleOop2DecodeBleResult(Bundle bundle) {
int[] iArr;
int[] iArr2;
if (Pref.getBooleanDefaultFalse("external_blukon_algorithm")) {
UserError.Log.e("jamorham nsemulator", "External OOP algorithm is on, ignoring ble decrypted data.");
return;
}
JSONObject extractParams = extractParams(bundle);
if (extractParams == null) {
return;
}
try {
String string = extractParams.getString("DecodedBuffer");
String string2 = extractParams.getString("PatchUid");
long j = extractParams.getLong("com.eveningoutpost.dexdrip.Extras.TIMESTAMP");
if (extractParams.has("TrendBg") && extractParams.has("HistoricBg")) {
JSONArray jSONArray = extractParams.getJSONArray("TrendBg");
int[] iArr3 = new int[jSONArray.length()];
for (int i = 0; i < jSONArray.length(); i++) {
iArr3[i] = jSONArray.getInt(i);
}
JSONArray jSONArray2 = extractParams.getJSONArray("HistoricBg");
int[] iArr4 = new int[jSONArray2.length()];
for (int i2 = 0; i2 < jSONArray2.length(); i2++) {
iArr4[i2] = jSONArray2.getInt(i2);
}
iArr2 = iArr4;
iArr = iArr3;
} else {
iArr = null;
iArr2 = null;
}
if (string == null) {
UserError.Log.e("jamorham nsemulator", "Error could not get decoded_buffer");
} else {
Sensor.createDefaultIfMissing();
LibreOOPAlgorithm.handleDecodedBleResult(j, Base64.decode(string, 2), Base64.decode(string2, 2), iArr, iArr2);
}
} catch (JSONException e) {
UserError.Log.e("jamorham nsemulator", "Error JSONException ", e);
}
}
public void handleOop2BluetoothEnableResult(Bundle bundle) {
int i;
if (Pref.getBooleanDefaultFalse("external_blukon_algorithm")) {
UserError.Log.e("jamorham nsemulator", "External OOP algorithm is on, ignoring data.");
return;
}
JSONObject extractParams = extractParams(bundle);
if (extractParams == null) {
return;
}
ArrayList arrayList = new ArrayList();
try {
String string = extractParams.getString("BtUnlockBuffer");
String string2 = extractParams.getString("NfcUnlockBuffer");
String string3 = extractParams.getString("PatchUid");
String string4 = extractParams.getString("PatchInfo");
String string5 = extractParams.getString("DeviceName");
if (extractParams.has("ConnectionIndex")) {
int i2 = extractParams.getInt("ConnectionIndex");
JSONArray jSONArray = extractParams.getJSONArray("BtUnlockBufferArray");
for (int i3 = 0; i3 < jSONArray.length(); i3++) {
arrayList.add(Base64.decode(jSONArray.getString(i3), 2));
}
i = i2;
} else {
i = -1;
}
LibreOOPAlgorithm.handleOop2BluetoothEnableResult(Base64.decode(string, 2), Base64.decode(string2, 2), Base64.decode(string3, 2), Base64.decode(string4, 2), string5, arrayList, i);
} catch (JSONException e) {
UserError.Log.e("jamorham nsemulator", "Error JSONException ", e);
}
}
public static BgReading bgReadingInsertFromData(long j, double d, double d2, boolean z) {
UserError.Log.d("jamorham nsemulator", "bgReadingInsertFromData called timestamp = " + j + " bg = " + d + " time =" + JoH.dateTimeText(j));
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("timestamp", j);
jSONObject.put("calculated_value", d);
jSONObject.put("filtered_calculated_value", d);
jSONObject.put("calculated_value_slope", d2);
jSONObject.put("source_info", "NSEmulator Follow");
jSONObject.put("raw_data", d);
jSONObject.put("age_adjusted_raw_value", d);
jSONObject.put("filtered_data", d);
jSONObject.put("uuid", UUID.randomUUID().toString());
UserError.Log.d("jamorham nsemulator", "Received NSEmulator SGV: " + jSONObject);
Sensor.createDefaultIfMissing();
return BgReading.bgReadingInsertFromJson(jSONObject.toString(), z, true);
} catch (JSONException e) {
UserError.Log.e("jamorham nsemulator", "bgReadingInsertFromData Got JSON exception: " + e);
return null;
}
}
}