Skip to content

Commit

Permalink
WalletApplication: Use SystemClock.elapsedRealtime() to detect reboot
Browse files Browse the repository at this point in the history
This will replace using BootstrapReceiver which comes with a delay in
receiving the reboot notice.
  • Loading branch information
HashEngineering committed Aug 4, 2019
1 parent 2ae945b commit deb3654
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 4 additions & 7 deletions wallet/src/de/schildbach/wallet/WalletApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import android.net.Uri;
import android.os.Build;
import android.os.StrictMode;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.support.annotation.StringRes;
import android.support.multidex.MultiDexApplication;
Expand Down Expand Up @@ -632,7 +633,9 @@ else if (lastUsedAgo < Constants.LAST_USAGE_THRESHOLD_RECENTLY_MS)

public void lockWalletIfNeeded() {
WalletLock walletLock = WalletLock.getInstance();
if (walletLock.isWalletLocked(wallet)) {
boolean recentReboot = SystemClock.elapsedRealtime() < WalletLock.DEFAULT_LOCK_TIMER_MILLIS &&
config.getLastUnlockTime() < (System.currentTimeMillis() - SystemClock.elapsedRealtime());
if (walletLock.isWalletLocked(wallet) || recentReboot) {
walletLock.setWalletLocked(true);
}
}
Expand Down Expand Up @@ -675,10 +678,4 @@ public void killAllActivities() {
AbstractWalletActivity.finishAll(this);
}

public static void resetWalletLockTimer(final Context context) {
final Configuration config = new Configuration(PreferenceManager.getDefaultSharedPreferences(context),
context.getResources());
config.setLastUnlockTime(0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public void onReceive(final Context context, final Intent intent) {
if (config.remindBalance() && config.hasBeenUsed()
&& config.getLastUsedAgo() > Constants.LAST_USAGE_THRESHOLD_INACTIVE_MS)
InactivityNotificationService.startMaybeShowNotification(context);

WalletApplication.resetWalletLockTimer(context);
}
}
}

0 comments on commit deb3654

Please sign in to comment.