Skip to content

Commit

Permalink
更新 PackageTool
Browse files Browse the repository at this point in the history
  • Loading branch information
HChenX committed Jan 7, 2025
1 parent 248b719 commit 0ed041d
Show file tree
Hide file tree
Showing 38 changed files with 169 additions and 114 deletions.
4 changes: 2 additions & 2 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ dependencyResolutionManagement {
dependencies {
// Choose one of these options; jitpack is recommended as maven might not update as frequently.
// Tip: Replace v.*.*.* with the latest release version.
implementation 'com.github.HChenX:HookTool:v.1.1.7' // jitpack
implementation 'io.github.hchenx:hooktool:v.1.1.7'
implementation 'com.github.HChenX:HookTool:v.1.1.6.2' // jitpack
implementation 'io.github.hchenx:hooktool:v.1.1.6.2'
// maven Tip: Almost abandoned, please do not use!
}
```
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ dependencyResolutionManagement {
dependencies {
// 二选一即可,推荐使用 jitpack,maven 可能不会同步更新!
// Tip: v.*.*.* 填写当前最新发行版版本号即可!
implementation 'com.github.HChenX:HookTool:v.1.1.7' // jitpack
implementation 'io.github.hchenx:hooktool:v.1.1.7' // maven Tip: 几乎废弃,请不要使用!
implementation 'com.github.HChenX:HookTool:v.1.1.6.2' // jitpack
implementation 'io.github.hchenx:hooktool:v.1.1.6.2' // maven Tip: 几乎废弃,请不要使用!
}
```

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ plugins {
id 'maven-publish'
}

def defVersion = 'v.1.1.6.1'
int defVersionCode = 2025010701
def defVersion = 'v.1.1.6.2'
int defVersionCode = 2025010702

group = 'com.github.HChenX'
version = defVersion
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/BaseHC.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/HCData.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/HCEntrance.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/HCInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/HCState.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool;

Expand Down
22 changes: 21 additions & 1 deletion app/src/main/java/com/hchen/hooktool/ToolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,23 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.os.Parcelable;

import com.hchen.hooktool.data.AppData;
import com.hchen.hooktool.hook.IHook;
import com.hchen.hooktool.tool.additional.BitmapTool;
import com.hchen.hooktool.tool.additional.PackageTool;
import com.hchen.hooktool.tool.itool.IPackageInfoGetter;

import java.util.ArrayList;

import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
Expand Down Expand Up @@ -101,6 +111,16 @@ public void before() {
}
};

AppData appData = PackageTool.getPackagesByCode(new IPackageInfoGetter() {
@Override
public Parcelable[] packageInfoGetter(PackageManager pm) throws PackageManager.NameNotFoundException {
PackageInfo packageInfo = null;
ArrayList<PackageInfo> arrayList = new ArrayList<>();
return arrayList.toArray(new PackageInfo[0]);
}
})[0];
Bitmap bitmap = BitmapTool.drawableToBitmap(appData.icon);

prefs().get("test_key", "0"); // 获取 prefs test_key 的值
prefs().getBoolean("test_key_bool", false); // 获取 prefs test_key_bool 的值

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/hchen/hooktool/data/AppData.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.data;

import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;

/**
* App 数据
Expand All @@ -28,7 +28,7 @@
public final class AppData {
public int user = 0; /* user id */
public int uid = -1; /* uid */
public Bitmap icon; /* 图标 */
public Drawable icon; /* 图标 */
public String label; /* 应用名 */
public String packageName; /* 包名 */
public String versionName; /* 版本名 */
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/data/ChainData.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.data;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/data/HookState.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.data;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/data/Priority.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.helper;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/helper/TryHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.helper;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/hook/HookFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.hook;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/hook/IHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.hook;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/log/AndroidLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.log;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/log/LogExpand.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.log;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/log/XposedLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.log;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/tool/ChainTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.tool;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/tool/CoreBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.tool;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/tool/CoreTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.tool;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/tool/ParamTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.tool;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/hchen/hooktool/tool/PrefsTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.tool;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.tool;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* This file is part of HookTool.
* HookTool is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.tool.additional;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;

import java.io.ByteArrayOutputStream;

/**
* Drawable 转 Bitmap
*/
public final class BitmapTool {
public static Bitmap drawableToBitmap(Drawable drawable) {
return drawableToBitmap(drawable, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
}

public static Bitmap drawableToBitmap(Drawable drawable, int width, int height) {
if (width <= 0 || height <= 0) {
width = drawable.getIntrinsicWidth();
height = drawable.getIntrinsicHeight();
}

Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
Bitmap bitmap = Bitmap.createBitmap(width, height, config);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, width, height);
drawable.draw(canvas);
return bitmap;
}

public static byte[] BitmapToBytes(Bitmap bm) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
return baos.toByteArray();
}

public static Bitmap BytesToBimap(byte[] b) {
if (b.length != 0) {
return BitmapFactory.decodeByteArray(b, 0, b.length);
} else {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.tool.additional;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.tool.additional;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* Copyright (C) 2023-2024 HookTool Contributions
* Copyright (C) 2023-2024 HChenX
*/
package com.hchen.hooktool.tool.additional;

Expand Down
Loading

0 comments on commit 0ed041d

Please sign in to comment.