Browse Source

Synchronize access to WakeLocker

Resolves #72
merge-requests/7/head
Trevor Slocum 2 years ago
parent
commit
13f42723a0
  1. 3
      CHANGELOG
  2. 26
      MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MeditationAssistant.java
  3. 2
      README.md

3
CHANGELOG

@ -1,3 +1,6 @@ @@ -1,3 +1,6 @@
1.5.9:
- Resolve possible crash when waking device
1.5.8:
- Resolve minor sound delay by preloading sounds
- Increase session message maximum length from 160 to 4096

26
MeditationAssistant/src/main/java/sh/ftp/rocketninelabs/meditationassistant/MeditationAssistant.java

@ -550,7 +550,7 @@ public class MeditationAssistant extends Application { @@ -550,7 +550,7 @@ public class MeditationAssistant extends Application {
public void cacheSessionSounds() {
String label;
for (int i = 0;i < 3;i++) {
for (int i = 0; i < 3; i++) {
switch (i) {
case 0:
label = "start";
@ -608,7 +608,7 @@ public class MeditationAssistant extends Application { @@ -608,7 +608,7 @@ public class MeditationAssistant extends Application {
Log.d("MeditationAssistant", "Failed to cache sound");
return; // Failed to load sound
}
MediaPlayer mp = mediaPlayers.get(cacheKey);
MediaPlayer mp = mediaPlayers.get(cacheKey);
if (mp.isPlaying()) {
Log.d("MeditationAssistant", "Failed to play sound: already playing");
@ -671,9 +671,9 @@ public class MeditationAssistant extends Application { @@ -671,9 +671,9 @@ public class MeditationAssistant extends Application {
String soundPath = prefs.getString("pref_meditation_sound_" + label, "");
if (!soundPath.equals("none")) {
if (soundPath.equals("custom")) {
playSound(0, prefs.getString("pref_meditation_sound_" + label + "_custom", ""), restoreVolume);
playSound(0, prefs.getString("pref_meditation_sound_" + label + "_custom", ""), restoreVolume);
} else {
playSound(MeditationSounds.getMeditationSound(soundPath), "", restoreVolume);
playSound(MeditationSounds.getMeditationSound(soundPath), "", restoreVolume);
}
}
}
@ -2455,16 +2455,22 @@ public class MeditationAssistant extends Application { @@ -2455,16 +2455,22 @@ public class MeditationAssistant extends Application {
return BuildConfig.VERSION_CODE;
}
public synchronized String acquireWakeLock(Boolean fullWakeUp) {
return wakeLocker.acquire(getApplicationContext(), fullWakeUp);
public String acquireWakeLock(Boolean fullWakeUp) {
synchronized (wakeLocker) {
return wakeLocker.acquire(getApplicationContext(), fullWakeUp);
}
}
public synchronized void releaseWakeLock(String wakeLockID) {
wakeLocker.release(wakeLockID);
public void releaseWakeLock(String wakeLockID) {
synchronized (wakeLocker) {
wakeLocker.release(wakeLockID);
}
}
public synchronized void releaseAllWakeLocks() {
wakeLocker.releaseAll();
public void releaseAllWakeLocks() {
synchronized (wakeLocker) {
wakeLocker.releaseAll();
}
}
public enum TrackerName {

2
README.md

@ -43,7 +43,7 @@ Translation is handled [online](https://medinet.rocketnine.space/translate/). @@ -43,7 +43,7 @@ Translation is handled [online](https://medinet.rocketnine.space/translate/).
## Download
APKs may be downloaded from [F-Droid](https://f-droid.org/packages/sh.ftp.rocketninelabs.meditationassistant.opensource/) (preferred).
They may also be downloaded from [the developer](http://medinet.rocketnine.space/download/).
They may also be downloaded from [the developer](http://medinet.rocketnine.space/download/?sort=name&order=desc).
## Build

Loading…
Cancel
Save