Java源码示例:com.eveningoutpost.dexdrip.UtilityModels.Intents
示例1
public static void testCalibration() {
Bundle bundle = new Bundle();
bundle.putDouble("glucose_number", 5.5d+ (JoH.ts() % 100)/100d); // format is local format, in this example 5.5 mmol/l or specify the units as shown below
bundle.putString("units", "mmol"); // mgdl or mmol
bundle.putLong("timestamp", JoH.tsl()-10000);
Intent intent = new Intent(Intents.ACTION_REMOTE_CALIBRATION);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
xdrip.getAppContext().sendBroadcast(intent);
}
示例2
@Override
protected void onResume()
{
super.onResume();
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(ActivityRecognizedService.prefListener);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && DexCollectionType.hasBluetooth() && !WholeHouse.isRpi()) {
LocationHelper.requestLocationForBluetooth(this); // double check!
}
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(LeFunEntry.prefListener);
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(MiBandEntry.prefListener);
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(BlueJayEntry.prefListener);
LocalBroadcastManager.getInstance(this).registerReceiver(mibandStatusReceiver,
new IntentFilter(Intents.PREFERENCE_INTENT));
}
示例3
public static void sendPrefIntent(MiBandService.MIBAND_INTEND_STATES state, Integer progress, String descrText) {
final Intent progressIntent = new Intent(Intents.PREFERENCE_INTENT);
progressIntent.putExtra("state", state.name());
progressIntent.putExtra("progress", progress);
if (!descrText.isEmpty())
progressIntent.putExtra("descr_text", descrText);
LocalBroadcastManager.getInstance(xdrip.getAppContext()).sendBroadcast(progressIntent);
}
示例4
public static void staticRefreshBGCharts(boolean override) {
reset_viewport = true;
if (activityVisible || override) {
Intent updateIntent = new Intent(Intents.ACTION_NEW_BG_ESTIMATE_NO_DATA);
mActivity.sendBroadcast(updateIntent);
}
}
示例5
public static void testCalibration() {
Bundle bundle = new Bundle();
bundle.putDouble("glucose_number", 5.5d+ (JoH.ts() % 100)/100d); // format is local format, in this example 5.5 mmol/l or specify the units as shown below
bundle.putString("units", "mmol"); // mgdl or mmol
bundle.putLong("timestamp", JoH.tsl()-10000);
Intent intent = new Intent(Intents.ACTION_REMOTE_CALIBRATION);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
xdrip.getAppContext().sendBroadcast(intent);
}
示例6
@Override
protected void onResume()
{
super.onResume();
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(ActivityRecognizedService.prefListener);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && DexCollectionType.hasBluetooth() && !WholeHouse.isRpi()) {
LocationHelper.requestLocationForBluetooth(this); // double check!
}
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(LeFunEntry.prefListener);
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(MiBandEntry.prefListener);
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(BlueJayEntry.prefListener);
LocalBroadcastManager.getInstance(this).registerReceiver(mibandStatusReceiver,
new IntentFilter(Intents.PREFERENCE_INTENT));
}
示例7
public static void sendPrefIntent(MiBandService.MIBAND_INTEND_STATES state, Integer progress, String descrText) {
final Intent progressIntent = new Intent(Intents.PREFERENCE_INTENT);
progressIntent.putExtra("state", state.name());
progressIntent.putExtra("progress", progress);
if (!descrText.isEmpty())
progressIntent.putExtra("descr_text", descrText);
LocalBroadcastManager.getInstance(xdrip.getAppContext()).sendBroadcast(progressIntent);
}
示例8
public static void staticRefreshBGCharts(boolean override) {
reset_viewport = true;
if (activityVisible || override) {
Intent updateIntent = new Intent(Intents.ACTION_NEW_BG_ESTIMATE_NO_DATA);
mActivity.sendBroadcast(updateIntent);
}
}
示例9
static public void SendData(byte[] fullData, long timestamp, byte []patchUid, byte []patchInfo) {
if(fullData == null) {
Log.e(TAG, "SendData called with null data");
return;
}
if(fullData.length < 344) {
Log.e(TAG, "SendData called with data size too small. " + fullData.length);
return;
}
Log.i(TAG, "Sending full data to OOP Algorithm data-len = " + fullData.length);
fullData = java.util.Arrays.copyOfRange(fullData, 0, 0x158);
Log.i(TAG, "Data that will be sent is " + HexDump.dumpHexString(fullData));
Intent intent = new Intent(Intents.XDRIP_PLUS_LIBRE_DATA);
Bundle bundle = new Bundle();
bundle.putByteArray(Intents.LIBRE_DATA_BUFFER, fullData);
bundle.putLong(Intents.LIBRE_DATA_TIMESTAMP, timestamp);
bundle.putString(Intents.LIBRE_SN, PersistentStore.getString("LibreSN"));
if(patchUid != null) {
bundle.putByteArray(Intents.LIBRE_PATCH_UID_BUFFER, patchUid);
}
if(patchInfo != null) {
bundle.putByteArray(Intents.LIBRE_PATCH_INFO_BUFFER, patchInfo);
}
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
final String packages = PersistentStore.getString(CompatibleApps.EXTERNAL_ALG_PACKAGES);
if (packages.length() > 0) {
final String[] packagesE = packages.split(",");
for (final String destination : packagesE) {
if (destination.length() > 3) {
intent.setPackage(destination);
Log.d(TAG, "Sending to package: " + destination);
xdrip.getAppContext().sendBroadcast(intent);
}
}
} else {
Log.d(TAG, "Sending to generic package");
xdrip.getAppContext().sendBroadcast(intent);
}
}
示例10
@Override
public void onReceive(final Context context, final Intent intent) {
new Thread() {
@Override
public void run() {
final PowerManager.WakeLock wl = JoH.getWakeLock("librealarm-receiver", 60000);
synchronized (lock) {
try {
Log.d(TAG, "LibreReceiver onReceiver: " + intent.getAction());
JoH.benchmark(null);
// check source
if (prefs == null)
prefs = PreferenceManager.getDefaultSharedPreferences(context);
final Bundle bundle = intent.getExtras();
// BundleScrubber.scrub(bundle);
final String action = intent.getAction();
if ((bundle != null) && (debug)) {
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
if (value != null) {
Log.d(TAG, String.format("%s %s (%s)", key,
value.toString(), value.getClass().getName()));
}
}
}
switch (action) {
case Intents.LIBRE_ALARM_TO_XDRIP_PLUS:
// If we are not currently in a mode supporting libre then switch
if (!DexCollectionType.hasLibre()) {
DexCollectionType.setDexCollectionType(DexCollectionType.LibreAlarm);
}
if (bundle == null) break;
Log.d(TAG, "Receiving LIBRE_ALARM broadcast");
oldest_cmp = oldest;
newest_cmp = newest;
Log.d(TAG, "At Start: Oldest : " + JoH.dateTimeText(oldest_cmp) + " Newest : " + JoH.dateTimeText(newest_cmp));
final String data = bundle.getString("data");
final int bridge_battery = bundle.getInt("bridge_battery");
if (bridge_battery > 0) {
Pref.setInt("bridge_battery", bridge_battery);
CheckBridgeBattery.checkBridgeBattery();
}
try {
final ReadingData.TransferObject object =
new Gson().fromJson(data, ReadingData.TransferObject.class);
object.data.CalculateSmothedData();
processReadingDataTransferObject(object, JoH.tsl(), "LibreAlarm", false, null, null);
Log.d(TAG, "At End: Oldest : " + JoH.dateTimeText(oldest_cmp) + " Newest : " + JoH.dateTimeText(newest_cmp));
} catch (Exception e) {
Log.wtf(TAG, "Could not process data structure from LibreAlarm: " + e.toString());
JoH.static_toast_long(gs(R.string.librealarm_data_format_appears_incompatible_protocol_changed_or_no_data));
}
break;
default:
Log.e(TAG, "Unknown action! " + action);
break;
}
} finally {
JoH.benchmark("LibreReceiver process");
JoH.releaseWakeLock(wl);
}
} // lock
}
}.start();
}
示例11
@Override
public void onReceive(final Context context, final Intent intent) {
if(DexCollectionType.getDexCollectionType() != DexCollectionType.LibreReceiver)
return;
new Thread() {
@Override
public void run() {
PowerManager.WakeLock wl = JoH.getWakeLock("libre-receiver", 60000);
synchronized (lock) {
try {
Log.d(TAG, "libre onReceiver: " + intent.getAction());
JoH.benchmark(null);
// check source
if (prefs == null)
prefs = PreferenceManager.getDefaultSharedPreferences(context);
final Bundle bundle = intent.getExtras();
// BundleScrubber.scrub(bundle);
final String action = intent.getAction();
if (action == null) return;
switch (action) {
case Intents.LIBRE2_ACTIVATION:
Log.v(TAG, "Receiving LibreData activation");
try {
saveSensorStartTime(intent.getBundleExtra("sensor"), intent.getBundleExtra("bleManager").getString("sensorSerial"));
} catch (NullPointerException e) {
Log.e(TAG, "Null pointer in LIBRE2_ACTIVATION: " + e);
}
break;
case Intents.LIBRE2_BG:
Libre2RawValue currentRawValue = processIntent(intent);
if (currentRawValue == null) return;
Log.v(TAG,"got bg reading: from sensor:"+currentRawValue.serial+" rawValue:"+currentRawValue.glucose+" at:"+currentRawValue.timestamp);
// period of 4.5 minutes to collect 5 readings
if(!BgReading.last_within_millis(45 * 6 * 1000 )) {
List<Libre2RawValue> smoothingValues = Libre2RawValue.last20Minutes();
smoothingValues.add(currentRawValue);
processValues(currentRawValue, smoothingValues, context);
}
currentRawValue.save();
break;
default:
Log.e(TAG, "Unknown action! " + action);
break;
}
} finally {
JoH.benchmark("NSEmulator process");
JoH.releaseWakeLock(wl);
}
} // lock
}
}.start();
}
示例12
static public void SendData(byte[] fullData, long timestamp, byte []patchUid, byte []patchInfo) {
if(fullData == null) {
Log.e(TAG, "SendData called with null data");
return;
}
if(fullData.length < 344) {
Log.e(TAG, "SendData called with data size too small. " + fullData.length);
return;
}
Log.i(TAG, "Sending full data to OOP Algorithm data-len = " + fullData.length);
fullData = java.util.Arrays.copyOfRange(fullData, 0, 0x158);
Log.i(TAG, "Data that will be sent is " + HexDump.dumpHexString(fullData));
Intent intent = new Intent(Intents.XDRIP_PLUS_LIBRE_DATA);
Bundle bundle = new Bundle();
bundle.putByteArray(Intents.LIBRE_DATA_BUFFER, fullData);
bundle.putLong(Intents.LIBRE_DATA_TIMESTAMP, timestamp);
bundle.putString(Intents.LIBRE_SN, PersistentStore.getString("LibreSN"));
bundle.putInt(Intents.LIBRE_RAW_ID, android.os.Process.myPid());
if(patchUid != null) {
bundle.putByteArray(Intents.LIBRE_PATCH_UID_BUFFER, patchUid);
}
if(patchInfo != null) {
bundle.putByteArray(Intents.LIBRE_PATCH_INFO_BUFFER, patchInfo);
}
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
final String packages = PersistentStore.getString(CompatibleApps.EXTERNAL_ALG_PACKAGES);
if (packages.length() > 0) {
final String[] packagesE = packages.split(",");
for (final String destination : packagesE) {
if (destination.length() > 3) {
intent.setPackage(destination);
Log.d(TAG, "Sending to package: " + destination);
xdrip.getAppContext().sendBroadcast(intent);
}
}
} else {
Log.d(TAG, "Sending to generic package");
xdrip.getAppContext().sendBroadcast(intent);
}
}
示例13
@Override
public void onReceive(final Context context, final Intent intent) {
new Thread() {
@Override
public void run() {
final PowerManager.WakeLock wl = JoH.getWakeLock("librealarm-receiver", 60000);
synchronized (lock) {
try {
Log.d(TAG, "LibreReceiver onReceiver: " + intent.getAction());
JoH.benchmark(null);
// check source
if (prefs == null)
prefs = PreferenceManager.getDefaultSharedPreferences(context);
final Bundle bundle = intent.getExtras();
// BundleScrubber.scrub(bundle);
final String action = intent.getAction();
if ((bundle != null) && (debug)) {
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
if (value != null) {
Log.d(TAG, String.format("%s %s (%s)", key,
value.toString(), value.getClass().getName()));
}
}
}
switch (action) {
case Intents.LIBRE_ALARM_TO_XDRIP_PLUS:
// If we are not currently in a mode supporting libre then switch
if (!DexCollectionType.hasLibre()) {
DexCollectionType.setDexCollectionType(DexCollectionType.LibreAlarm);
}
if (bundle == null) break;
Log.d(TAG, "Receiving LIBRE_ALARM broadcast");
oldest_cmp = oldest;
newest_cmp = newest;
Log.d(TAG, "At Start: Oldest : " + JoH.dateTimeText(oldest_cmp) + " Newest : " + JoH.dateTimeText(newest_cmp));
final String data = bundle.getString("data");
final int bridge_battery = bundle.getInt("bridge_battery");
if (bridge_battery > 0) {
Pref.setInt("bridge_battery", bridge_battery);
CheckBridgeBattery.checkBridgeBattery();
}
try {
final ReadingData.TransferObject object =
new Gson().fromJson(data, ReadingData.TransferObject.class);
object.data.CalculateSmothedData();
processReadingDataTransferObject(object, JoH.tsl(), "LibreAlarm", false, null, null);
Log.d(TAG, "At End: Oldest : " + JoH.dateTimeText(oldest_cmp) + " Newest : " + JoH.dateTimeText(newest_cmp));
} catch (Exception e) {
Log.wtf(TAG, "Could not process data structure from LibreAlarm: " + e.toString());
JoH.static_toast_long(gs(R.string.librealarm_data_format_appears_incompatible_protocol_changed_or_no_data));
}
break;
default:
Log.e(TAG, "Unknown action! " + action);
break;
}
} finally {
JoH.benchmark("LibreReceiver process");
JoH.releaseWakeLock(wl);
}
} // lock
}
}.start();
}
示例14
private static Intent getAPIintent() {
return new Intent(Intents.BLUEJAY_THINJAM_EMIT);
}
示例15
private static Intent getAPIintent() {
return new Intent(Intents.BLUEJAY_THINJAM_API);
}
示例16
public static void updateStatusLine(String key, String value) {
final Intent homeStatus = new Intent(Intents.HOME_STATUS_ACTION);
homeStatus.putExtra(key, value);
LocalBroadcastManager.getInstance(xdrip.getAppContext()).sendBroadcast(homeStatus);
Log.d(TAG, "Home Status update: " + key + " / " + value);
}
示例17
static public void SendData(byte[] fullData, long timestamp, byte []patchUid, byte []patchInfo) {
if(fullData == null) {
Log.e(TAG, "SendData called with null data");
return;
}
if(fullData.length < 344) {
Log.e(TAG, "SendData called with data size too small. " + fullData.length);
return;
}
Log.i(TAG, "Sending full data to OOP Algorithm data-len = " + fullData.length);
fullData = java.util.Arrays.copyOfRange(fullData, 0, 0x158);
Log.i(TAG, "Data that will be sent is " + HexDump.dumpHexString(fullData));
Intent intent = new Intent(Intents.XDRIP_PLUS_LIBRE_DATA);
Bundle bundle = new Bundle();
bundle.putByteArray(Intents.LIBRE_DATA_BUFFER, fullData);
bundle.putLong(Intents.LIBRE_DATA_TIMESTAMP, timestamp);
bundle.putString(Intents.LIBRE_SN, PersistentStore.getString("LibreSN"));
if(patchUid != null) {
bundle.putByteArray(Intents.LIBRE_PATCH_UID_BUFFER, patchUid);
}
if(patchInfo != null) {
bundle.putByteArray(Intents.LIBRE_PATCH_INFO_BUFFER, patchInfo);
}
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
final String packages = PersistentStore.getString(CompatibleApps.EXTERNAL_ALG_PACKAGES);
if (packages.length() > 0) {
final String[] packagesE = packages.split(",");
for (final String destination : packagesE) {
if (destination.length() > 3) {
intent.setPackage(destination);
Log.d(TAG, "Sending to package: " + destination);
xdrip.getAppContext().sendBroadcast(intent);
}
}
} else {
Log.d(TAG, "Sending to generic package");
xdrip.getAppContext().sendBroadcast(intent);
}
}
示例18
@Override
public void onReceive(final Context context, final Intent intent) {
new Thread() {
@Override
public void run() {
final PowerManager.WakeLock wl = JoH.getWakeLock("librealarm-receiver", 60000);
synchronized (lock) {
try {
Log.d(TAG, "LibreReceiver onReceiver: " + intent.getAction());
JoH.benchmark(null);
// check source
if (prefs == null)
prefs = PreferenceManager.getDefaultSharedPreferences(context);
final Bundle bundle = intent.getExtras();
// BundleScrubber.scrub(bundle);
final String action = intent.getAction();
if ((bundle != null) && (debug)) {
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
if (value != null) {
Log.d(TAG, String.format("%s %s (%s)", key,
value.toString(), value.getClass().getName()));
}
}
}
switch (action) {
case Intents.LIBRE_ALARM_TO_XDRIP_PLUS:
// If we are not currently in a mode supporting libre then switch
if (!DexCollectionType.hasLibre()) {
DexCollectionType.setDexCollectionType(DexCollectionType.LibreAlarm);
}
if (bundle == null) break;
Log.d(TAG, "Receiving LIBRE_ALARM broadcast");
oldest_cmp = oldest;
newest_cmp = newest;
Log.d(TAG, "At Start: Oldest : " + JoH.dateTimeText(oldest_cmp) + " Newest : " + JoH.dateTimeText(newest_cmp));
final String data = bundle.getString("data");
final int bridge_battery = bundle.getInt("bridge_battery");
if (bridge_battery > 0) {
Pref.setInt("bridge_battery", bridge_battery);
CheckBridgeBattery.checkBridgeBattery();
}
try {
final ReadingData.TransferObject object =
new Gson().fromJson(data, ReadingData.TransferObject.class);
object.data.CalculateSmothedData();
processReadingDataTransferObject(object, JoH.tsl(), "LibreAlarm", false, null, null);
Log.d(TAG, "At End: Oldest : " + JoH.dateTimeText(oldest_cmp) + " Newest : " + JoH.dateTimeText(newest_cmp));
} catch (Exception e) {
Log.wtf(TAG, "Could not process data structure from LibreAlarm: " + e.toString());
JoH.static_toast_long(gs(R.string.librealarm_data_format_appears_incompatible_protocol_changed_or_no_data));
}
break;
default:
Log.e(TAG, "Unknown action! " + action);
break;
}
} finally {
JoH.benchmark("LibreReceiver process");
JoH.releaseWakeLock(wl);
}
} // lock
}
}.start();
}
示例19
@Override
public void onReceive(final Context context, final Intent intent) {
if(DexCollectionType.getDexCollectionType() != DexCollectionType.LibreReceiver)
return;
new Thread() {
@Override
public void run() {
PowerManager.WakeLock wl = JoH.getWakeLock("libre-receiver", 60000);
synchronized (lock) {
try {
Log.d(TAG, "libre onReceiver: " + intent.getAction());
JoH.benchmark(null);
// check source
if (prefs == null)
prefs = PreferenceManager.getDefaultSharedPreferences(context);
final Bundle bundle = intent.getExtras();
// BundleScrubber.scrub(bundle);
final String action = intent.getAction();
if (action == null) return;
switch (action) {
case Intents.LIBRE2_ACTIVATION:
Log.v(TAG, "Receiving LibreData activation");
try {
saveSensorStartTime(intent.getBundleExtra("sensor"), intent.getBundleExtra("bleManager").getString("sensorSerial"));
} catch (NullPointerException e) {
Log.e(TAG, "Null pointer in LIBRE2_ACTIVATION: " + e);
}
break;
case Intents.LIBRE2_BG:
Libre2RawValue currentRawValue = processIntent(intent);
if (currentRawValue == null) return;
Log.v(TAG,"got bg reading: from sensor:"+currentRawValue.serial+" rawValue:"+currentRawValue.glucose+" at:"+currentRawValue.timestamp);
// period of 4.5 minutes to collect 5 readings
if(!BgReading.last_within_millis(45 * 6 * 1000 )) {
List<Libre2RawValue> smoothingValues = Libre2RawValue.last20Minutes();
smoothingValues.add(currentRawValue);
processValues(currentRawValue, smoothingValues, context);
}
currentRawValue.save();
break;
default:
Log.e(TAG, "Unknown action! " + action);
break;
}
} finally {
JoH.benchmark("NSEmulator process");
JoH.releaseWakeLock(wl);
}
} // lock
}
}.start();
}
示例20
static public void SendData(byte[] fullData, long timestamp, byte []patchUid, byte []patchInfo) {
if(fullData == null) {
Log.e(TAG, "SendData called with null data");
return;
}
if(fullData.length < 344) {
Log.e(TAG, "SendData called with data size too small. " + fullData.length);
return;
}
Log.i(TAG, "Sending full data to OOP Algorithm data-len = " + fullData.length);
fullData = java.util.Arrays.copyOfRange(fullData, 0, 0x158);
Log.i(TAG, "Data that will be sent is " + HexDump.dumpHexString(fullData));
Intent intent = new Intent(Intents.XDRIP_PLUS_LIBRE_DATA);
Bundle bundle = new Bundle();
bundle.putByteArray(Intents.LIBRE_DATA_BUFFER, fullData);
bundle.putLong(Intents.LIBRE_DATA_TIMESTAMP, timestamp);
bundle.putString(Intents.LIBRE_SN, PersistentStore.getString("LibreSN"));
bundle.putInt(Intents.LIBRE_RAW_ID, android.os.Process.myPid());
if(patchUid != null) {
bundle.putByteArray(Intents.LIBRE_PATCH_UID_BUFFER, patchUid);
}
if(patchInfo != null) {
bundle.putByteArray(Intents.LIBRE_PATCH_INFO_BUFFER, patchInfo);
}
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
final String packages = PersistentStore.getString(CompatibleApps.EXTERNAL_ALG_PACKAGES);
if (packages.length() > 0) {
final String[] packagesE = packages.split(",");
for (final String destination : packagesE) {
if (destination.length() > 3) {
intent.setPackage(destination);
Log.d(TAG, "Sending to package: " + destination);
xdrip.getAppContext().sendBroadcast(intent);
}
}
} else {
Log.d(TAG, "Sending to generic package");
xdrip.getAppContext().sendBroadcast(intent);
}
}
示例21
@Override
public void onReceive(final Context context, final Intent intent) {
new Thread() {
@Override
public void run() {
final PowerManager.WakeLock wl = JoH.getWakeLock("librealarm-receiver", 60000);
synchronized (lock) {
try {
Log.d(TAG, "LibreReceiver onReceiver: " + intent.getAction());
JoH.benchmark(null);
// check source
if (prefs == null)
prefs = PreferenceManager.getDefaultSharedPreferences(context);
final Bundle bundle = intent.getExtras();
// BundleScrubber.scrub(bundle);
final String action = intent.getAction();
if ((bundle != null) && (debug)) {
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
if (value != null) {
Log.d(TAG, String.format("%s %s (%s)", key,
value.toString(), value.getClass().getName()));
}
}
}
switch (action) {
case Intents.LIBRE_ALARM_TO_XDRIP_PLUS:
// If we are not currently in a mode supporting libre then switch
if (!DexCollectionType.hasLibre()) {
DexCollectionType.setDexCollectionType(DexCollectionType.LibreAlarm);
}
if (bundle == null) break;
Log.d(TAG, "Receiving LIBRE_ALARM broadcast");
oldest_cmp = oldest;
newest_cmp = newest;
Log.d(TAG, "At Start: Oldest : " + JoH.dateTimeText(oldest_cmp) + " Newest : " + JoH.dateTimeText(newest_cmp));
final String data = bundle.getString("data");
final int bridge_battery = bundle.getInt("bridge_battery");
if (bridge_battery > 0) {
Pref.setInt("bridge_battery", bridge_battery);
CheckBridgeBattery.checkBridgeBattery();
}
try {
final ReadingData.TransferObject object =
new Gson().fromJson(data, ReadingData.TransferObject.class);
object.data.CalculateSmothedData();
processReadingDataTransferObject(object, JoH.tsl(), "LibreAlarm", false, null, null);
Log.d(TAG, "At End: Oldest : " + JoH.dateTimeText(oldest_cmp) + " Newest : " + JoH.dateTimeText(newest_cmp));
} catch (Exception e) {
Log.wtf(TAG, "Could not process data structure from LibreAlarm: " + e.toString());
JoH.static_toast_long(gs(R.string.librealarm_data_format_appears_incompatible_protocol_changed_or_no_data));
}
break;
default:
Log.e(TAG, "Unknown action! " + action);
break;
}
} finally {
JoH.benchmark("LibreReceiver process");
JoH.releaseWakeLock(wl);
}
} // lock
}
}.start();
}
示例22
private static Intent getAPIintent() {
return new Intent(Intents.BLUEJAY_THINJAM_EMIT);
}
示例23
private static Intent getAPIintent() {
return new Intent(Intents.BLUEJAY_THINJAM_API);
}
示例24
public static void updateStatusLine(String key, String value) {
final Intent homeStatus = new Intent(Intents.HOME_STATUS_ACTION);
homeStatus.putExtra(key, value);
LocalBroadcastManager.getInstance(xdrip.getAppContext()).sendBroadcast(homeStatus);
Log.d(TAG, "Home Status update: " + key + " / " + value);
}