Android Things中如果使用传统的Intent来安装APK,你将永远安装不上
常见的应用内APK安装方法有以下两种方法
1.Intent安装APK的方法如下:
Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); Uri contentUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".fileProvider", new File(path + "app-debug.apk")); intent.setDataAndType(contentUri, "application/vnd.android.package-archive"); startActivity(intent); |
同时添加权限:
2.通过install命令来安装
命令如下:
pm install -i 当前包名 --user 0 XX.apk |
运行方法:
Runtime.getRuntime().exec("") |
注意:以上两种方法在android 手机中没有问题,但截止目前在Android Things 1.0.1中是行不通的
为了能在Android Things系统中更新APP,故经过不断的探索发现,最终采用插件化的方案来解决此问题
经过评估测试,最终发现360出品的RePlugin框架满足我们的需求
https://github.com/Qihoo360/RePlugin |
在RePlugin壳子中,必须申请完所有权限,因为壳子是不会更新的。我整理了所有的权限,在下面列出来
android:name="com.google.android.things.permission.MANAGE_BLUETOOTH" />
android:name="com.google.android.things.permission.PERFORM_UPDATE_NOW" />
android:name="com.google.android.things.permission.USE_PERIPHERAL_IO" />
android:name="com.google.android.things.permission.SET_TIME" />
android:name="com.google.android.things.permission.REBOOT" />
android:name="andriod.permission.ACCESS_CHECKIN_PROPERTIES">
android:name="android.permission.ACCESS_COARSE_LOCATION" />
android:name="android.permission.ACCESS_FINE_LOCATION"/>
android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
android:name="android.permission.ACCESS_NETWORK_STATE"/>
android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
android:name="android.permission.ACCESS_WIFI_STATE"/>
android:name="android.permission.ADD_VOICEMAIL"/>
android:name="android.permission.BLUETOOTH"/>
android:name="android.permission.BLUETOOTH_ADMIN"/>
android:name="android.permission.BODY_SENSORS"/>
android:name="android.permission.BROADCAST_STICKY"/>
android:name="android.permission.CALL_PHONE"/>
android:name="android.permission.CAMERA"/>
android:name="android.permission.CHANGE_NETWORK_STATE"/>
android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
android:name="android.permission.CHANGE_WIFI_STATE"/>
android:name="android.permission.DISABLE_KEYGUARD">
android:name="android.permission.EXPAND_STATUS_BAR">
android:name="android.permission.GET_ACCOUNTS"/>
android:name="android.permission.GET_PACKAGE_SIZE"/>
android:name="android.permission.GET_TASKS"/>
android:name="android.permission.INSTALL_SHORTCUT"/>
android:name="android.permission.INTERNET"/>
android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
android:name="android.permission.NFC">
android:name="android.permission.PERSISTENT_ACTIVITY">
android:name="android.permission.PROCESS_OUTGOING_CALLS">
android:name="android.permission.READ_CALENDAR"/>
android:name="android.permission.READ_CALL_LOG"/>
android:name="android.permission.READ_CONTACTS"/>
android:name="android.permission.READ_EXTERNAL_STORAGE"/>
android:name="android.permission.READ_PHONE_STATE"/>
android:name="android.permission.READ_SMS"/>
android:name="android.permission.READ_SYNC_SETTINGS"/>
android:name="android.permission.READ_SYNC_STATS"/>
android:name="android.permission.READ_VOICEMAIL"/>
android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
android:name="android.permission.RECEIVE_MMS"/>
android:name="android.permission.RECEIVE_SMS"/>
android:name="android.permission.RECEIVE_WAP_PUSH"/>
android:name="android.permission.RECORD_AUDIO"/>
android:name="android.permission.REORDER_TASKS"/>
android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
android:name="android.permission.RESTART_PACKAGES"/>
android:name="android.permission.SEND_SMS"/>
android:name="android.permission.SET_ALARM"/>
android:name="android.permission.SET_WALLPAPER"/>
android:name="android.permission.SET_WALLPAPER_HINTS"/>
android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
android:name="android.permission.TRANSMIT_IR"/>
android:name="android.permission.UNINSTALL_SHORTCUT"/>
android:name="android.permission.USE_FINGERPRINT"/>
android:name="android.permission.USE_SIP"/>
android:name="android.permission.VIBRATE"/>
android:name="android.permission.WAKE_LOCK"/>
android:name="android.permission.WRITE_CALENDAR"/>
android:name="android.permission.WRITE_CALL_LOG"/>
android:name="android.permission.WRITE_CONTACTS"/>
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
android:name="android.permission.WRITE_SYNC_SETTINGS"/>
android:name="android.permission.WRITE_VOICEMAIL"/>
android:name="android.permission.ACCOUNT_MANAGER"/>
android:name="android.permission.BATTERY_STATS"/>
android:name="android.permission.BIND_ACCESSIBILITY_SERVICE"/>
android:name="android.permission.BIND_CARRIER_MESSAGING_SERVICE"/>
android:name="android.permission.BIND_CARRIER_SERVICES"/>
android:name="android.permission.BIND_CHOOSER_TARGET_SERVICE"/>
android:name="android.permission.BIND_DEVICE_ADMIN"/>
android:name="android.permission.BIND_CONDITION_PROVIDER_SERVICE"/>
android:name="android.permission.BIND_DREAM_SERVICE"/>
android:name="android.permission.BIND_INCALL_SERVICE"/>
android:name="android.permission.BIND_INPUT_METHOD"/>
android:name="android.permission.BIND_MIDI_DEVICE_SERVICE"/>
android:name="android.permission.BIND_NFC_SERVICE"/>
android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
android:name="android.permission.BIND_PRINT_SERVICE"/>
android:name="android.permission.BIND_QUICK_SETTINGS_TILE"/>
android:name="android.permission.BIND_REMOTEVIEWS"/>
android:name="android.permission.BIND_SCREENING_SERVICE"/>
android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE"/>
android:name="android.permission.BIND_TEXT_SERVICE">
android:name="android.permission.BIND_TV_INPUT">
android:name="android.permission.BIND_VOICE_INTERACTION">
android:name="android.permission.BIND_VPN_SERVICE">
android:name="android.permission.BIND_VR_LISTENER_SERVICE"/>
android:name="android.permission.BIND_WALLPAPER"/>
android:name="android.permission.BLUETOOTH_PRIVILEGED"/>
android:name="android.permission.BROADCAST_PACKAGE_REMOVED"/>
android:name="android.permission.BROADCAST_SMS"/>
android:name="android.permission.BROADCAST_WAP_PUSH"/>
android:name="android.permission.CALL_PRIVILEGED"/>
android:name="android.permission.CAPTURE_AUDIO_OUTPUT"/>
android:name="android.permission.CAPTURE_SECURE_VIDEO_OUTPUT"/>
android:name="android.permission.CAPTURE_VIDEO_OUTPUT"/>
android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>
android:name="android.permission.CHANGE_CONFIGURATION"/>
android:name="android.permission.CLEAR_APP_CACHE"/>
android:name="android.permission.CONTROL_LOCATION_UPDATES"/>
android:name="android.permission.DELETE_CACHE_FILES"/>
android:name="android.permission.DELETE_PACKAGES"/>
android:name="android.permission.DIAGNOSTIC"/>
android:name="android.permission.DUMP">
android:name="android.permission.FACTORY_TEST">
android:name="android.permission.GET_ACCOUNTS_PRIVILEGED"/>
android:name="android.permission.GLOBAL_SEARCH"/>
android:name="android.permission.INSTALL_LOCATION_PROVIDER"/>
android:name="android.permission.INSTALL_PACKAGES"/>
android:name="android.permission.LOCATION_HARDWARE"/>
android:name="android.permission.MANAGE_DOCUMENTS"/>
android:name="android.permission.MASTER_CLEAR"/>
android:name="android.permission.MEDIA_CONTENT_CONTROL"/>
android:name="android.permission.MODIFY_PHONE_STATE"/>
android:name="android.permission.MOUNT_FORMAT_FILESYSTEMS"/>
android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
android:name="android.permission.PACKAGE_USAGE_STATS">
android:name="android.permission.READ_FRAME_BUFFER"/>
android:name="android.permission.READ_INPUT_STATE"/>
android:name="android.permission.READ_LOGS"/>
android:name="android.permission.REBOOT"/>
android:name="android.permission.SEND_RESPOND_VIA_MESSAGE"/>
android:name="android.permission.SET_ALWAYS_FINISH"/>
android:name="android.permission.SET_ANIMATION_SCALE"/>
android:name="android.permission.SET_DEBUG_APP"/>
android:name="android.permission.SET_PREFERRED_APPLICATIONS">
android:name="android.permission.SET_PROCESS_LIMIT">
android:name="android.permission.SET_TIME">
android:name="android.permission.SET_TIME_ZONE">
android:name="android.permission.SIGNAL_PERSISTENT_PROCESSES"/>
|