Skip to content

Commit

Permalink
Hook UsageStatsService to track activity resume stop event
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornaco committed Oct 10, 2021
1 parent 82263b5 commit 199cbf3
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 253 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package github.tornaco.android.thanox.magisk.bridge.proxy;
package util;

import android.os.RemoteException;
import android.util.Log;
Expand All @@ -9,6 +9,7 @@
import java.lang.reflect.Method;

public interface ExceptionTransformedInvocationHandler {

default Object tryInvoke(Object proxy, Method method, Object[] args)
throws Throwable {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,11 @@ public static int getIntFieldWithPotentialNames(Object obj, String... potentialF
}
throw new NoSuchFieldException(Arrays.toString(potentialFieldNames));
}

public static boolean matchMethodNameAndArgs(Method methodToCheck, String methodNameExpected, Class<?>... argTypesExpected) {
if (!methodNameExpected.equals(methodToCheck.getName())){
return false;
}
return Arrays.equals(methodToCheck.getParameterTypes(), argTypesExpected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import com.elvishew.xlog.XLog;

import github.tornaco.android.thanox.magisk.bridge.proxy.ActivityThreadProxy;
import github.tornaco.android.thanox.magisk.bridge.proxy.SystemServiceRegistryHookInstaller;

public class ProcessHookInstaller implements ProcessHandler {
Expand Down Expand Up @@ -40,7 +39,6 @@ public void onStartApplication() {
}

AppProcessSystemServiceHookInstaller.install();
ActivityThreadProxy.install();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.lang.reflect.Proxy;
import java.util.Arrays;

import util.ExceptionTransformedInvocationHandler;

public class ActivityManagerProxyProvider implements ProxyProvider, ExceptionTransformedInvocationHandler {
private static final boolean DEBUG_AMS = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import github.tornaco.android.thanos.core.app.ThanosManagerNative;
import github.tornaco.android.thanos.core.util.PkgUtils;
import util.ExceptionTransformedInvocationHandler;
import util.ObjectsUtils;

public class ActivityTaskManagerProxyProvider implements ProxyProvider, ExceptionTransformedInvocationHandler {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import github.tornaco.android.thanos.core.IThanos;
import github.tornaco.android.thanos.core.app.ThanosManagerNative;
import github.tornaco.android.thanos.core.util.PkgUtils;
import util.ExceptionTransformedInvocationHandler;

public class AppOpsManagerProxyProvider implements ProxyProvider, ExceptionTransformedInvocationHandler {
private static final boolean DEBUG_OPS = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import github.tornaco.android.thanos.core.app.ThanosManagerNative;
import github.tornaco.android.thanos.core.n.NotificationRecord;
import util.ExceptionTransformedInvocationHandler;

public class NotificationManagerProxyProvider implements ProxyProvider, ExceptionTransformedInvocationHandler {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static github.tornaco.thanox.android.server.patch.framework.hooks.am.ActiveServicesHooks.attachActiveServices;
import static github.tornaco.thanox.android.server.patch.framework.hooks.am.AppExitInfoTrackerHooks.installAppExitInfoTracker;
import static github.tornaco.thanox.android.server.patch.framework.hooks.am.IFWHooks.installIFW;
import static github.tornaco.thanox.android.server.patch.framework.hooks.app.usage.UsageStatsManagerInternalHooks.installUsageStatsService;

import com.android.server.am.ActivityManagerService;
import com.elvishew.xlog.XLog;
Expand Down Expand Up @@ -31,6 +32,7 @@ private static void installHooksForAMS() {
attachActiveServices(ams);
installIFW(ams);
installAppExitInfoTracker(ams);
installUsageStatsService(ams);
});

} catch (Throwable e) {
Expand Down
Loading

0 comments on commit 199cbf3

Please sign in to comment.