1. 程式人生 > >360外掛化框架整合填坑

360外掛化框架整合填坑

在整合框架是一定記住新增相應的許可權,官方文件沒有提到這個。在demo 中需要以下幾個許可權

	<!-- SDK Only (4Stats)。也是“常用的”幾個許可權 -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />

其中有意思的是,我工程裡沒有

<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />

這個許可權也報錯。報錯還挺有意思,僅第一次啟動外掛的時候才報錯,主程式崩潰,再次點選主程式再次啟動外掛程式居然不會報錯了。查了查日誌提示

問題:

11-19 14:03:47.183 30411-30411/com.xxxxx.xxxxxx E/CrashFile: 錯誤CrashTime=2018-11-19 14:03:47.172
    BOARD=EVA-AL00
    CPU_ABI2=armeabi
    HOST=wuhjk0387cna
    versionName=v2.2.1
    IS_TREBLE_ENABLED=true
    SUPPORTED_64_BIT_ABIS=[Ljava.lang.String;@8107aab
    CPU_ABI=armeabi-v7a
    PERMISSIONS_REVIEW_REQUIRED=false
    IS_USERDEBUG=false
    DISPLAY=EVA-AL00 8.0.0.535(C00)
    SUPPORTED_ABIS=[Ljava.lang.String;@fa68508
    FINGERPRINT=HUAWEI/EVA-AL00/HWEVA:8.0.0/HUAWEIEVA-AL00/535(C00):user/release-keys
    PRODUCT=EVA-AL00
    HIDE_PRODUCT_INFO=false
    ID=HUAWEIEVA-AL00
    replacements=[Ljava.lang.String;@a3f76c6
    TYPE=user
    SERIAL=PBV0216B01002150
    NO_HOTA=false
    IS_CONTAINER=false
    IS_ENG=false
    DEVICE=HWEVA
    TIME=1537190797000
    IS_USER=true
    MODEL=EVA-AL00
    MANUFACTURER=HUAWEI
    USER=test
    versionCode=25
    BRAND=HUAWEI
    SUPPORTED_32_BIT_ABIS=[Ljava.lang.String;@b2604fa
    matchers=[Ljava.lang.String;@29f44a1
    HARDWARE=hi3650
    IS_DEBUGGABLE=false
    BOOTLOADER=unknown
    RADIO=unknown
    TAG=Build
    UNKNOWN=unknown
    IS_EMULATOR=false
    TAGS=release-keys
    java.lang.SecurityException: no permission to read the sync settings: Neither user 10401 nor current process has android.permission.READ_SYNC_SETTINGS.
        at android.os.Parcel.readException(Parcel.java:1946)
        at android.os.Parcel.readException(Parcel.java:1892)
        at android.content.IContentService$Stub$Proxy.getMasterSyncAutomatically(IContentService.java:1302)
        at android.content.ContentResolver.getMasterSyncAutomatically(ContentResolver.java:2637)
        at com.fsck.k9.service.MailService.startService(MailService.java:95)
        at com.fsck.k9.service.CoreService.onStartCommand(CoreService.java:245)
        at com.qihoo360.replugin.component.service.server.PluginServiceServer$1.handleMessage(PluginServiceServer.java:110)
        at android.os.Handler.dispatchMessage(Handler.java:108)
        at android.os.Looper.loop(Looper.java:166)
        at android.app.ActivityThread.main(ActivityThread.java:7425)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)

解決:

新增相應的許可權

<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />