use of de.schildbach.wallet.Configuration in project bitcoin-wallet by bitcoin-wallet.
the class BootstrapReceiver method onReceive.
@Override
public void onReceive(final Context context, final Intent intent) {
log.info("got broadcast: " + intent);
final WalletApplication application = (WalletApplication) context.getApplicationContext();
final boolean bootCompleted = Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction());
final boolean packageReplaced = Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction());
if (packageReplaced || bootCompleted) {
// make sure wallet is upgraded to HD
if (packageReplaced)
UpgradeWalletService.startUpgrade(context);
// make sure there is always an alarm scheduled
BlockchainService.scheduleStart(application);
// if the app hasn't been used for a while and contains coins, maybe show reminder
final Configuration config = application.getConfiguration();
if (config.remindBalance() && config.hasBeenUsed() && config.getLastUsedAgo() > Constants.LAST_USAGE_THRESHOLD_INACTIVE_MS)
InactivityNotificationService.startMaybeShowNotification(context);
}
}
use of de.schildbach.wallet.Configuration in project bitcoin-wallet by bitcoin-wallet.
the class BlockchainService method scheduleStart.
public static void scheduleStart(final WalletApplication application) {
final Configuration config = application.getConfiguration();
final long lastUsedAgo = config.getLastUsedAgo();
// apply some backoff
final long alarmInterval;
if (lastUsedAgo < Constants.LAST_USAGE_THRESHOLD_JUST_MS)
alarmInterval = AlarmManager.INTERVAL_FIFTEEN_MINUTES;
else if (lastUsedAgo < Constants.LAST_USAGE_THRESHOLD_RECENTLY_MS)
alarmInterval = AlarmManager.INTERVAL_HALF_DAY;
else
alarmInterval = AlarmManager.INTERVAL_DAY;
log.info("last used {} minutes ago, rescheduling blockchain sync in roughly {} minutes", lastUsedAgo / DateUtils.MINUTE_IN_MILLIS, alarmInterval / DateUtils.MINUTE_IN_MILLIS);
final AlarmManager alarmManager = (AlarmManager) application.getSystemService(Context.ALARM_SERVICE);
final PendingIntent alarmIntent = PendingIntent.getService(application, 0, new Intent(application, BlockchainService.class), 0);
alarmManager.cancel(alarmIntent);
// workaround for no inexact set() before KitKat
final long now = System.currentTimeMillis();
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, now + alarmInterval, AlarmManager.INTERVAL_DAY, alarmIntent);
}
use of de.schildbach.wallet.Configuration in project bitcoin-wallet by bitcoin-wallet.
the class ReportIssueDialogFragment method appendApplicationInfo.
private static void appendApplicationInfo(final Appendable report, final WalletApplication application) throws IOException {
final PackageInfo pi = application.packageInfo();
final Configuration configuration = application.getConfiguration();
final Calendar calendar = new GregorianCalendar(UTC);
report.append("Version: " + pi.versionName + " (" + pi.versionCode + ")\n");
report.append("Package: " + pi.packageName + "\n");
report.append("Installer: " + application.getPackageManager().getInstallerPackageName(pi.packageName) + "\n");
report.append("Test/Prod: " + (Constants.TEST ? "test" : "prod") + "\n");
report.append("Timezone: " + TimeZone.getDefault().getID() + "\n");
calendar.setTimeInMillis(System.currentTimeMillis());
report.append("Time: " + String.format(Locale.US, "%tF %tT %tZ", calendar, calendar, calendar) + "\n");
calendar.setTimeInMillis(WalletApplication.TIME_CREATE_APPLICATION);
report.append("Time of launch: " + String.format(Locale.US, "%tF %tT %tZ", calendar, calendar, calendar) + "\n");
calendar.setTimeInMillis(pi.lastUpdateTime);
report.append("Time of last update: " + String.format(Locale.US, "%tF %tT %tZ", calendar, calendar, calendar) + "\n");
calendar.setTimeInMillis(pi.firstInstallTime);
report.append("Time of first install: " + String.format(Locale.US, "%tF %tT %tZ", calendar, calendar, calendar) + "\n");
final long lastBackupTime = configuration.getLastBackupTime();
calendar.setTimeInMillis(lastBackupTime);
report.append("Time of backup: " + (lastBackupTime > 0 ? String.format(Locale.US, "%tF %tT %tZ", calendar, calendar, calendar) : "none") + "\n");
report.append("Network: " + Constants.NETWORK_PARAMETERS.getId() + "\n");
final Wallet wallet = application.getWallet();
report.append("Encrypted: " + wallet.isEncrypted() + "\n");
report.append("Keychain size: " + wallet.getKeyChainGroupSize() + "\n");
final Set<Transaction> transactions = wallet.getTransactions(true);
int numInputs = 0;
int numOutputs = 0;
int numSpentOutputs = 0;
for (final Transaction tx : transactions) {
numInputs += tx.getInputs().size();
final List<TransactionOutput> outputs = tx.getOutputs();
numOutputs += outputs.size();
for (final TransactionOutput txout : outputs) {
if (!txout.isAvailableForSpending())
numSpentOutputs++;
}
}
report.append("Transactions: " + transactions.size() + "\n");
report.append("Inputs: " + numInputs + "\n");
report.append("Outputs: " + numOutputs + " (spent: " + numSpentOutputs + ")\n");
report.append("Last block seen: " + wallet.getLastBlockSeenHeight() + " (" + wallet.getLastBlockSeenHash() + ")\n");
report.append("Databases:");
for (final String db : application.databaseList()) report.append(" " + db);
report.append("\n");
final File filesDir = application.getFilesDir();
report.append("\nContents of FilesDir " + filesDir + ":\n");
appendDir(report, filesDir, 0);
}
Aggregations