Skip to content

Commit d70b566

Browse files
committed
move AboutFragment.getActiveXposedVersion() to MainApplication
1 parent a712de0 commit d70b566

4 files changed

Lines changed: 29 additions & 19 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
android:allowBackup="false"
99
android:icon="@mipmap/ic_launcher"
1010
android:label="@string/app_name"
11+
android:name=".MainApplication"
1112
android:roundIcon="@mipmap/ic_launcher_round"
1213
android:supportsRtl="true"
1314
android:theme="@style/Theme.AppCompat.DayNight">
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package tw.idv.palatis.xappdebug;
2+
3+
import static tw.idv.palatis.xappdebug.Constants.LOG_TAG;
4+
5+
import android.app.Application;
6+
import android.util.Log;
7+
8+
import androidx.annotation.Keep;
9+
10+
public class MainApplication extends Application {
11+
@Keep
12+
public static int getActiveXposedVersion() {
13+
Log.d(LOG_TAG, "Xposed framework is inactive.");
14+
return -1;
15+
}
16+
}

app/src/main/java/tw/idv/palatis/xappdebug/ui/AboutFragment.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
11
package tw.idv.palatis.xappdebug.ui;
22

3+
import static tw.idv.palatis.xappdebug.BuildConfig.VERSION_NAME;
4+
35
import android.content.Intent;
46
import android.net.Uri;
57
import android.os.Bundle;
6-
import android.util.Log;
78
import android.view.LayoutInflater;
89
import android.view.View;
910
import android.view.ViewGroup;
1011
import android.widget.Button;
1112
import android.widget.TextView;
1213

13-
import androidx.annotation.Keep;
1414
import androidx.annotation.NonNull;
1515
import androidx.fragment.app.Fragment;
16-
import tw.idv.palatis.xappdebug.R;
1716

18-
import static tw.idv.palatis.xappdebug.BuildConfig.VERSION_NAME;
19-
import static tw.idv.palatis.xappdebug.Constants.LOG_TAG;
17+
import tw.idv.palatis.xappdebug.MainApplication;
18+
import tw.idv.palatis.xappdebug.R;
2019

2120
public class AboutFragment extends Fragment {
22-
23-
@Keep
24-
private static int getActiveXposedVersion() {
25-
Log.d(LOG_TAG, "Xposed framework is inactive.");
26-
return -1;
27-
}
28-
2921
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
3022
final View root = inflater.inflate(R.layout.fragment_about, container, false);
3123
final Button button = root.findViewById(R.id.github);
@@ -34,7 +26,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
3426
final TextView version = root.findViewById(R.id.version);
3527
version.setText(getString(R.string.app_version, VERSION_NAME));
3628

37-
int xposed = getActiveXposedVersion();
29+
int xposed = MainApplication.getActiveXposedVersion();
3830
if (xposed != -1) {
3931
final TextView text = root.findViewById(R.id.xposed);
4032
text.setText(getString(R.string.xposed_version, xposed));

app/src/main/java/tw/idv/palatis/xappdebug/xposed/HookSelf.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package tw.idv.palatis.xappdebug.xposed;
22

3-
import androidx.annotation.Keep;
4-
import de.robv.android.xposed.IXposedHookLoadPackage;
5-
import de.robv.android.xposed.callbacks.XC_LoadPackage;
6-
import tw.idv.palatis.xappdebug.ui.AboutFragment;
7-
83
import static de.robv.android.xposed.XC_MethodReplacement.returnConstant;
94
import static de.robv.android.xposed.XposedBridge.getXposedVersion;
105
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
116
import static tw.idv.palatis.xappdebug.BuildConfig.APPLICATION_ID;
127

8+
import androidx.annotation.Keep;
9+
10+
import de.robv.android.xposed.IXposedHookLoadPackage;
11+
import de.robv.android.xposed.callbacks.XC_LoadPackage;
12+
import tw.idv.palatis.xappdebug.MainApplication;
13+
1314
@Keep
1415
public class HookSelf implements IXposedHookLoadPackage {
1516
@Override
@@ -18,7 +19,7 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th
1819
return;
1920

2021
findAndHookMethod(
21-
AboutFragment.class.getName(),
22+
MainApplication.class.getName(),
2223
lpparam.classLoader,
2324
"getActiveXposedVersion",
2425
returnConstant(getXposedVersion())

0 commit comments

Comments
 (0)