Skip to content

Commit

Permalink
更新图标 新增启动开关
Browse files Browse the repository at this point in the history
  • Loading branch information
gallonyin committed Jun 19, 2018
1 parent f5a947b commit de1cae1
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 29 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "org.caworks.wechathk"
applicationId "org.gallonyin.wechathk"
minSdkVersion 15
targetSdkVersion 26
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.caworks.wechathk">
package="org.gallonyin.wechathk">

<application
android:allowBackup="true"
Expand All @@ -24,7 +24,7 @@
android:name="xposedminversion"
android:value="30" />

<activity android:name="org.caworks.wechathk.MainActivity">
<activity android:name="org.gallonyin.wechathk.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.caworks.wechathk;
package org.gallonyin.wechathk;

import android.util.Log;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,55 @@
package org.caworks.wechathk;
package org.gallonyin.wechathk;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Toast;

/**
* Created by gallonyin on 2018/6/13.
*
* todo List 添加数据库
* 开启校偏 0.002 -0.005
* 界面左拉框
* 腾讯获取坐标点 http://lbs.qq.com/tool/getpoint/
* 开关
*/

public class MainActivity extends AppCompatActivity {


private EditText et_la;
private EditText et_lo;
private CheckBox cb_open;
private SharedPreferences sp;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sp = getSharedPreferences("main", Context.MODE_PRIVATE);

initView();
}

private void initView() {
et_la = findViewById(R.id.et_la);
et_lo = findViewById(R.id.et_lo);
cb_open = findViewById(R.id.cb_open);
cb_open.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Intent intent = new Intent("weworkdk_open");
intent.putExtra("open", isChecked);
sendBroadcast(intent);
}
});
findViewById(R.id.bt_save).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -36,11 +59,12 @@ public void onClick(View v) {
Toast.makeText(MainActivity.this, "格式异常", Toast.LENGTH_LONG).show();
return;
}
Intent intent = new Intent("weworkdk");
Intent intent = new Intent("weworkdk_gps");
intent.putExtra("data", la + "#" + lo);
sendBroadcast(intent);
Toast.makeText(MainActivity.this, "保存修改成功", Toast.LENGTH_LONG).show();
}
});

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.caworks.wechathk;
package org.gallonyin.wechathk;

import android.content.BroadcastReceiver;
import android.content.Context;
Expand Down Expand Up @@ -38,6 +38,7 @@ public class WeWork {
private float defLo = 118.784308f;
private float la = 0;
private float lo = 0;
private boolean isOpen = true;

public void start(ClassLoader classLoader) {
this.classLoader = classLoader;
Expand All @@ -50,19 +51,29 @@ private void initReceiver(Context context, final SharedPreferences sp) {

@Override
public void onReceive(Context context, Intent intent) {
String data = intent.getStringExtra("data");
Log.e(TAG, "onReceive: " + data);
String[] split = data.split("#");
if (split.length != 2) return;
la = Float.parseFloat(split[0]);
lo = Float.parseFloat(split[1]);
sp.edit().putFloat("GPSLatitude", la)
.putFloat("GPSLongitude", lo)
.apply();
String action = intent.getAction();
if (action == null) return;
switch (action) {
case "weworkdk_gps":
String data = intent.getStringExtra("data");
Log.e(TAG, "onReceive: " + data);
String[] split = data.split("#");
if (split.length != 2) return;
la = Float.parseFloat(split[0]);
lo = Float.parseFloat(split[1]);
sp.edit().putFloat("GPSLatitude", la)
.putFloat("GPSLongitude", lo)
.apply();
break;
case "weworkdk_open":
isOpen = intent.getBooleanExtra("weworkdk_open", true);
break;
}
}
};

IntentFilter filter = new IntentFilter("weworkdk");
IntentFilter filter = new IntentFilter("weworkdk_gps");
filter.addAction("weworkdk_open");
context.registerReceiver(receiver, filter);
}

Expand All @@ -83,9 +94,9 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}

private float salted(float f) {
if (f > 0) {
return (float) (f + salt * (1 - (Math.random() * 2)));
}
// if (f > 0) {
// return (float) (f + salt * (1 - (Math.random() * 2)));
// }
return f;
}

Expand All @@ -96,6 +107,7 @@ private void hkGPS(ClassLoader classLoader) {
"getCellLocation", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(null);
Log.d(TAG, "getCellLocation");
}
Expand All @@ -105,6 +117,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
"onCellLocationChanged", CellLocation.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(null);
Log.d(TAG, "onCellLocationChanged");
}
Expand All @@ -115,6 +128,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
"getPhoneCount", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(1);
Log.d(TAG, "getPhoneCount");
}
Expand All @@ -126,6 +140,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
"getNeighboringCellInfo", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(new ArrayList<>());
Log.d(TAG, "getNeighboringCellInfo");
}
Expand All @@ -137,6 +152,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
"getAllCellInfo", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(null);
Log.d(TAG, "getAllCellInfo");
}
Expand All @@ -145,6 +161,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
"onCellInfoChanged", List.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(null);
Log.d(TAG, "onCellInfoChanged");
}
Expand All @@ -154,6 +171,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod("android.net.wifi.WifiManager", classLoader, "getScanResults", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(new ArrayList<>());
Log.d(TAG, "getScanResults");
}
Expand All @@ -162,6 +180,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod("android.net.wifi.WifiManager", classLoader, "getWifiState", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(1);
Log.d(TAG, "getWifiState");
}
Expand All @@ -170,6 +189,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod("android.net.wifi.WifiManager", classLoader, "isWifiEnabled", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(true);
Log.d(TAG, "isWifiEnabled");
}
Expand All @@ -178,6 +198,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod("android.net.wifi.WifiInfo", classLoader, "getMacAddress", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult("00-00-00-00-00-00-00-00");
Log.d(TAG, "getMacAddress");
}
Expand All @@ -186,6 +207,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod("android.net.wifi.WifiInfo", classLoader, "getSSID", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult("null");
Log.d(TAG, "getSSID");
}
Expand All @@ -194,6 +216,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod("android.net.wifi.WifiInfo", classLoader, "getBSSID", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult("00-00-00-00-00-00-00-00");
Log.d(TAG, "getBSSID");
}
Expand All @@ -204,6 +227,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
"getTypeName", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult("WIFI");
Log.d(TAG, "getTypeName");
}
Expand All @@ -212,6 +236,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
"isConnectedOrConnecting", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(true);
Log.d(TAG, "isConnectedOrConnecting");
}
Expand All @@ -221,6 +246,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
"isConnected", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(true);
Log.d(TAG, "isConnected");
}
Expand All @@ -230,6 +256,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
"isAvailable", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(true);
Log.d(TAG, "isAvailable");
}
Expand All @@ -239,6 +266,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
"isRegistered", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(true);
Log.d(TAG, "isRegistered");
}
Expand All @@ -247,6 +275,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod(LocationManager.class, "getLastLocation", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
Location l = new Location(LocationManager.GPS_PROVIDER);
l.setLatitude(salted(la));
l.setLongitude(salted(lo));
Expand All @@ -263,6 +292,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod(LocationManager.class, "getLastKnownLocation", String.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
Location l = new Location(LocationManager.GPS_PROVIDER);
l.setLatitude(salted(la));
l.setLongitude(salted(lo));
Expand All @@ -280,6 +310,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.hookAllMethods(LocationManager.class, "getProviders", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add("gps");
param.setResult(arrayList);
Expand All @@ -290,6 +321,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod(LocationManager.class, "getBestProvider", Criteria.class, Boolean.TYPE, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult("gps");
Log.d(TAG, "getBestProvider");
}
Expand All @@ -298,6 +330,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod(LocationManager.class, "addGpsStatusListener", GpsStatus.Listener.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
if (param.args[0] != null) {
XposedHelpers.callMethod(param.args[0], "onGpsStatusChanged", 1);
XposedHelpers.callMethod(param.args[0], "onGpsStatusChanged", 3);
Expand All @@ -309,6 +342,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.findAndHookMethod(LocationManager.class, "addNmeaListener", GpsStatus.NmeaListener.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
param.setResult(false);
Log.d(TAG, "addNmeaListener");
}
Expand All @@ -318,6 +352,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
"getGpsStatus", GpsStatus.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
Log.d(TAG, "getGpsStatus");
GpsStatus gss = (GpsStatus) param.getResult();
if (gss == null)
Expand Down Expand Up @@ -370,6 +405,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.hookMethod(method, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
Log.d(TAG, "requestLocationUpdates");
if (param.args.length >= 4 && (param.args[3] instanceof LocationListener)) {

Expand Down Expand Up @@ -410,6 +446,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.hookMethod(method, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (!isOpen) return;
Log.d(TAG, "requestSingleUpdate");
if (param.args.length >= 3 && (param.args[1] instanceof LocationListener)) {

Expand Down
Loading

0 comments on commit de1cae1

Please sign in to comment.