Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
fixed issues with sound volume on lock screen
Browse files Browse the repository at this point in the history
  • Loading branch information
XJIOP committed Dec 17, 2019
1 parent d322bc0 commit 6658f5f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ Always on Display (AOD) Double Tap to Lock Screen
**Install**
- Download and install [apk](https://github.com/XJIOP/OnePlus-AOD-DoubleTap-Mod/releases)
- Activate this mod in Android Settings -> System -> Accessibility
- In fingerprint settings need enable option -> Tap the screen to show
- Now one tap it shows AOD, double tap from AOD to show screen lock
- Enjoy!
2 changes: 2 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/build
/debug
/release
5 changes: 2 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ android {
applicationId "org.xjiop.oneplusaoddoubletapmod"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
versionCode 11
versionName "1.1"
}
buildTypes {
release {
Expand Down
32 changes: 25 additions & 7 deletions app/src/main/java/org/xjiop/oneplusaoddoubletapmod/KeyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,36 @@
import android.accessibilityservice.AccessibilityService;
import android.content.Context;
import android.os.PowerManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.accessibility.AccessibilityEvent;

public class KeyService extends AccessibilityService {

private final String TAG = "KeyService";

private long CLICK_DELAY;

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {}
public void onAccessibilityEvent(AccessibilityEvent event) {
//Log.d(TAG, "onAccessibilityEvent: " + event);
}

@Override
public void onInterrupt() {}
public void onInterrupt() {
//Log.d(TAG, "onInterrupt");
}

@Override
protected boolean onKeyEvent(KeyEvent event) {
return doubleClick();
//Log.d(TAG, "onKeyEvent: " + event);

boolean result = false;

if(event.getKeyCode() == KeyEvent.KEYCODE_F4)
result = doubleClick();

return result;
}

private boolean doubleClick() {
Expand All @@ -31,16 +45,20 @@ private boolean doubleClick() {
CLICK_DELAY = -1;
result = true;

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK |PowerManager.ACQUIRE_CAUSES_WAKEUP, getPackageName()+":double_tap");
wl.acquire(500L);
wl.release();
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
if(powerManager != null) {
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, getPackageName() + ":double_tap");
wakeLock.acquire(500L);
wakeLock.release();
}
}
else {
CLICK_DELAY = thisTime;
result = false;
}

//Log.d(TAG, "doubleClick: " + result);

return result;
}
}

0 comments on commit 6658f5f

Please sign in to comment.