This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
112 additions
and
17 deletions.
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
5 changes: 3 additions & 2 deletions
5
app/src/androidTest/java/moe/riru/manager/ExampleInstrumentedTest.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
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
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 |
---|---|---|
@@ -1,22 +1,80 @@ | ||
package moe.riru.manager; | ||
|
||
import android.app.AlertDialog; | ||
import android.content.ClipData; | ||
import android.content.ClipboardManager; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
|
||
import androidx.annotation.Nullable; | ||
import moe.riru.manager.app.BaseActivity; | ||
import moe.riru.manager.utils.NativeHelper; | ||
import moe.shizuku.support.text.HtmlCompat; | ||
|
||
public class MainActivity extends BaseActivity { | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
boolean init, isZygoteMethodsReplaced; | ||
int version, nativeForkAndSpecializeCallsCount, nativeForkSystemServerCallsCount; | ||
String nativeForkAndSpecializeSignature, nativeForkSystemServerSignature; | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
|
||
init = NativeHelper.init(); | ||
if (init) { | ||
version = NativeHelper.getRiruVersion(); | ||
if (version < 13) { | ||
sb.append("Riru version less than 13, diagnostic is only available for Riru v13 or above."); | ||
} else { | ||
isZygoteMethodsReplaced = NativeHelper.isZygoteMethodsReplaced(); | ||
nativeForkAndSpecializeCallsCount = NativeHelper.getNativeForkAndSpecializeCallsCount(); | ||
nativeForkSystemServerCallsCount = NativeHelper.getNativeForkSystemServerCallsCount(); | ||
nativeForkAndSpecializeSignature = NativeHelper.getNativeForkAndSpecializeSignature(); | ||
nativeForkSystemServerSignature = NativeHelper.getNativeForkSystemServerSignature(); | ||
|
||
sb.append("Riru v").append(version).append(" found.").append("<br>"); | ||
|
||
if (isZygoteMethodsReplaced) { | ||
sb.append("Native methods of Zygote class replaced.").append("<br><br>") | ||
.append("nativeForkAndSpecialize calls count: ").append(nativeForkAndSpecializeCallsCount).append("<br>") | ||
.append("nativeForkSystemServer calls count: ").append(nativeForkSystemServerCallsCount).append("<br>"); | ||
|
||
if (nativeForkAndSpecializeCallsCount == 0) { | ||
sb.append("<br>nativeForkAndSpecialize calls count is 0, Riru is not working correctly.<br>This may because Riru's hook is overwritten by other things, please check yourself."); | ||
} else if (nativeForkSystemServerCallsCount != 0) { | ||
sb.append("<br>Everything looks fine :D"); | ||
} | ||
} else { | ||
sb.append("However, native methods of Zygote class not replaced, please contact developer with the following information.").append("<br><br>") | ||
.append("nativeForkAndSpecializeSignature:<br><font face=\"monospace\">").append(nativeForkAndSpecializeSignature).append("</font><br><br>") | ||
.append("getNativeForkSystemServerSignature:<br><font face=\"monospace\">").append(nativeForkSystemServerSignature).append("</font>"); | ||
} | ||
} | ||
} else { | ||
sb.append("Riru not found in memory."); | ||
} | ||
|
||
new AlertDialog.Builder(this) | ||
.setMessage(HtmlCompat.fromHtml(sb.toString())) | ||
.setPositiveButton(android.R.string.ok, (dialog, which) -> { | ||
finish(); | ||
}) | ||
.setNeutralButton("Copy", (dialog, which) -> { | ||
getSystemService(ClipboardManager.class).setPrimaryClip(ClipData.newPlainText("text", HtmlCompat.fromHtml(sb.toString()).toString())); | ||
finish(); | ||
}) | ||
.setCancelable(false) | ||
.show(); | ||
|
||
Log.i("RiruManager", "init: " + NativeHelper.init()); | ||
Log.i("RiruManager", "getRiruVersion: " + NativeHelper.getRiruVersion()); | ||
Log.i("RiruManager", "isZygoteMethodsReplaced: " + NativeHelper.isZygoteMethodsReplaced()); | ||
Log.i("RiruManager", "getNativeForkAndSpecializeCallsCount: " + NativeHelper.getNativeForkAndSpecializeCallsCount()); | ||
Log.i("RiruManager", "getNativeForkSystemServerCallsCount: " + NativeHelper.getNativeForkSystemServerCallsCount()); | ||
Log.i("RiruManager", "getNativeForkAndSpecializeSignature: " + NativeHelper.getNativeForkAndSpecializeSignature()); | ||
Log.i("RiruManager", "getNativeForkSystemServerSignature: " + NativeHelper.getNativeForkSystemServerSignature()); | ||
} | ||
} |
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