Compare commits

...

1 Commits

Author SHA1 Message Date
wenyifan
f6f2504158 config 2022-11-26 23:56:28 +08:00
25 changed files with 226 additions and 228 deletions

View File

@ -28,6 +28,5 @@ android {
}
dependencies {
compileOnly files('libs/XposedBridgeAPI-89.jar')
}

View File

@ -1,13 +1,24 @@
<?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="run.evan.hotspotip">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true">
android:supportsRtl="true"
tools:ignore="MissingApplicationIcon"
android:theme="@style/AppTheme">
<activity
android:name="run.evan.hotspotip.SettingsActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="de.robv.android.xposed.category.MODULE_SETTINGS" />
</intent-filter>
</activity>
<meta-data
android:name="xposedmodule"
android:value="true" />
@ -17,6 +28,9 @@
<meta-data
android:name="xposedminversion"
android:value="53" />
<meta-data
android:name="xposedscope"
android:resource="@array/scope" />
</application>
</manifest>

View File

@ -4,35 +4,79 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XC_MethodHook;
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;
public class MainHook implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
if (loadPackageParam.packageName.equals("com.android.networkstack.tethering.inprocess")) {
XSharedPreferences prefs = new XSharedPreferences("run.evan.hotspotip", "conf");
XposedBridge.log("Hotspot Ip init");
XposedHelpers.findAndHookMethod("com.android.networkstack.tethering.PrivateAddressCoordinator", loadPackageParam.classLoader, "requestDownstreamAddress", "android.net.ip.IpServer", boolean.class, new XC_MethodReplacement() {
XposedHelpers.findAndHookMethod("com.android.networkstack.tethering.PrivateAddressCoordinator", loadPackageParam.classLoader, "requestDownstreamAddress", "android.net.ip.IpServer", boolean.class, new XC_MethodHook() {
@Override
protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
prefs.reload();
Class linkAddressClass = XposedHelpers.findClass("android.net.LinkAddress", loadPackageParam.classLoader);
Constructor linkAddressConstructor = linkAddressClass.getConstructor(String.class);
Class ipServerClass = XposedHelpers.findClass("android.net.ip.IpServer", loadPackageParam.classLoader);
Method interfaceTypeMethod = ipServerClass.getDeclaredMethod("interfaceType");
int iFaceType = (int) interfaceTypeMethod.invoke(methodHookParam.args[0]);
switch (iFaceType) {
case 3:
return linkAddressConstructor.newInstance("192.168.49.1/24");
case 0:
return linkAddressConstructor.newInstance("192.168.6.1/24");
case 1:
return linkAddressConstructor.newInstance("192.168.7.1/24");
default:
return linkAddressConstructor.newInstance("192.168.8.1/24");
int iFaceType = (int) interfaceTypeMethod.invoke(param.args[0]);
XposedBridge.log("Hotspot Ip process ifaceType=" + iFaceType);
XposedBridge.log(prefs.getString("usb_ip", "192.168.7.2/24"));
if (prefs.getBoolean("wlan_persistent_enable", true)) {
XposedBridge.log("Hotspot Ip fixed wlanA");
param.setResult(linkAddressConstructor.newInstance("192.168.6.1/24"));
}else {
XposedBridge.log("Hotspot Ip fixed wlan not enable");
}
// switch (iFaceType) {
// case 0:
// if (prefs.getBoolean("wlan_persistent_enable", true)) {
// XposedBridge.log("Hotspot Ip fixed wlan");
// param.setResult(linkAddressConstructor.newInstance("192.168.6.1/24"));
// }else {
// XposedBridge.log("Hotspot Ip fixed wlan not enable");
// }
// case 1:
// if (prefs.getBoolean("usb_persistent_enable", true)) {
// param.setResult(linkAddressConstructor.newInstance(prefs.getString("usb_ip", "192.168.7.1/24")));
// }
// case 2:
// if (prefs.getBoolean("bluetooth_persistent_enable", true)) {
// param.setResult(linkAddressConstructor.newInstance(prefs.getString("usb_ip", "192.168.8.1/24")));
// }
// default:
// //super.afterHookedMethod(param);
//
// }
}
//
// @Override
// protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
// Class linkAddressClass = XposedHelpers.findClass("android.net.LinkAddress", loadPackageParam.classLoader);
// Constructor linkAddressConstructor = linkAddressClass.getConstructor(String.class);
// Class ipServerClass = XposedHelpers.findClass("android.net.ip.IpServer", loadPackageParam.classLoader);
// Method interfaceTypeMethod = ipServerClass.getDeclaredMethod("interfaceType");
// int iFaceType = (int) interfaceTypeMethod.invoke(methodHookParam.args[0]);
// switch (iFaceType) {
// case 3:
// return linkAddressConstructor.newInstance("192.168.49.1/24");
// case 0:
// return linkAddressConstructor.newInstance("192.168.6.1/24");
// case 1:
// return linkAddressConstructor.newInstance("192.168.7.1/24");
// default:
// return linkAddressConstructor.newInstance("192.168.8.1/24");
// }
// }
});
}
}

View File

@ -0,0 +1,73 @@
package run.evan.hotspotip;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.view.View;
public class SettingsActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
checkEdXposed();
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.fragment_container, new SettingsFragment()).commit();
}
}
@SuppressLint("WorldReadableFiles")
private void checkEdXposed() {
try {
// getSharedPreferences will hooked by LSPosed and change xml file path to /data/misc/edxp**
// will not throw SecurityException
//noinspection deprecation
getSharedPreferences("conf", Context.MODE_WORLD_READABLE);
} catch (SecurityException exception) {
new AlertDialog.Builder(this)
.setMessage("AA")
.setPositiveButton(android.R.string.ok, (dialog12, which) -> finish())
.setNegativeButton("BB", null)
.show();
}
}
public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getPreferenceManager().setSharedPreferencesName("conf");
addPreferencesFromResource(R.xml.root_preferences);
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
View list = view.findViewById(android.R.id.list);
list.setOnApplyWindowInsetsListener((v, insets) -> {
list.setPadding(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getStableInsetBottom());
return insets.consumeSystemWindowInsets();
});
super.onViewCreated(view, savedInstanceState);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
}
@Override
public void onDestroy() {
super.onDestroy();
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
}
}
}

View File

@ -1,30 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

View File

@ -1,170 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

View File

@ -1,4 +1,8 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material">
<item name="android:colorAccent">#3F51B5</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>
</resources>

View File

@ -2,4 +2,12 @@
<resources>
<string name="app_name">固定热点IP</string>
<string name="module_desc">使热点的IP固定不变</string>
<string name="wlan_hotspot">无线热点</string>
<string name="usb_hotspot">USB网络共享</string>
<string name="bluetooth_hotspot">蓝牙网络共享</string>
<string name="fixed_ip">固定IP开关</string>
<string name="custom_ip">自定义IP</string>
<string name="wlan_title">Custom IP</string>
</resources>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="scope">
<item>android</item>
</string-array>
</resources>

View File

@ -1,4 +1,12 @@
<resources>
<string name="app_name">Fixed Hotspot IP</string>
<string name="module_desc">Make hotspot IP fixed</string>
<string name="wlan_hotspot">WLAN Hotspot</string>
<string name="usb_hotspot">USB Hotspot</string>
<string name="bluetooth_hotspot">Bluetooth Hotspot</string>
<string name="fixed_ip">Fixed IP</string>
<string name="custom_ip">Custom IP</string>
<string name="wlan_title">Custom IP</string>
</resources>

View File

@ -1,4 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light.LightStatusBar">
<item name="android:colorAccent">#3F51B5</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>
</resources>

View File

@ -0,0 +1,44 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/wlan_hotspot">
<SwitchPreference
android:defaultValue="true"
android:key="wlan_persistent_enable"
android:title="@string/fixed_ip" />
<EditTextPreference
android:defaultValue="192.168.6.1/24"
android:key="wlan_ip"
android:singleLine="true"
android:title="@string/custom_ip" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/usb_hotspot">
<SwitchPreference
android:defaultValue="true"
android:key="usb_persistent_enable"
android:title="@string/fixed_ip" />
<EditTextPreference
android:defaultValue="192.168.7.1/24"
android:key="usb_ip"
android:singleLine="true"
android:title="@string/custom_ip" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/bluetooth_hotspot">
<SwitchPreference
android:defaultValue="true"
android:key="bluetooth_persistent_enable"
android:title="@string/fixed_ip" />
<EditTextPreference
android:defaultValue="192.168.8.1/24"
android:key="bluetooth_ip"
android:singleLine="true"
android:title="@string/custom_ip" />
</PreferenceCategory>
</PreferenceScreen>