正在查看: xDrip+ v04633772025.07.16 应用的 InfoContentProvider.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: xDrip+ v04633772025.07.16 应用的 InfoContentProvider.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.eveningoutpost.dexdrip.receiver;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Looper;
import android.util.Log;
import com.eveningoutpost.dexdrip.BestGlucose;
import com.eveningoutpost.dexdrip.eassist.EmergencyAssist;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.utilitymodels.AlertPlayer;
import com.eveningoutpost.dexdrip.utilitymodels.BgGraphBuilder;
import com.eveningoutpost.dexdrip.utilitymodels.BgSparklineBuilder;
import com.eveningoutpost.dexdrip.utilitymodels.CollectionServiceStarter;
import com.eveningoutpost.dexdrip.utilitymodels.ColorCache;
import com.eveningoutpost.dexdrip.utilitymodels.NanoStatus;
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
import com.eveningoutpost.dexdrip.utils.BlobCache;
import com.eveningoutpost.dexdrip.watch.thinjam.BlueJayEntry;
import com.eveningoutpost.dexdrip.xdrip;
import java.io.ByteArrayOutputStream;
public class InfoContentProvider extends ContentProvider {
private static final BlobCache dgCache = new BlobCache(60000);
private static final BlobCache graphCache = new BlobCache(60000);
private int boolInt(boolean z) {
return z ? 1 : 0;
}
@Override
public int delete(Uri uri, String str, String[] strArr) {
return 0;
}
@Override
public String getType(Uri uri) {
return null;
}
@Override
public int update(Uri uri, ContentValues contentValues, String str, String[] strArr) {
return 0;
}
public InfoContentProvider() {
xdrip.setContext(getContext());
}
@Override
public boolean onCreate() {
xdrip.setContext(getContext());
return enabled();
}
@Override
public Cursor query(Uri uri, String[] strArr, String str, String[] strArr2, String str2) {
char c;
char c2;
if (!enabled() || str == null) {
return null;
}
try {
switch (str.hashCode()) {
case -1964645618:
if (str.equals("eassist")) {
c = 2;
break;
}
c = 65535;
break;
case -1415196606:
if (str.equals("alarms")) {
c = 1;
break;
}
c = 65535;
break;
case -1354792126:
if (str.equals("config")) {
c = '\t';
break;
}
c = 65535;
break;
case -937613073:
if (str.equals("status-line")) {
c = 4;
break;
}
c = 65535;
break;
case 3141:
if (str.equals("bg")) {
c = 3;
break;
}
c = 65535;
break;
case 3237038:
if (str.equals("info")) {
c = 6;
break;
}
c = 65535;
break;
case 3441010:
if (str.equals("ping")) {
c = 0;
break;
}
c = 65535;
break;
case 98615630:
if (str.equals("graph")) {
c = '\b';
break;
}
c = 65535;
break;
case 890604511:
if (str.equals("iob-info")) {
c = 7;
break;
}
c = 65535;
break;
case 1634274603:
if (str.equals("nano-status")) {
c = 5;
break;
}
c = 65535;
break;
default:
c = 65535;
break;
}
if (c == 0) {
return matrixRow("version", "0463377-2025.07.16", "versioncode", 2125071614);
}
if (c == 1) {
if (strArr2.length <= 0 || !strArr2[0].equals("snooze")) {
return null;
}
AlertPlayer.getPlayer().OpportunisticSnooze();
Log.d("jamorham-content", "Opportunistic snooze");
return null;
}
if (c == 2) {
if (!enabledWrite()) {
return null;
}
EmergencyAssist.test(EmergencyAssist.Reason.REQUESTED_ASSISTANCE, 60000L);
UserError.Log.ueh("jamorham-content", "Emergency assist triggered remotely");
return null;
}
if (c == 3) {
BlobCache blobCache = dgCache;
BestGlucose.DisplayGlucose displayGlucose = (BestGlucose.DisplayGlucose) blobCache.get();
if (displayGlucose == null) {
displayGlucose = BestGlucose.getDisplayGlucose();
blobCache.set(displayGlucose);
}
if (displayGlucose == null) {
return null;
}
int col = ColorCache.getCol(ColorCache.X.color_inrange_bg_values);
if (displayGlucose.isHigh()) {
col = ColorCache.getCol(ColorCache.X.color_high_bg_values);
} else if (displayGlucose.isLow()) {
col = ColorCache.getCol(ColorCache.X.color_low_bg_values);
}
return matrixRow("timestamp", Long.valueOf(displayGlucose.timestamp), "mgdl", Double.valueOf(displayGlucose.mgdl), "delta_mgdl", Double.valueOf(displayGlucose.delta_mgdl), "delta_arrow", displayGlucose.delta_arrow, "delta_name", displayGlucose.delta_name, "mssince", Long.valueOf(displayGlucose.mssince), "unitized", displayGlucose.unitized, "unitized_delta", displayGlucose.unitized_delta, "unitized_delta_no_units", displayGlucose.unitized_delta_no_units, "chint", Integer.valueOf(col), "humansummary", displayGlucose.humanSummary(), "ishigh", Integer.valueOf(boolInt(displayGlucose.isHigh())), "islow", Integer.valueOf(boolInt(displayGlucose.isLow())), "isstale", Integer.valueOf(boolInt(displayGlucose.isStale())), "isreallystale", Integer.valueOf(boolInt(displayGlucose.isReallyStale())));
}
if (c == 5) {
return matrixRow("collector", NanoStatus.nanoStatus("collector"), "sensor-expiry", NanoStatus.nanoStatus("sensor-expiry"), "s-expiry", NanoStatus.nanoStatus("s-expiry"));
}
if (c == 6) {
return matrixRow("last_ueh", UserError.newestBySeverity(6));
}
if (c == '\b') {
if (Looper.myLooper() == null) {
Looper.prepare();
}
int min = Math.min(1000, Integer.parseInt(strArr2[0]));
int min2 = Math.min(1000, Integer.parseInt(strArr2[1]));
BlobCache blobCache2 = graphCache;
long j = min;
long j2 = min2;
byte[] bArr = (byte[]) blobCache2.get(j, j2);
if (bArr == null) {
if (strArr2.length >= 3) {
String str3 = strArr2[2];
}
Bitmap build = new BgSparklineBuilder(xdrip.getAppContext()).setBgGraphBuilder(new BgGraphBuilder(xdrip.getAppContext())).setHeight(min2).setDotSize(5).setWidth(min).showHighLine(true).showLowLine(true).build();
bArr = convertBitmapToPNGByteArray(build);
build.recycle();
blobCache2.set(bArr, j, j2);
}
MatrixCursor matrixCursor = new MatrixCursor(new String[]{"blob"});
matrixCursor.addRow(new Object[]{bArr});
return matrixCursor;
}
if (c != '\t' || !enabledWrite() || strArr2 == null || strArr == null) {
return null;
}
try {
if (strArr2.length != strArr.length) {
return null;
}
for (int i = 0; i < strArr.length; i++) {
String str4 = strArr[i];
switch (str2.hashCode()) {
case -1850743644:
if (str2.equals("Remove")) {
c2 = '\b';
break;
}
c2 = 65535;
break;
case -1808118735:
if (str2.equals("String")) {
c2 = 0;
break;
}
c2 = 65535;
break;
case -1642061176:
if (str2.equals("NewBoolean")) {
c2 = 7;
break;
}
c2 = 65535;
break;
case -785339364:
if (str2.equals("NewLong")) {
c2 = 6;
break;
}
c2 = 65535;
break;
case -672261858:
if (str2.equals("Integer")) {
c2 = 1;
break;
}
c2 = 65535;
break;
case 2374300:
if (str2.equals("Long")) {
c2 = 2;
break;
}
c2 = 65535;
break;
case 251279262:
if (str2.equals("NewInteger")) {
c2 = 5;
break;
}
c2 = 65535;
break;
case 1408261553:
if (str2.equals("NewString")) {
c2 = 4;
break;
}
c2 = 65535;
break;
case 1729365000:
if (str2.equals("Boolean")) {
c2 = 3;
break;
}
c2 = 65535;
break;
default:
c2 = 65535;
break;
}
switch (c2) {
case 0:
Pref.setString(str4, strArr2[i]);
break;
case 1:
Pref.setInt(str4, Integer.parseInt(strArr2[i]));
break;
case 2:
Pref.setLong(str4, Long.parseLong(strArr2[i]));
break;
case 3:
Pref.setBoolean(str4, Boolean.parseBoolean(strArr2[i]));
break;
case 4:
if (Pref.getString(str4, "defaultvalue").equals("defaultvalue")) {
Pref.setString(str4, strArr2[i]);
break;
} else {
break;
}
case 5:
if (Pref.getInt(str4, -1000) == -1000) {
Pref.setInt(str4, Integer.parseInt(strArr2[i]));
break;
} else {
break;
}
case 6:
if (Pref.getLong(str4, -1000L) == -1000) {
Pref.setLong(str4, Long.parseLong(strArr2[i]));
break;
} else {
break;
}
case 7:
if (Pref.isPreferenceSet(str4)) {
Pref.setBoolean(str4, Boolean.parseBoolean(strArr2[i]));
break;
} else {
break;
}
case '\b':
Pref.removeItem(str4);
break;
}
}
CollectionServiceStarter.restartCollectionServiceBackground();
return matrixRow("processed", Integer.valueOf(strArr.length));
} catch (Exception e) {
UserError.Log.e("jamorham-content", "config error: " + e);
return null;
}
} catch (Exception e2) {
Log.d("jamorham-content", "Got exception: " + e2);
e2.printStackTrace();
return null;
}
}
private static MatrixCursor matrixRow(Object... objArr) {
String[] strArr = new String[objArr.length / 2];
Object[] objArr2 = new Object[objArr.length / 2];
for (int i = 0; i < objArr.length; i += 2) {
int i2 = i / 2;
strArr[i2] = (String) objArr[i];
objArr2[i2] = objArr[i + 1];
}
try {
MatrixCursor matrixCursor = new MatrixCursor(strArr);
try {
matrixCursor.addRow(objArr2);
matrixCursor.close();
return matrixCursor;
} finally {
}
} catch (Exception e) {
Log.d("jamorham-content", "Error with cursor: " + e);
return null;
}
}
@Override
public Uri insert(Uri uri, ContentValues contentValues) {
if (!enabled()) {
return null;
}
try {
getContext().getContentResolver().notifyChange(uri, null);
} catch (Exception e) {
Log.e("jamorham-content", "Got exception during insert " + e);
}
return null;
}
private static boolean enabled() {
return BlueJayEntry.isNative() || (xdrip.getAppContext() != null && Pref.getBooleanDefaultFalse("host_content_provider"));
}
private static boolean enabledWrite() {
return enabled() && (BlueJayEntry.isNative() || Pref.getBooleanDefaultFalse("content_provider_write"));
}
public static void ping(String str) {
if (!enabled() || str == null) {
return;
}
if (str.equals("bg")) {
dgCache.clear();
graphCache.clear();
}
xdrip.getAppContext().getContentResolver().insert(Uri.parse("content://com.eveningoutpost.dexdrip.contentprovider/" + str), null);
}
public static byte[] convertBitmapToPNGByteArray(Bitmap bitmap) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
return byteArrayOutputStream.toByteArray();
}
}