我正在使用有根设备。我创建了一个应用程序作为系统应用程序运行。在以 su 用户身份从 adb shell 挂载 /system 目录后,我已将 apk 文件复制到 sd 卡,然后复制到 /system/priv-app。清单文件如下所示
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="abc.def.settings"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_APN_SETTINGS" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.WRITE_CALL_LOG" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.STATUS_BAR" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<service
android:name="abc.def.settings.service.SystemSettingsService" >
</service>
<receiver android:name="abc.def.settings.boot.DeviceBootReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="abc.def.settings.start_after_reinstall"/>
</intent-filter>
</receiver>
</application>
</manifest>
将 apk 复制到 /system/priv-app 后,我将权限从 shell 更改为 777。该应用程序在设备启动时启动得非常好。但我无法在重新启动之前启动服务。我的限制之一是不应重新启动设备以启动此服务。
我尝试了以下方法,但都没有奏效。
adb shell am startservice -n abc.def.settings/.SystemSettingsService
adb shell am startservice -n abc.def.settings/.service.SystemSettingsService
adb shell am startservice -a abc.def.settings.start_after_reinstall
adb shell am broadcast -a abc.def.settings.start_after_reinstall
adb shell am broadcast -a abc.def.settings.start_after_reinstall -f 32
有什么我想念的吗?!提前致谢。