Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Remove obsolete code
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Feb 14, 2015
1 parent 862d144 commit ce1c3a1
Showing 1 changed file with 1 addition and 54 deletions.
55 changes: 1 addition & 54 deletions src/biz/bokhorst/xprivacy/XActivityManagerService.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package biz.bokhorst.xprivacy;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Semaphore;

import android.annotation.SuppressLint;
import android.os.Build;
import android.os.IBinder;
import android.util.Log;

@SuppressLint("InlinedApi")
Expand All @@ -20,7 +18,6 @@ public class XActivityManagerService extends XHook {
private static boolean mLockScreen = false;
private static boolean mSleeping = false;
private static boolean mShutdown = false;
private static int mResumed = -1;

private XActivityManagerService(Methods method) {
super(null, method.name(), null);
Expand Down Expand Up @@ -61,8 +58,7 @@ public String getClassName() {
// @formatter:off
private enum Methods {
inputDispatchingTimedOut, appNotResponding,
systemReady, finishBooting, setLockScreenShown, goingToSleep, wakingUp, shutdown,
activityResumed, activityPaused
systemReady, finishBooting, setLockScreenShown, goingToSleep, wakingUp, shutdown
};
// @formatter:on

Expand All @@ -77,8 +73,6 @@ public static List<XHook> getInstances() {
listHook.add(new XActivityManagerService(Methods.goingToSleep));
listHook.add(new XActivityManagerService(Methods.wakingUp));
listHook.add(new XActivityManagerService(Methods.shutdown));
listHook.add(new XActivityManagerService(Methods.activityResumed));
listHook.add(new XActivityManagerService(Methods.activityPaused));
return listHook;
}

Expand All @@ -94,10 +88,6 @@ public static boolean canWriteUsageData() {
return !mShutdown;
}

public static boolean isVisible(int uid) {
return (mResumed == uid);
}

@Override
protected void before(XParam param) throws Throwable {
switch (mMethod) {
Expand Down Expand Up @@ -150,16 +140,6 @@ protected void before(XParam param) throws Throwable {
mShutdown = true;
Util.log(this, Log.WARN, "Shutdown");
break;

case activityResumed:
mResumed = getUidForToken(param.args[0]);
Util.log(this, Log.WARN, "Resumed uid=" + mResumed);
break;

case activityPaused:
mResumed = -1;
Util.log(this, Log.WARN, "Paused uid=" + getUidForToken(param.args[0]));
break;
}
}

Expand Down Expand Up @@ -200,11 +180,6 @@ protected void after(XParam param) throws Throwable {
case shutdown:
// Do nothing
break;

case activityResumed:
case activityPaused:
// Do nothing
break;
}
}

Expand All @@ -226,32 +201,4 @@ private int getUidANR(XParam param) throws IllegalAccessException {
}
return uid;
}

private int getUidForToken(Object token) {
Class<?> cActivityRecord;
try {
cActivityRecord = Class.forName("com.android.server.am.ActivityRecord");
Method mForToken = cActivityRecord.getDeclaredMethod("forToken", IBinder.class);
mForToken.setAccessible(true);
Object activityRecord = mForToken.invoke(null, token);
if (activityRecord != null) {
// Get ActivityRecord.app (ProcessRecord)
Field fApp = cActivityRecord.getDeclaredField("app");
fApp.setAccessible(true);
Object processRecord = fApp.get(activityRecord);

// Get ProcessRecord.uid (int)
Class<?> cProcessRecord = Class.forName("com.android.server.am.ProcessRecord");
Field fUid = cProcessRecord.getDeclaredField("uid");
fUid.setAccessible(true);
return (Integer) fUid.get(processRecord);
}
} catch (ClassNotFoundException ignored) {
} catch (NoSuchMethodException ignored) {
} catch (NoSuchFieldException ignored) {
} catch (Throwable ex) {
Util.bug(this, ex);
}
return -1;
}
}

0 comments on commit ce1c3a1

Please sign in to comment.