正在查看: xDrip+ v04633772025.07.16 应用的 BroadcastService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: xDrip+ v04633772025.07.16 应用的 BroadcastService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.eveningoutpost.dexdrip.services.broadcastservice;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.IBinder;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import androidx.health.platform.client.error.ErrorCode;
import com.eveningoutpost.dexdrip.BestGlucose;
import com.eveningoutpost.dexdrip.models.Accuracy;
import com.eveningoutpost.dexdrip.models.BgReading;
import com.eveningoutpost.dexdrip.models.BloodTest;
import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.models.Treatments;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.services.broadcastservice.models.BroadcastModel;
import com.eveningoutpost.dexdrip.services.broadcastservice.models.GraphLine;
import com.eveningoutpost.dexdrip.services.broadcastservice.models.Settings;
import com.eveningoutpost.dexdrip.stats.StatsResult;
import com.eveningoutpost.dexdrip.store.FastStore;
import com.eveningoutpost.dexdrip.store.KeyStore;
import com.eveningoutpost.dexdrip.utilitymodels.BgGraphBuilder;
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
import com.eveningoutpost.dexdrip.utilitymodels.PumpStatus;
import com.eveningoutpost.dexdrip.utils.PowerStateReceiver;
import com.eveningoutpost.dexdrip.wearintegration.ExternalStatusService;
import com.eveningoutpost.dexdrip.xdrip;
import java.util.HashMap;
import java.util.Map;
import lecho.lib.hellocharts.model.Line;
public class BroadcastService extends Service {
public static SharedPreferences.OnSharedPreferenceChangeListener prefListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public final void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String str) {
BroadcastService.lambda$static$0(sharedPreferences, str);
}
};
protected Map<String, BroadcastModel> broadcastEntities;
protected String TAG = getClass().getSimpleName();
protected KeyStore keyStore = FastStore.getInstance();
private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(android.content.Context r28, android.content.Intent r29) {
throw new UnsupportedOperationException("Method not decompiled: com.eveningoutpost.dexdrip.services.broadcastservice.BroadcastService.AnonymousClass1.onReceive(android.content.Context, android.content.Intent):void");
}
};
@Override
public IBinder onBind(Intent intent) {
return null;
}
public static void lambda$static$0(SharedPreferences sharedPreferences, String str) {
if (str.equals("broadcast_service_enabled")) {
JoH.startService(BroadcastService.class);
}
}
@Override
public void onCreate() {
UserError.Log.e(this.TAG, "starting service");
this.broadcastEntities = new HashMap();
registerReceiver(this.broadcastReceiver, new IntentFilter("com.eveningoutpost.dexdrip.watch.wearintegration.BROADCAST_SERVICE_RECEIVER"));
JoH.startService(BroadcastService.class, "FUNCTION", "start");
super.onCreate();
}
@Override
public void onDestroy() {
UserError.Log.e(this.TAG, "killing service");
this.broadcastEntities.clear();
unregisterReceiver(this.broadcastReceiver);
super.onDestroy();
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
PowerManager.WakeLock wakeLock = JoH.getWakeLock(this.TAG, ErrorCode.INVALID_OWNERSHIP);
try {
if (!BroadcastEntry.isEnabled()) {
UserError.Log.d(this.TAG, "Service is NOT set be active - shutting down");
stopSelf();
JoH.releaseWakeLock(wakeLock);
return 2;
}
if (intent != null) {
String stringExtra = intent.getStringExtra("FUNCTION");
if (stringExtra != null) {
try {
handleCommand(stringExtra, intent);
} catch (Exception e) {
UserError.Log.e(this.TAG, "handleCommand Error: " + e.toString());
}
} else {
UserError.Log.d(this.TAG, "onStartCommand called without function");
}
}
JoH.releaseWakeLock(wakeLock);
return 1;
} catch (Throwable th) {
JoH.releaseWakeLock(wakeLock);
throw th;
}
}
private void handleCommand(java.lang.String r14, android.content.Intent r15) {
throw new UnsupportedOperationException("Method not decompiled: com.eveningoutpost.dexdrip.services.broadcastservice.BroadcastService.handleCommand(java.lang.String, android.content.Intent):void");
}
protected void sendBroadcast(String str, String str2, Bundle bundle) {
Intent intent = new Intent("com.eveningoutpost.dexdrip.watch.wearintegration.BROADCAST_SERVICE_SENDER");
UserError.Log.d(this.TAG, String.format("sendBroadcast functionName: %s, receiver: %s", str, str2));
if (str == null || str.isEmpty()) {
UserError.Log.d(this.TAG, "Error, function not specified");
return;
}
intent.putExtra("FUNCTION", str);
if (str2 != null && !str2.isEmpty()) {
intent.setPackage(str2);
}
if (bundle != null) {
intent.putExtras(bundle);
}
intent.addFlags(32);
xdrip.getAppContext().sendBroadcast(intent);
}
protected Bundle prepareStatisticBundle(BroadcastModel broadcastModel, int i) {
String str;
if (broadcastModel.isStatCacheValid(i)) {
UserError.Log.d(this.TAG, "Stats Cache Hit");
return broadcastModel.getStatBundle();
}
UserError.Log.d(this.TAG, "Stats Cache Miss");
UserError.Log.d(this.TAG, "Getting StatsResult");
Bundle bundle = new Bundle();
StatsResult statsResult = new StatsResult(Pref.getInstance(), 3600000 * i, JoH.tsl());
bundle.putString("status.avg", statsResult.getAverageUnitised());
bundle.putString("status.a1c_dcct", statsResult.getA1cDCCT());
bundle.putString("status.a1c_ifcc", statsResult.getA1cIFCC());
bundle.putString("status.in", statsResult.getInPercentage());
bundle.putString("status.high", statsResult.getHighPercentage());
bundle.putString("status.low", statsResult.getLowPercentage());
bundle.putString("status.stdev", statsResult.getStdevUnitised());
bundle.putString("status.gvi", statsResult.getGVI());
bundle.putString("status.carbs", String.valueOf(Math.round(statsResult.getTotal_carbs())));
bundle.putString("status.insulin", JoH.qs(statsResult.getTotal_insulin(), 2));
bundle.putString("status.royce_ratio", JoH.qs(statsResult.getRatio(), 2));
bundle.putString("status.capture_percentage", statsResult.getCapturePercentage(false));
bundle.putString("status.capture_realtime_capture_percentage", statsResult.getRealtimeCapturePercentage(false));
String evaluateAccuracy = Accuracy.evaluateAccuracy(259200000L);
if (evaluateAccuracy == null || evaluateAccuracy.length() <= 0) {
String evaluateAccuracy2 = BloodTest.evaluateAccuracy(259200000L);
if (evaluateAccuracy2 != null) {
str = " " + evaluateAccuracy2;
} else {
str = "";
}
evaluateAccuracy = str;
}
bundle.putString("status.accuracy", evaluateAccuracy);
bundle.putString("status.steps", String.valueOf(statsResult.getTotal_steps()));
broadcastModel.setStatCache(bundle, i);
return bundle;
}
protected Bundle prepareBgBundle(BroadcastModel broadcastModel) {
Settings settings;
double dg_mgdl;
boolean isStale;
long epochTimestamp;
String str;
String str2;
double d;
boolean z;
boolean z2;
if (broadcastModel == null || (settings = broadcastModel.getSettings()) == null) {
return null;
}
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(xdrip.getAppContext());
Bundle bundle = new Bundle();
bundle.putBoolean("doMgdl", defaultSharedPreferences.getString("units", "mgdl").equals("mgdl"));
bundle.putInt("phoneBattery", PowerStateReceiver.getBatteryLevel(xdrip.getAppContext()));
BestGlucose.DisplayGlucose displayGlucose = BestGlucose.getDisplayGlucose();
BgReading last = BgReading.last();
if (displayGlucose != null || last != null) {
if (displayGlucose != null) {
str2 = displayGlucose.delta_name;
dg_mgdl = displayGlucose.mgdl;
isStale = displayGlucose.isStale();
z = displayGlucose.isHigh();
z2 = displayGlucose.isLow();
epochTimestamp = displayGlucose.timestamp;
str = displayGlucose.plugin_name;
d = displayGlucose.delta_mgdl;
} else {
String dg_deltaName = last.getDg_deltaName();
dg_mgdl = last.getDg_mgdl();
isStale = last.isStale();
epochTimestamp = last.getEpochTimestamp();
str = "";
str2 = dg_deltaName;
d = BgReading.BESTOFFSET;
z = false;
z2 = false;
}
bundle.putString("bg.deltaName", str2);
bundle.putDouble("bg.valueMgdl", dg_mgdl);
bundle.putBoolean("bg.isHigh", z);
bundle.putBoolean("bg.isLow", z2);
bundle.putLong("bg.timeStamp", epochTimestamp);
bundle.putBoolean("bg.isStale", isStale);
bundle.putString("bg.plugin", str);
bundle.putDouble("bg.deltaValueMgdl", d);
bundle.putString("pumpJSON", PumpStatus.toJson());
Treatments last2 = Treatments.last();
if (last2 != null && last2.hasContent() && !last2.noteOnly()) {
double d2 = last2.insulin;
if (d2 > BgReading.BESTOFFSET) {
bundle.putDouble("treatment.insulin", d2);
}
double d3 = last2.carbs;
if (d3 > BgReading.BESTOFFSET) {
bundle.putDouble("treatment.carbs", d3);
}
bundle.putLong("treatment.timeStamp", last2.timestamp);
}
if (settings.isDisplayGraph()) {
long graphStart = settings.getGraphStart();
long graphEnd = settings.getGraphEnd();
long tsl = JoH.tsl();
if (graphStart == 0) {
graphStart = 7200000;
}
long j = tsl - graphStart;
long j2 = tsl + graphEnd;
bundle.putInt("fuzzer", 30000);
bundle.putLong("start", j);
bundle.putLong("end", j2);
bundle.putDouble("highMark", JoH.tolerantParseDouble(defaultSharedPreferences.getString("highValue", "170"), 170.0d));
bundle.putDouble("lowMark", JoH.tolerantParseDouble(defaultSharedPreferences.getString("lowValue", "70"), 70.0d));
BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(xdrip.getAppContext(), j, j2);
bgGraphBuilder.defaultLines(false);
bundle.putParcelable("graph.lowLine", new GraphLine(bgGraphBuilder.lowLine()));
bundle.putParcelable("graph.highLine", new GraphLine(bgGraphBuilder.highLine()));
bundle.putParcelable("graph.inRange", new GraphLine(bgGraphBuilder.inRangeValuesLine()));
bundle.putParcelable("graph.low", new GraphLine(bgGraphBuilder.lowValuesLine()));
bundle.putParcelable("graph.high", new GraphLine(bgGraphBuilder.highValuesLine()));
Line[] treatmentValuesLine = bgGraphBuilder.treatmentValuesLine();
bundle.putParcelable("graph.iob", new GraphLine(treatmentValuesLine[2]));
bundle.putParcelable("graph.treatment", new GraphLine(treatmentValuesLine[1]));
bundle.putParcelable("graph.predictedBg", new GraphLine(treatmentValuesLine[5]));
bundle.putParcelable("graph.cob", new GraphLine(treatmentValuesLine[6]));
bundle.putParcelable("graph.polyBg", new GraphLine(treatmentValuesLine[7]));
}
String s = this.keyStore.getS("last_iob");
if (s != null) {
bundle.putString("predict.IOB", s);
bundle.putLong("predict.IOB.timeStamp", this.keyStore.getL("last_iob_timestamp"));
}
String s2 = this.keyStore.getS("last_bwp");
if (s2 != null) {
bundle.putString("predict.BWP", s2);
bundle.putLong("predict.BWP.timeStamp", this.keyStore.getL("last_bwp_timestamp"));
}
bundle.putString("external.statusLine", ExternalStatusService.getLastStatusLine());
bundle.putLong("external.timeStamp", ExternalStatusService.getLastStatusLineTime());
}
return bundle;
}
}