在系统应用程序上使用android的ShutdownThread with Reflection

时间:2016-01-13 15:48:58

标签: java android reflection shutdown android-4.1-jelly-bean

我在系统分区上安装了一个应用程序(未使用系统的签名密钥签名),并希望使用shutdown ShutdownThread方法。我做了以下事情:

try {
    Class<?> ShutdownThread = Class.forName("com.android.server.pm.ShutdownThread");
    Method shutdown = ShutdownThread.getMethod("shutdown", Context.class, boolean.class);
    Log.v(getString(R.string.app_name), "PowerService: apagando");
    shutdown.invoke(ShutdownThread, getApplicationContext(), false);
} catch (Exception e) {
    e.printStackTrace();
}
Log.v(getString(R.string.app_name), "PowerService: deteniendo");

方法get被正确调用但在shutdown()执行期间发生错误,我不知道如何解决它。接下来是Logcat的消息:

01-16 13:38:46.976: V/My APP        (587): PowerService: apagando
01-16 13:38:46.984: D/ShutdownThread(587): !@Notifying thread to start shutdown longPressBehavior=1
01-16 13:38:46.984: I/ShutdownThread(587): !@########POWEROFF START WITHOUT CONFIRM######
01-16 13:38:46.984: I/ShutdownDelay (587): start state
01-16 13:38:46.984: I/ShutdownThread(587): beginShutdownSequence
01-16 13:38:46.984: I/ShutdownThread(587): setStartedShutdown to true
01-16 13:38:46.984: D/InputReader   (389): !@setStartedShutdown: 1
01-16 13:38:46.984: D/BatteryStatsImpl(389): ++++++xy WakeLock start : pid=587, name=, type=0, tid=688, pid=389, pName=null
01-16 13:38:46.984: I/AudioSystem   (587): AudioSystem::setParameters(shutdown=1)
01-16 13:38:46.984: D/dalvikvm      (389): WAIT_FOR_CONCURRENT_GC blocked 0ms
01-16 13:38:46.992: W/ServiceManager(106): Permission failure: android.permission.MODIFY_AUDIO_SETTINGS from uid=10121 pid=587
01-16 13:38:46.992: E/    (106): Request requires android.permission.MODIFY_AUDIO_SETTINGS
01-16 13:38:47.109: D/dalvikvm      (389): GC_EXPLICIT freed 609K, 22% free 14194K/18055K, paused 6ms+9ms, total 126ms
01-16 13:38:47.117: D/BatteryStatsImpl(389): ++++++xy WakeLock start : pid=106, name=, type=0, tid=389, pid=389, pName=null
01-16 13:38:47.117: I/ShutdownDialog(587): prepare shutdown dialog image and sound
01-16 13:38:47.117: W/dalvikvm      (587): No implementation found for native Lcom/android/server/pm/LibQmg;.qmgOpen:(Ljava/lang/String;)I
01-16 13:38:47.117: W/System.err    (587): java.lang.reflect.InvocationTargetException
01-16 13:38:47.117: W/System.err    (587):  at java.lang.reflect.Method.invokeNative(Native Method)
01-16 13:38:47.117: W/System.err    (587):  at java.lang.reflect.Method.invoke(Method.java:511)
01-16 13:38:47.117: W/System.err    (587):  at com.colaboracionvirtual.provisioningmanager.services.PowerActionService$1.run(PowerActionService.java:121)
01-16 13:38:47.117: W/System.err    (587):  at android.os.Handler.handleCallback(Handler.java:615)
01-16 13:38:47.117: W/System.err    (587):  at android.os.Handler.dispatchMessage(Handler.java:92)
01-16 13:38:47.117: W/System.err    (587):  at android.os.Looper.loop(Looper.java:137)
01-16 13:38:47.117: W/System.err    (587):  at android.app.ActivityThread.main(ActivityThread.java:4949)
01-16 13:38:47.117: W/System.err    (587):  at java.lang.reflect.Method.invokeNative(Native Method)
01-16 13:38:47.117: W/System.err    (587):  at java.lang.reflect.Method.invoke(Method.java:511)
01-16 13:38:47.117: W/System.err    (587):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1043)
01-16 13:38:47.117: W/System.err    (587):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
01-16 13:38:47.117: W/System.err    (587):  at dalvik.system.NativeStart.main(Native Method)
01-16 13:38:47.117: W/System.err    (587): Caused by: java.lang.UnsatisfiedLinkError: Native method not found: com.android.server.pm.LibQmg.qmgOpen:(Ljava/lang/String;)I
01-16 13:38:47.125: W/System.err    (587):  at com.android.server.pm.LibQmg.qmgOpen(Native Method)
01-16 13:38:47.125: W/System.err    (587):  at com.android.server.pm.ShutdownDialog.prepareAnim(ShutdownDialog.java:441)
01-16 13:38:47.125: W/System.err    (587):  at com.android.server.pm.ShutdownDialog.prepareShutdown(ShutdownDialog.java:566)
01-16 13:38:47.125: W/System.err    (587):  at com.android.server.pm.ShutdownThread.beginShutdownSequence(ShutdownThread.java:439)
01-16 13:38:47.125: W/System.err    (587):  at com.android.server.pm.ShutdownThread.shutdownInner(ShutdownThread.java:277)
01-16 13:38:47.125: W/System.err    (587):  at com.android.server.pm.ShutdownThread.shutdown(ShutdownThread.java:166)
01-16 13:38:47.125: W/System.err    (587):  ... 12 more
01-16 13:38:47.125: V/My APP        (587): PowerService: deteniendo

日志以代码中的两个日志注释开始和结束。

接下来是我的明显权限:

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_FRAME_BUFFER" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.REBOOT" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />

我还添加了<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />来删除Permission failure消息,但没有任何区别。

有谁知道这个错误意味着什么,我该如何解决?我知道它与处理QMG文件的库有关(应用程序设计用于三星平板电脑)但除此之外我不知道其他任何事情。

0 个答案:

没有答案