-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Xposed back (for GitHub releases only), closes #8
- Loading branch information
1 parent
f1c153f
commit 8f3477f
Showing
9 changed files
with
240 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="tk.wasdennnoch.scoop" | ||
android:installLocation="internalOnly"> | ||
|
||
<uses-permission android:name="android.permission.VIBRATE" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> | ||
<uses-permission | ||
android:name="android.permission.READ_LOGS" | ||
tools:ignore="ProtectedPermissions" /> | ||
|
||
<application | ||
android:name=".ScoopApplication" | ||
android:allowBackup="true" | ||
android:fullBackupContent="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<meta-data | ||
android:name="xposedmodule" | ||
android:value="true" /> | ||
<meta-data | ||
android:name="xposedminversion" | ||
android:value="82" /> | ||
<meta-data | ||
android:name="preloaded_fonts" | ||
android:resource="@array/preloaded_fonts" /> | ||
|
||
<activity | ||
android:name=".ui.MainActivity" | ||
android:configChanges="orientation|screenSize|screenLayout" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
<category android:name="de.robv.android.xposed.category.MODULE_SETTINGS" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".ui.DetailActivity" | ||
android:parentActivityName=".ui.MainActivity" | ||
tools:ignore="UnusedAttribute"> | ||
<meta-data | ||
android:name="android.support.PARENT_ACTIVITY" | ||
android:value=".ui.MainActivity" /> | ||
</activity> | ||
<activity | ||
android:name=".ui.SettingsActivity" | ||
android:label="@string/settings_title"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.NOTIFICATION_PREFERENCES" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".ui.BlacklistAppsActivity" | ||
android:label="@string/blacklist_title" /> | ||
<activity | ||
android:name=".ui.AboutActivity" | ||
android:label="@string/about_title" /> | ||
|
||
<receiver | ||
android:name=".receiver.CrashReceiver" | ||
android:exported="true" | ||
tools:ignore="ExportedReceiver"> | ||
<intent-filter> | ||
<action android:name="tk.wasdennnoch.scoop.EXCEPTION" /> | ||
</intent-filter> | ||
</receiver> | ||
<receiver | ||
android:name=".receiver.ShareReceiver" | ||
android:exported="true" | ||
tools:ignore="ExportedReceiver"> | ||
<intent-filter> | ||
<action android:name="tk.wasdennnoch.scoop.ACTION_SHARE" /> | ||
<action android:name="tk.wasdennnoch.scoop.ACTION_COPY" /> | ||
</intent-filter> | ||
</receiver> | ||
|
||
<service | ||
android:name=".IndicatorService" | ||
android:enabled="true" /> | ||
|
||
<receiver | ||
android:name=".receiver.StopReceiver" | ||
android:enabled="true" /> | ||
|
||
<service | ||
android:name=".detector.CrashDetectorService" | ||
android:enabled="true" | ||
android:process=":crashDetectorService" /> | ||
<service | ||
android:name=".dogbin.DogbinUploadService" | ||
android:enabled="true" | ||
android:exported="false" /> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tk.wasdennnoch.scoop.XposedHook |
111 changes: 111 additions & 0 deletions
111
app/src/github/java/tk/wasdennnoch/scoop/XposedHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package tk.wasdennnoch.scoop; | ||
|
||
import android.app.Application; | ||
import android.content.Intent; | ||
import android.util.Log; | ||
|
||
import de.robv.android.xposed.IXposedHookLoadPackage; | ||
import de.robv.android.xposed.XC_MethodHook; | ||
import de.robv.android.xposed.XC_MethodReplacement; | ||
import de.robv.android.xposed.XposedHelpers; | ||
import de.robv.android.xposed.callbacks.XC_LoadPackage; | ||
import tk.wasdennnoch.scoop.receiver.CrashReceiver; | ||
|
||
@SuppressWarnings("WeakerAccess") | ||
public class XposedHook implements IXposedHookLoadPackage { | ||
|
||
private static String mPkg; | ||
private Application mApplication; | ||
private boolean mSent; | ||
private final XC_MethodHook uncaughtExceptionHook = new XC_MethodHook() { | ||
@Override | ||
protected void beforeHookedMethod(MethodHookParam param) throws Throwable { | ||
if (mSent) { | ||
Log.d("scoop", "uncaughtExceptionHook (" + mPkg + "): Broadcast already sent"); | ||
return; | ||
} | ||
Log.d("scoop", "uncaughtExceptionHook (" + mPkg + "): Sending broadcast"); | ||
Throwable t = (Throwable) param.args[1]; | ||
Intent intent = new Intent(Intents.INTENT_ACTION) | ||
.setClassName(BuildConfig.APPLICATION_ID, CrashReceiver.class.getName()) | ||
.putExtra(Intents.INTENT_PACKAGE_NAME, mApplication.getPackageName()) | ||
.putExtra(Intents.INTENT_TIME, System.currentTimeMillis()) | ||
.putExtra(Intents.INTENT_DESCRIPTION, t.toString()) | ||
.putExtra(Intents.INTENT_STACKTRACE, Log.getStackTraceString(t)); | ||
// Just send everything here because it costs no performance (well, technically | ||
// it does, but the process is about to die anyways, so I don't care). | ||
// Also I have no idea how to detect custom subclasses efficiently. | ||
mApplication.sendBroadcast(intent); | ||
mSent = true; // Doesn't need to be reset as process dies soon | ||
} | ||
}; | ||
private final XC_MethodHook setUncaughtExceptionHandlerHook = new XC_MethodHook() { | ||
@Override | ||
protected void beforeHookedMethod(MethodHookParam param) throws Throwable { | ||
if (param.args[0] != null) | ||
hookUncaughtException(param.args[0].getClass()); | ||
} | ||
}; | ||
|
||
@Override | ||
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { | ||
if (lpparam.packageName.equals("android")) return; | ||
mPkg = lpparam.packageName; | ||
XposedHelpers.findAndHookConstructor(Application.class, new XC_MethodHook() { | ||
@Override | ||
protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable { | ||
mApplication = (Application) param.thisObject; | ||
mSent = false; | ||
} | ||
}); | ||
XposedHelpers.findAndHookMethod( | ||
Thread.class, | ||
"setDefaultUncaughtExceptionHandler", | ||
Thread.UncaughtExceptionHandler.class, | ||
setUncaughtExceptionHandlerHook); | ||
|
||
XposedHelpers.findAndHookMethod( | ||
Thread.class, | ||
"setUncaughtExceptionHandler", | ||
Thread.UncaughtExceptionHandler.class, | ||
setUncaughtExceptionHandlerHook); | ||
|
||
XposedHelpers.findAndHookMethod( | ||
ThreadGroup.class, | ||
"uncaughtException", | ||
Thread.class, | ||
Throwable.class, | ||
uncaughtExceptionHook); | ||
|
||
// Gets initialized in between native application creation, handleLoadPackage gets | ||
// called after native creation | ||
hookUncaughtException(Thread.getDefaultUncaughtExceptionHandler().getClass()); | ||
|
||
if (lpparam.packageName.equals(BuildConfig.APPLICATION_ID)) { | ||
XposedHelpers.findAndHookMethod( | ||
ScoopApplication.class, | ||
"xposedActive", | ||
XC_MethodReplacement.returnConstant(true)); | ||
} | ||
} | ||
|
||
private void hookUncaughtException(Class<?> clazz) { | ||
int i = 0; | ||
do { // Search through superclasses | ||
try { | ||
XposedHelpers.findAndHookMethod( | ||
clazz, | ||
"uncaughtException", | ||
Thread.class, | ||
Throwable.class, | ||
uncaughtExceptionHook); | ||
Log.d("scoop", "hookUncaughtException (" + mPkg | ||
+ "): Hooked class " + clazz.getName() + " after " + i + " loops"); | ||
return; | ||
} catch (Throwable ignore) { | ||
} | ||
i++; | ||
} while ((clazz = clazz.getSuperclass()) != null); | ||
Log.d("scoop", "hookUncaughtException (" + mPkg + "): No class found to hook!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters