Skip to content

Commit

Permalink
opt code logic
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackBoxing committed Jul 31, 2022
1 parent 8ee9d98 commit 8569037
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Bcore/src/main/cpp/BoxCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ void nativeHook(JNIEnv *env) {
BaseHook::init(env);
UnixFileSystemHook::init(env);
VMClassLoaderHook::init(env);

// SystemPropertiesHook会引起小米k40,安卓11上的抖音崩溃
SystemPropertiesHook::init(env);

RuntimeHook::init(env);
BinderHook::init(env);
}
Expand Down Expand Up @@ -111,7 +114,6 @@ void addWhiteList(JNIEnv *env, jclass clazz, jstring path) {
}

void enableIO(JNIEnv *env, jclass clazz) {
// SystemPropertiesHook::init(env);
IO::init(env);
nativeHook(env);
}
Expand Down
3 changes: 2 additions & 1 deletion Bcore/src/main/cpp/Hook/SystemPropertiesHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ HOOK_JNI(int, __system_property_get, const char *name, char *value) {
if (NULL == name || NULL == value) {
return orig___system_property_get(name, value);
}
// log_print_debug("calling __system_property_get");

ALOGD(name, value);
auto ret = prop_map.find(name);
if (ret != prop_map.end()) {
Expand Down Expand Up @@ -65,6 +65,7 @@ void SystemPropertiesHook::init(JNIEnv *env) {
"native_get", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
(void *) new_native_get,
(void **) (&orig_native_get), true);

shadowhook_hook_sym_name("libc.so", "__system_property_get", (void *) new___system_property_get,
(void **) (&orig___system_property_get));
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ private int getUsingBPidL() {

public void restartAppProcess(String packageName, String processName, int userId) {
synchronized (mProcessLock) {
int callingUid = Binder.getCallingUid();
int callingPid = Binder.getCallingPid();
ProcessRecord app = findProcessByPid(callingPid);;
if (app == null) {
String stubProcessName = getProcessName(BlackBoxCore.getContext(), callingPid);
int bpid = parseBPid(stubProcessName);
startProcessLocked(packageName, processName, userId, bpid, callingPid);
ProcessRecord app = findProcessByPid(callingPid);
if (app != null) {
killProcess(app);
}
String stubProcessName = getProcessName(BlackBoxCore.getContext(), callingPid);
int bpid = parseBPid(stubProcessName);
startProcessLocked(packageName, processName, userId, bpid, callingPid);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ public ComponentName getCallingActivity(IBinder token, int userId) {

private void synchronizeTasks() {
List<ActivityManager.RecentTaskInfo> recentTasks = mAms.getRecentTasks(100, 0);
List<ActivityManager.AppTask> appTasks = mAms.getAppTasks();
Map<Integer, TaskRecord> newTacks = new LinkedHashMap<>();
for (int i = recentTasks.size() - 1; i >= 0; i--) {
ActivityManager.RecentTaskInfo next = recentTasks.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* 此处无Bug
*/
public class UserSpace {
// 单实例
public final ActiveServices mActiveServices = new ActiveServices();
// 单实例
public final ActivityStack mStack = new ActivityStack();
public final Map<IBinder, PendingIntentRecord> mIntentSenderRecords = new HashMap<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* 此处无Bug
*/
public class IPackageManagerProxy extends BinderInvocationStub {
public static final String TAG = "PackageManagerStub";
public static final String TAG = "PackageManagerProxy";

public IPackageManagerProxy() {
super(BRActivityThread.get().sPackageManager().asBinder());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.IBinder;

import top.niunaijun.blackbox.core.system.am.ActivityRecord;
import top.niunaijun.blackbox.utils.compat.BundleCompat;

/**
* Created by Milk on 3/31/21.
Expand Down
2 changes: 2 additions & 0 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
* vlc应用启动崩溃,96bd784版本正常启动
* 火狐浏览器点击输入网址崩溃
* 调用content provider的getType崩溃
* 静态广播测试失败
* 多进程缺陷,初步怀疑新进程启动后,Activity中的原活动对应的pid未更新,导致出现新活动对应多进程。卡顿是由于初始化新进程导致的

## 感谢
- [VirtualApp](https://github.com/asLody/VirtualApp)
Expand Down

0 comments on commit 8569037

Please sign in to comment.