tiann / FreeReflection

A library that lets you use reflection without any restriction above Android P

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

这玩意到底咋用?logcat提示:不能访问方法,是我调用方法不对吗?

shanlanCoding opened this issue · comments

logcat的信息:

SurfaceFlinger: Permission Denial: can't access SurfaceFlinger pid=3505, uid=10283

    public void startPower(View view) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException {
        // Do something in response to button

        //-------
        Log.d(TAG, "start-------------");

        // get hide function
        Class<?> surfaceClass = (Class<?>) CLASS.forName("android.view.SurfaceControl");
        getBuiltInDisplayMethod = surfaceClass.getMethod("getBuiltInDisplay", int.class);
        // run function
        IBinder displayToken = (IBinder) getBuiltInDisplayMethod.invoke(null, 0);

        // get hide function
        setDisplayPowerModeMethod = surfaceClass.getMethod("setDisplayPowerMode", IBinder.class, int.class);
        setDisplayPowerModeMethod.invoke(null, displayToken, 0);

        //结束
        toast("ok");
        Log.d(TAG, "end-------------");
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        Reflection.unseal(base);
        Log.d(TAG, "attachBaseContext-----------------------------------------------------------------------------------------------------------------------------------------------");

    }

image

上面的代码我是直接放在MainActivity.java文件里。在手机上执行的时候不生效。

我会一点Java代码,但是不懂Android。
大佬是我调用的方法不对吗?还是我这个函数本来就不能调用。
可以肯定的是,我这个函数可以用app_process方式运行成功。

启动程序的时候,attachBaseContext的里面的log能在logcat里看到,说明attachBaseContext确实运行成功了。

@tiann @lizhangqu @simpleton 大佬们养生的时候请帮我看看问题,谢谢了。

@tiann 再次呼叫下大佬

与反射无关。

是你这个进程,没有调用这个api 的权限。app_process 之所以可以,是因为你是以shell身份运行的。shell 用户比 app 用户权限高得多。

是你这个进程,没有调用这个api 的权限。app_process 之所以可以,是因为你是以shell身份运行的。shell 用户比 app 用户权限高得多。

莫得办法解决吗?这个功能是关闭屏幕,但是程序会继续运行,例如:视频播放不会暂停。

是你这个进程,没有调用这个api 的权限。app_process 之所以可以,是因为你是以shell身份运行的。shell 用户比 app 用户权限高得多。

莫得办法解决吗?这个功能是关闭屏幕,但是程序会继续运行,例如:视频播放不会暂停。

有解决么?遇到一样的问题