Skip to content

Commit

Permalink
Lollipop support
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteckler committed Feb 14, 2015
1 parent 3d67e3e commit e13c764
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 65 deletions.
3 changes: 2 additions & 1 deletion .idea/gradle.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.

11 changes: 0 additions & 11 deletions .idea/libraries/support_annotations_20_0_0.xml

This file was deleted.

11 changes: 11 additions & 0 deletions .idea/libraries/support_annotations_21_0_0.xml

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

11 changes: 0 additions & 11 deletions .idea/libraries/support_v4_20_0_0.xml

This file was deleted.

13 changes: 13 additions & 0 deletions .idea/libraries/support_v4_21_0_0.xml

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

13 changes: 8 additions & 5 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
Expand All @@ -31,11 +31,13 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
Expand Down Expand Up @@ -77,13 +79,14 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="XposedBridgeApi-54" level="project" />
<orderEntry type="library" exported="" name="play-services-6.1.11" level="project" />
<orderEntry type="library" exported="" name="support-annotations-20.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-20.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-6.5.87" level="project" />
<orderEntry type="library" exported="" name="gson-2.3" level="project" />
</component>
</module>
Expand Down
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ buildscript {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
classpath 'com.android.tools.build:gradle:1.0.0'
}
}

android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId 'com.ryansteckler.nlpunbounce'
minSdkVersion 16
targetSdkVersion 20
versionCode 44
versionName '2.0.7'
targetSdkVersion 21
versionCode 50
versionName '3.0.0'
}
buildTypes {
release {
runProguard false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Expand Down
50 changes: 27 additions & 23 deletions app/src/main/java/com/ryansteckler/nlpunbounce/hooks/Wakelocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

import static de.robv.android.xposed.XposedHelpers.callMethod;
Expand All @@ -38,7 +39,6 @@ public class Wakelocks implements IXposedHookLoadPackage {
public static final String FILE_VERSION = "3"; //This needs to be pulled from the manifest or gradle build.
private HashMap<String, Long> mLastWakelockAttempts = null; //The last time each wakelock was allowed.
private HashMap<String, Long> mLastAlarmAttempts = null; //The last time each alarm was allowed.
// private HashMap<String, Long> mLastServiceAttempts = null; //The last time each wakelock was allowed.

private long mLastUpdateStats = 0;
private long mUpdateStatsFrequency = 300000; //Save every five minutes
Expand All @@ -50,7 +50,6 @@ public class Wakelocks implements IXposedHookLoadPackage {

XSharedPreferences m_prefs;
public static HashMap<IBinder, InterimEvent> mCurrentWakeLocks;
// public static HashMap<String, InterimEvent> mCurrentServices;

@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
Expand All @@ -63,10 +62,8 @@ public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
defaultLog("Version " + VERSION);

mCurrentWakeLocks = new HashMap<IBinder, InterimEvent>();
// mCurrentServices = new HashMap<String, InterimEvent>();
mLastWakelockAttempts = new HashMap<String, Long>();
mLastAlarmAttempts = new HashMap<String, Long>();
// mLastServiceAttempts = new HashMap<String, Long>();

hookAlarms(lpparam);
hookWakeLocks(lpparam);
Expand All @@ -90,7 +87,6 @@ private void resetFilesIfNeeded(Context context) {
} catch (IllegalStateException ise) {
}
}
// UnbounceStatsCollection.getInstance().resetLocalStats(UnbounceStatsCollection.STAT_CURRENT);
}
}

Expand Down Expand Up @@ -148,8 +144,14 @@ private void hookAlarms(LoadPackageParam lpparam) {

private void hookWakeLocks(LoadPackageParam lpparam) {
boolean wakeLocksHooked = false;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//Try for wakelock hooks for API levels 19-20
defaultLog("Attempting 21 WakeLockHook");
try21WakeLockHook(lpparam);
defaultLog("Successful 21 WakeLockHook");
wakeLocksHooked = true;
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
//Try for wakelock hooks for API levels 19-20
defaultLog("Attempting 19to20 WakeLockHook");
try19To20WakeLockHook(lpparam);
Expand Down Expand Up @@ -228,15 +230,6 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
});
}

// findAndHookMethod("com.android.server.am.ActiveServices", lpparam.classLoader, "stopServiceLocked", "android.app.IApplicationThread", Intent.class, String.class, int.class, new XC_MethodHook() {
// @Override
// protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// Intent intent = (Intent) param.args[1];
// handleServiceStop(param, intent);
// }
// });

}

//4.1.2r1 to
Expand All @@ -248,15 +241,26 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
handleServiceStart(param, intent);
}
});
}

// findAndHookMethod("com.android.server.am.ActiveServices", lpparam.classLoader, "stopServiceLocked", "android.app.IApplicationThread", Intent.class, String.class, int.class, new XC_MethodHook() {
// @Override
// protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// Intent intent = (Intent) param.args[1];
// handleServiceStop(param, intent);
// }
// });
private void try21WakeLockHook(LoadPackageParam lpparam) {
findAndHookMethod("com.android.server.power.PowerManagerService", lpparam.classLoader, "acquireWakeLockInternal", android.os.IBinder.class, int.class, String.class, String.class, android.os.WorkSource.class, String.class, int.class, int.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
String wakeLockName = (String) param.args[2];
IBinder lock = (IBinder) param.args[0];
int uId = (Integer) param.args[6];
handleWakeLockAcquire(param, wakeLockName, lock, uId);
}
});

findAndHookMethod("com.android.server.power.PowerManagerService", lpparam.classLoader, "releaseWakeLockInternal", android.os.IBinder.class, int.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
IBinder lock = (IBinder) param.args[0];
handleWakeLockRelease(param, lock);
}
});
}


Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
classpath 'com.android.tools.build:gradle:1.0.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Fri Feb 13 18:35:09 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
4 changes: 3 additions & 1 deletion unbounce-android.iml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/classes/main" />
<output-test url="file://$MODULE_DIR$/build/classes/test" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
Expand Down

0 comments on commit e13c764

Please sign in to comment.