Skip to content

Commit

Permalink
battery optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
marcolettieri committed Aug 19, 2021
1 parent cb59556 commit 446f6fa
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 30 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ android {
applicationId "com.ml.proximitysensorfix"
minSdkVersion 16
targetSdkVersion 30
versionCode 31
versionName "1.0.9"
versionCode 32
versionName "1.1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.config
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
{
"type": "SINGLE",
"filters": [],
"versionCode": 31,
"versionName": "1.0.9",
"versionCode": 32,
"versionName": "1.1.0",
"outputFile": "app-release.apk"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import android.os.Build;
import android.os.IBinder;
import android.os.PowerManager;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;

Expand Down Expand Up @@ -56,16 +55,14 @@ private void createNotificationChannel() {
DevicePolicyManager devicePolicyManager;
SharedPreferences preferences;
AccessibilityManager accessibilityService;
Boolean locked = Boolean.FALSE;
BroadcastReceiver screenReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if(sm!=null){
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF) && locked) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
sm.unregisterListener(ProximitySensorService.this);
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
registerListeners();
locked = Boolean.FALSE;
}
}
}
Expand Down Expand Up @@ -145,7 +142,6 @@ private void lockNow() {
event.getText().add(getString(R.string.accessibility_service_text));
accessibilityService.sendAccessibilityEvent(event);
}
locked = Boolean.TRUE;
sm.unregisterListener(this);
}
@Override
Expand All @@ -164,27 +160,6 @@ public void onSensorChanged(SensorEvent event) {
}
}
}
/*if (true || isCallActive()) {
if (event.values[0] == 0) {
if (!wakeLock.isHeld()) {
Log.d("APP", "BLOCK");
wakeLock.acquire();
}
} else {
if (wakeLock.isHeld()) {
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
e.printStackTrace();
}
Log.d("APP", "RELEASE");
wakeLock.release();
}
}
}*/
}
@Override
public void onDestroy() {
Expand Down

0 comments on commit 446f6fa

Please sign in to comment.