Skip to content

Commit

Permalink
WakeLock virkar
Browse files Browse the repository at this point in the history
  • Loading branch information
sverrisson authored and Hannes Sverrisson committed Nov 26, 2018
1 parent cb61fe8 commit b82d891
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 37 deletions.
87 changes: 52 additions & 35 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public NotificationPanel(Context parent, String title, String author, boolean pl
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ruv.wifilock.player");
wakeLock.setReferenceCounted(false);

wifiLock = ((WifiManager)parent.getApplicationContext().getSystemService(Context.WIFI_SERVICE));
wifiLock.createWifiLock(WifiManager.WIFI_MODE_FULL, "ruv.wifilock.gardina.MediaPlayerService");
WifiManager wifiManager = ((WifiManager)parent.getApplicationContext().getSystemService(Context.WIFI_SERVICE));
wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, "ruv.wifilock.gardina.MediaPlayerService");
wifiLock.setReferenceCounted(false);

audioManager = (AudioManager)parent.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
Expand Down Expand Up @@ -138,16 +138,23 @@ public void getWifiLock() {
if (!wifiLock.isHeld()) {
wifiLock.acquire();
}
if (!wakeLock.isHeld()) {
wakeLock.acquire();
}
}

public void releaseWifiLock() {
if (wifiLock.isHeld()) {
wifiLock.release();
}
if (wakeLock.isHeld()) {
wakeLock.release();
}
}

@Override
protected void onDestroy() {
Log.i(TAG, "Media Gardina onDestroy");
nManager.cancel(NOTIFICATION_ID);
super.onDestroy();
}
Expand Down

0 comments on commit b82d891

Please sign in to comment.