public static String getString(String key) { if (key == null) { UserError.Log.e(JAMORHAM_LANGUAGE, "getString key is null!"); return ""; } return xdrip.getAppContext() .getSharedPreferences(JAMORHAM_LANGUAGE+"-"+ Locale.getDefault().toString(), Context.MODE_PRIVATE) .getString(key, ""); }
private static byte[] getCryptKey() { final String transmitterId = getTransmitterID(); if (transmitterId.length() != 6) UserError.Log.e(TAG, "cryptKey: Wrong transmitter id length!: " + transmitterId.length()); try { final String padding = "00"; return (padding + transmitterId + padding + transmitterId).getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { UserError.Log.wtf(TAG, "System encoding problem: " + e); } return null; }
private static void threadSleep(int ms) { try { Thread.sleep(ms); } catch (Exception e) { UserError.Log.e(TAG, "Failed to sleep for " + ms + " due to: " + e); } }
@Override protected void onPause() { try { LocalBroadcastManager.getInstance(xdrip.getAppContext()).unregisterReceiver(mRegistrationBroadcastReceiver); } catch (Exception e) { Log.e(TAG, "Exception onPause: ", e); } super.onPause(); }
public static void delete_by_timestamp(long timestamp, int accuracy, boolean from_interactive) { final Treatments t = byTimestamp(timestamp, accuracy); // do we need to alter default accuracy? if (t != null) { Log.d(TAG, "Deleting treatment closest to: " + JoH.dateTimeText(timestamp) + " matches uuid: " + t.uuid); delete_by_uuid(t.uuid, from_interactive); } else { Log.e(TAG, "Couldn't find a treatment near enough to " + JoH.dateTimeText(timestamp) + " to delete!"); } }
public static void UpdateBgVal(long timestamp, double calculated_value) { LibreBlock libreBlock = getForTimestamp(timestamp); if (libreBlock == null) { return; } Log.e(TAG, "Updating bg for timestamp " + timestamp); libreBlock.calculated_bg = calculated_value; libreBlock.save(); }
public static boolean setStoredFirmwareBytes(String transmitterId, byte[] data, boolean from_bluetooth) { if (from_bluetooth) UserError.Log.e(TAG, "Store: VersionRX dbg: " + JoH.bytesToHex(data)); if (transmitterId.length() != 6) return false; if (data.length < 10) return false; if (JoH.ratelimit("store-firmware-bytes", 60)) { PersistentStore.setBytes(G5_FIRMWARE_MARKER + transmitterId, data); } return true; }
public static void setLastEnd(final long when) { if (when > getLastEnd()) { PersistentStore.setLong(LAST_UPLOAD_END_PREF, when); UserError.Log.d(TAG, "Updating last end to: " + dateTimeText(when)); } else { UserError.Log.e(TAG, "Cannot set last end to: " + dateTimeText(when) + " vs " + dateTimeText(getLastEnd())); } }
private static void setSummary_static(AllPrefsFragment allPrefsFragment, String pref_name) { try { // is there a cleaner way to bind these values when setting programatically? final String pref_val = allPrefsFragment.prefs.getString(pref_name, ""); allPrefsFragment.findPreference(pref_name).setSummary(pref_val); EditTextPreference thispref = (EditTextPreference) allPrefsFragment.findPreference(pref_name); thispref.setText(pref_val); } catch (Exception e) { Log.e(TAG, "Exception during setSummary: " + e.toString()); } }
private static void bindPreferenceTitleAppendToValueUpdateChannel(Preference preference) { try { preference.setOnPreferenceChangeListener(sBindPreferenceTitleAppendToValueListenerUpdateChannel); sBindPreferenceTitleAppendToValueListenerUpdateChannel.onPreferenceChange(preference, PreferenceManager .getDefaultSharedPreferences(preference.getContext()) .getString(preference.getKey(), "")); } catch (Exception e) { Log.e(TAG, "Got exception binding preference title: " + e.toString()); } }
private void pushSearch(String query, boolean submit) { if (searchItem != null && searchView != null) { searchItem.expandActionView(); searchView.setQuery(query, submit); searchView.clearFocus(); } else { UserError.Log.e(TAG, "SearchView is null!"); } }
public synchronized static void Seen(String item_json) { try { UserError.Log.d(TAG, "Processing Seen: " + item_json); Seen(fromJson(item_json)); } catch (Exception e) { UserError.Log.e(TAG, "Got exception processing Seen() " + e); } }
@Override public void onDestroy() { if (transporter != null) { transporter.disconnectTransportService(); } UserError.Log.e("Amazfitservice", "killing service "); super.onDestroy(); }
public static int getNoiseBlockLevel() { int value = 200; try { value = Integer.parseInt(Pref.getString("noise_block_level", "200")); } catch (NumberFormatException e) { UserError.Log.e(TAG, "Cannot process noise block level: " + e); } return value; }
public static BackFillTxMessage get(String id, long startTime, long endTime) { final int dexStart = getDexTime(id, startTime); final int dexEnd = getDexTime(id, endTime); if (dexStart < 1 || dexEnd < 1) { UserError.Log.e(TAG, "Unable to calculate start or end time for BackFillTxMessage"); return null; } return new BackFillTxMessage(dexStart, dexEnd); }
public static LibreBlock findByUuid(String uuid) { try { return new Select() .from(LibreBlock.class) .where("uuid = ?", uuid) .executeSingle(); } catch (Exception e) { Log.e(TAG,"findByUuid() Got exception on Select : "+e.toString()); return null; } }
public static byte[] getBytes() { if (isFindable()) { UserError.Log.d(TAG, "Outer apk found - extracting"); final String path = findOuterApkPath(); return path != null ? extractFromApk(new File(path)) : null; } else { UserError.Log.e(TAG, "Cannot find file"); return null; } }
private void onDiscoverFailed(Throwable throwable) { UserError.Log.e(TAG, "Discover failure: " + throwable.toString()); incrementErrors(); prepareToWakeup(); }
private synchronized void send_reset_command() { hardResetTransmitterNow = false; getBatteryStatusNow = true; if (JoH.ratelimit("reset-command", 1200)) { UserError.Log.e(TAG, "Issuing reset command!"); changeState(STATE.RESET); } else { UserError.Log.e(TAG, "Reset command blocked by 20 minute timer"); } }