Skip to content

Commit

Permalink
Version 1.2: now disables Phantom Process Killing on 12L+
Browse files Browse the repository at this point in the history
  • Loading branch information
adolfintel committed Oct 16, 2022
1 parent c6e3145 commit fb75e4b
Show file tree
Hide file tree
Showing 18 changed files with 334 additions and 28 deletions.
21 changes: 21 additions & 0 deletions DozeOff/.idea/gradle.sync-conflict-20210825-112330-FX4KVJU.xml

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

3 changes: 1 addition & 2 deletions DozeOff/.idea/gradle.xml

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

9 changes: 9 additions & 0 deletions DozeOff/.idea/misc.sync-conflict-20210825-112325-FX4KVJU.xml

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

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

13 changes: 0 additions & 13 deletions DozeOff/.idea/runConfigurations.xml

This file was deleted.

194 changes: 194 additions & 0 deletions DozeOff/.idea/workspace.sync-conflict-20210825-112349-FX4KVJU.xml

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

10 changes: 7 additions & 3 deletions DozeOff/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@ android {
applicationId "com.dosse.dozeoff"
minSdkVersion 23
targetSdkVersion 29
versionCode 2
versionName '1.1'
versionCode 3
versionName '1.2'

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

lintOptions {
checkReleaseBuilds false
abortOnError false
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.dosse.dozeoff;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.dosse.dozeoff", appContext.getPackageName());
}
}
18 changes: 16 additions & 2 deletions DozeOff/app/src/main/java/com/dosse/dozeoff/DozeKiller.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.PowerManager;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.Toast;

import java.io.OutputStream;
Expand All @@ -25,9 +28,20 @@ public static void apply(Context context) {
if(prefs.getBoolean("doze_off",true)){
os.write(("dumpsys deviceidle disable\n").getBytes("ASCII")); //disable doze
Log.d("DozeOff","Doze disabled");
}else{
}else {
os.write(("dumpsys deviceidle enable\n").getBytes("ASCII")); //enable doze
Log.d("DozeOff","Doze enabled");
Log.d("DozeOff", "Doze enabled");
}
if(Build.VERSION.SDK_INT>=32){ //phantom process killing was introduced with android 12L
if(prefs.getBoolean("phantom_off",true)){ //disable phantom process killing
os.write(("settings put global settings_enable_monitor_phantom_procs false\n").getBytes("ASCII"));
os.write(("setprop persist.sys.fflag.override.settings_enable_monitor_phantom_procs false\n").getBytes("ASCII"));
Log.d("DozeOff","Phantom Process Killing disabled");
}else{ //enable phantom process killing
os.write(("settings put global settings_enable_monitor_phantom_procs true\n").getBytes("ASCII"));
os.write(("setprop persist.sys.fflag.override.settings_enable_monitor_phantom_procs true\n").getBytes("ASCII"));
Log.d("DozeOff","Phantom Process Killing enabled");
}
}
os.flush();
os.write("exit\n".getBytes("ASCII"));
Expand Down
Loading

0 comments on commit fb75e4b

Please sign in to comment.