Android手机中第三方签名应用程序无法获得的permission

Android 手机中,有些 permission 并不是在应用程序的mainfest文件中声明就可以获得,它们还和是否是第三方签名及签名的类型有关系。
典型的 android.permission.INSTALL_PACKAGES 除了需要在 mainfest文件中声明,还需要应用程序是系统的Platform签名
今天特意写一测试程序来测试哪些 permission 第三方签名的应用程序获得的。当然有些Android手机,如果把apk应用程序放到 /system/app 的目录下,即使是使用的第三方签名,也能获得相当于 系统的Platform签名的权限。但是这个毕竟是非常规方法,故在这里不在我讨论的范围内。另外由于我的操作失误,可能应为某个 permission 没加入到 mainfest 文件,造成无法通过权限检查。因此测试结果 仅供参考
测试用例1
测试源码TestPermission.java
 
   

package edu . cdut . robin ;
import java . lang . reflect . Field ;
import android . content . Context ;
import android . content . pm . PackageManager ;
import android . util . Log ;
public class TestPermission extends Thread {
final Context context ;
final static String TAG = "robin" ;
TestPermission ( Context context )
{
super ();
this . context = context ;
}
public void run (){
/* 使用getDeclaredFields获取属性*/
Class < android . Manifest . permission > classType = android . Manifest . permission . class ;
Field [] fields = classType . getFields ();
for ( Field f : fields ) {
Object o = null ;
try {
o = f . get ( "" );
} catch ( IllegalArgumentException e ) {
e . printStackTrace ();
} catch ( IllegalAccessException e ) {
e . printStackTrace ();
}
if ( o != null && o instanceof String ){
String permission =( String ) o ;
boolean res =( context . checkCallingOrSelfPermission ( permission )== PackageManager . PERMISSION_GRANTED );
if (! res ){
Log . w ( TAG , permission );
}
}
System . out . println ( f );
}
}
}

mainfest文件中
 
   

android:name = "android.permission.ACCESS_COARSE_LOCATION" />
android:name = "android.permission.ACCESS_CHECKIN_PROPERTIES" />
android:name = "android.permission.ACCESS_FINE_LOCATION" />
android:name = "android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
android:name = "android.permission.ACCESS_MOCK_LOCATION" />
android:name = "android.permission.ACCESS_NETWORK_STATE" />
android:name = "android.permission.ACCESS_SURFACE_FLINGER" />
android:name = "android.permission.ACCESS_WIFI_STATE" />
android:name = "android.permission.ACCOUNT_MANAGER" />
android:name = "android.permission.AUTHENTICATE_ACCOUNTS" />
android:name = "android.permission.BATTERY_STATS" />
android:name = "android.permission.BIND_APPWIDGET" />
android:name = "android.permission.BIND_DEVICE_ADMIN" />
android:name = "android.permission.BIND_INPUT_METHOD" />
android:name = "android.permission.BIND_WALLPAPER" />
android:name = "android.permission.BLUETOOTH" />
android:name = "android.permission.BLUETOOTH_ADMIN" />
android:name = "android.permission.BRICK" />
android:name = "android.permission.BROADCAST_PACKAGE_REMOVED" />
android:name = "android.permission.BROADCAST_SMS" />
android:name = "android.permission.BROADCAST_STICKY" />
android:name = "android.permission.BROADCAST_WAP_PUSH" />
android:name = "android.permission.CALL_PHONE" />
android:name = "android.permission.CALL_PRIVILEGED" />
android:name = "android.permission.CAMERA" />
android:name = "android.permission.CHANGE_COMPONENT_ENABLED_STATE" />
android:name = "android.permission.CHANGE_CONFIGURATION" />
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.CLEAR_APP_CACHE" />
android:name = "android.permission.CLEAR_APP_USER_DATA" />
android:name = "android.permission.CONTROL_LOCATION_UPDATES" />
android:name = "android.permission.DELETE_CACHE_FILES" />
android:name = "android.permission.DELETE_PACKAGES" />
android:name = "android.permission.DEVICE_POWER" />
android:name = "android.permission.DIAGNOSTIC" />
android:name = "android.permission.DISABLE_KEYGUARD" />
android:name = "android.permission.DUMP" />
android:name = "android.permission.EXPAND_STATUS_BAR" />
android:name = "android.permission.FACTORY_TEST" />
android:name = "android.permission.FLASHLIGHT" />
android:name = "android.permission.FORCE_BACK" />
android:name = "android.permission.GET_ACCOUNTS" />
android:name = "android.permission.GET_PACKAGE_SIZE" />
android:name = "android.permission.GET_TASKS" />
android:name = "android.permission.GLOBAL_SEARCH" />
android:name = "android.permission.HARDWARE_TEST" />
android:name = "android.permission.INJECT_EVENTS" />
android:name = "android.permission.INSTALL_LOCATION_PROVIDER" />
android:name = "android.permission.INSTALL_PACKAGES" />
android:name = "android.permission.INTERNAL_SYSTEM_WINDOW" />
android:name = "android.permission.INTERNET" />
android:name = "android.permission.KILL_BACKGROUND_PROCESSES" />
android:name = "android.permission.MANAGE_ACCOUNTS" />
android:name = "android.permission.MANAGE_APP_TOKENS" />
android:name = "android.permission.MASTER_CLEAR" />
android:name = "android.permission.MODIFY_AUDIO_SETTINGS" />
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.PERSISTENT_ACTIVITY" />
android:name = "android.permission.PROCESS_OUTGOING_CALLS" />
android:name = "android.permission.READ_CALENDAR" />
android:name = "android.permission.READ_CONTACTS" />
android:name = "android.permission.READ_FRAME_BUFFER" />
android:name = "com.android.browser.permission.READ_HISTORY_BOOKMARKS" />
android:name = "android.permission.READ_INPUT_STATE" />
android:name = "android.permission.READ_LOGS" />
android:name = "android.permission.READ_OWNER_DATA" />
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.REBOOT" />
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.RESTART_PACKAGES" />
android:name = "android.permission.SEND_SMS" />
android:name = "android.permission.SET_ACTIVITY_WATCHER" />
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_ORIENTATION" />
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.SET_WALLPAPER" />
android:name = "android.permission.SET_WALLPAPER_HINTS" />
android:name = "android.permission.SIGNAL_PERSISTENT_PROCESSES" />
android:name = "android.permission.STATUS_BAR" />
android:name = "android.permission.SUBSCRIBED_FEEDS_READ" />
android:name = "android.permission.SUBSCRIBED_FEEDS_WRITE" />
android:name = "android.permission.SYSTEM_ALERT_WINDOW" />
android:name = "android.permission.UPDATE_DEVICE_STATS" />
android:name = "android.permission.USE_CREDENTIALS" />
android:name = "android.permission.VIBRATE" />
android:name = "android.permission.WAKE_LOCK" />
android:name = "android.permission.WRITE_APN_SETTINGS" />
android:name = "android.permission.WRITE_CALENDAR" />
android:name = "android.permission.WRITE_CONTACTS" />
android:name = "android.permission.WRITE_EXTERNAL_STORAGE" />
android:name = "android.permission.WRITE_GSERVICES" />
android:name = "com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" />
android:name = "android.permission.WRITE_OWNER_DATA" />
android:name = "android.permission.WRITE_SECURE_SETTINGS" />
android:name = "android.permission.WRITE_SETTINGS" />
android:name = "android.permission.WRITE_SMS" />
android:name = "android.permission.WRITE_SYNC_SETTINGS" />

测试结果显示,在 HTC G10 Android2.3.5 )中应用程序使用第三方签名无法获得以下的permission

android.permission.ACCESS_4G_RADIO_DISABLE
android.permission.ACCESS_4G_STATE
android.permission.ACCESS_BLUETOOTH_PRINTER
android.permission.ACCESS_CACHE_FILESYSTEM
android.permission.ACCESS_CHECKIN_PROPERTIES
android.permission.ACCESS_FM_RECEIVER
android.permission.ACCESS_FM_TRANSMITTER
android.permission.ACCESS_SURFACE_FLINGER
android.permission.ACCESS_USBNET_STATE
android.permission.ACCESS_WIMAX_STATE
android.permission.ACCOUNT_MANAGER
android.permission.ASEC_ACCESS
android.permission.ASEC_CREATE
android.permission.ASEC_DESTROY
android.permission.ASEC_MOUNT_UNMOUNT
android.permission.ASEC_RENAME
android.permission.BACKUP
android.permission.BIND_APPWIDGET
android.permission.BIND_DEVICE_ADMIN
android.permission.BIND_INPUT_METHOD
android.permission.BIND_WALLPAPER
android.permission.BRICK
android.permission.BROADCAST_PACKAGE_REMOVED
android.permission.BROADCAST_SMS
android.permission.BROADCAST_WAP_PUSH
android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE
android.permission.CALL_PRIVILEGED
android.permission.CHANGE_4G_STATE
android.permission.CHANGE_BACKGROUND_DATA_SETTING
android.permission.CHANGE_COMPONENT_ENABLED_STATE
android.permission.CHANGE_USBNET_STATE
android.permission.CHANGE_WIMAX_STATE
android.permission.CLEAR_APP_USER_DATA
android.permission.CONTROL_LOCATION_UPDATES
android.permission.COPY_PROTECTED_DATA
android.permission.DELETE_CACHE_FILES
android.permission.DELETE_PACKAGES
android.permission.DEVICE_POWER
android.permission.DIAGNOSTIC
android.permission.DUMP
android.permission.FACTORY_TEST
ti.permission.FMRX
ti.permission.FMRX_ADMIN
android.permission.FORCE_BACK
android.permission.FORCE_STOP_PACKAGES
android.permission.GLOBAL_SEARCH
android.permission.GLOBAL_SEARCH_CONTROL
android.permission.HARDWARE_TEST
android.permission.INITIATE_4G_SCAN
android.permission.INITIATE_4G_SCAN_DATA_SERVICE_DISRUPTIVE
android.permission.INJECT_EVENTS
android.permission.INSTALL_LOCATION_PROVIDER
android.permission.INSTALL_PACKAGES
android.permission.INTERNAL_SYSTEM_WINDOW
android.permission.MANAGE_APP_TOKENS
android.permission.MANAGE_USB
android.permission.MASTER_CLEAR
android.permission.MODIFY_PHONE_STATE
android.permission.MOVE_PACKAGE
android.permission.NET_ADMIN
android.permission.NET_RAW
android.permission.NFC
android.permission.PACKAGE_USAGE_STATS
android.permission.PERFORM_CDMA_PROVISIONING
android.permission.READ_FRAME_BUFFER
android.permission.READ_INPUT_STATE
android.permission.READ_USER_DICTIONARY
android.permission.REBOOT
android.permission.RECEIVE_EMERGENCY_BROADCAST
android.permission.SET_ACTIVITY_WATCHER
com.android.alarm.permission.SET_ALARM
android.permission.SET_ORIENTATION
android.permission.SET_PREFERRED_APPLICATIONS
android.permission.SET_TIME
android.permission.SET_WALLPAPER_COMPONENT
android.permission.SHUTDOWN
android.permission.STATUS_BAR
android.permission.STATUS_BAR_SERVICE
android.permission.STOP_APP_SWITCHES
android.permission.UPDATE_DEVICE_STATS
android.permission.USE_SIP
android.permission.VPN
android.permission.WRITE_GSERVICES
android.permission.WRITE_SECURE_SETTINGS
android.permission.WRITE_USER_DICTIONARY

测试结果显示,在Lenovo A820(Android 4.1.2中应用程序使用第三方签名无法获得以下的permission

android.permission.ACCESS_CACHE_FILESYSTEM
android.permission.ACCESS_CHECKIN_PROPERTIES
android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY
android.permission.ACCESS_MTK_MMHW
android.permission.ACCESS_MTP
android.permission.ACCESS_SURFACE_FLINGER
android.permission.ACCESS_WIMAX_STATE
android.permission.ACCOUNT_MANAGER
com.android.voicemail.permission.ADD_VOICEMAIL
android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK
android.permission.ASEC_ACCESS
android.permission.ASEC_CREATE
android.permission.ASEC_DESTROY
android.permission.ASEC_MOUNT_UNMOUNT
android.permission.ASEC_RENAME
android.permission.BACKUP
android.permission.BIND_ACCESSIBILITY_SERVICE
android.permission.BIND_APPWIDGET
android.permission.BIND_DEVICE_ADMIN
android.permission.BIND_INPUT_METHOD
android.permission.BIND_PACKAGE_VERIFIER
android.permission.BIND_REMOTEVIEWS
android.permission.BIND_TEXT_SERVICE
android.permission.BIND_VPN_SERVICE
android.permission.BIND_WALLPAPER
android.permission.BRICK
android.permission.BROADCAST_PACKAGE_REMOVED
android.permission.BROADCAST_SMS
android.permission.BROADCAST_WAP_PUSH
android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE
android.permission.CALL_PRIVILEGED
android.permission.CHANGE_BACKGROUND_DATA_SETTING
android.permission.CHANGE_COMPONENT_ENABLED_STATE
android.permission.CHANGE_WIMAX_STATE
android.permission.CLEAR_APP_USER_DATA
android.permission.CONFIRM_FULL_BACKUP
android.permission.CONNECTIVITY_INTERNAL
android.permission.CONTROL_LOCATION_UPDATES
android.permission.COPY_PROTECTED_DATA
android.permission.CRYPT_KEEPER
android.permission.DELETE_CACHE_FILES
android.permission.DELETE_PACKAGES
android.permission.DEVICE_POWER
android.permission.DIAGNOSTIC
android.permission.DUMP
android.permission.FACTORY_TEST
android.permission.FORCE_BACK
android.permission.FORCE_STOP_PACKAGES
android.permission.GET_DETAILED_TASKS
android.permission.GLOBAL_SEARCH
android.permission.GLOBAL_SEARCH_CONTROL
android.permission.GRANT_REVOKE_PERMISSIONS
android.permission.HARDWARE_TEST
android.permission.INJECT_EVENTS
android.permission.INSTALL_LOCATION_PROVIDER
android.permission.INSTALL_PACKAGES
android.permission.INTERNAL_SYSTEM_WINDOW
android.permission.MANAGE_APP_TOKENS
android.permission.MANAGE_NETWORK_POLICY
android.permission.MANAGE_USB
android.permission.MASTER_CLEAR
android.permission.MODIFY_APPWIDGET_BIND_PERMISSIONS
android.permission.MODIFY_NETWORK_ACCOUNTING
android.permission.MODIFY_PHONE_STATE
android.permission.MOVE_PACKAGE
android.permission.NET_ADMIN
android.permission.NFC
android.permission.PACKAGE_USAGE_STATS
android.permission.PACKAGE_VERIFICATION_AGENT
android.permission.PERFORM_CDMA_PROVISIONING
android.permission.READ_CELL_BROADCASTS
android.permission.READ_FRAME_BUFFER
android.permission.READ_INPUT_STATE
android.permission.READ_LOGS
android.permission.READ_NETWORK_USAGE_HISTORY
android.permission.READ_PRIVILEGED_PHONE_STATE
android.permission.READ_PROFILE
android.permission.READ_SOCIAL_STREAM
android.permission.READ_USER_DICTIONARY
android.permission.REBOOT
android.permission.RECEIVE_EMERGENCY_BROADCAST
android.permission.REMOTE_AUDIO_PLAYBACK
android.permission.REMOVE_TASKS
android.permission.RETRIEVE_WINDOW_CONTENT
android.permission.SEND_SMS_NO_CONFIRMATION
android.permission.SERIAL_PORT
android.permission.SET_ACTIVITY_WATCHER
com.android.alarm.permission.SET_ALARM
android.permission.SET_ALWAYS_FINISH
android.permission.SET_ANIMATION_SCALE
android.permission.SET_DEBUG_APP
android.permission.SET_KEYBOARD_LAYOUT
android.permission.SET_ORIENTATION
android.permission.SET_POINTER_SPEED
android.permission.SET_PREFERRED_APPLICATIONS
android.permission.SET_PROCESS_LIMIT
android.permission.SET_SCREEN_COMPATIBILITY
android.permission.SET_TIME
android.permission.SET_WALLPAPER_COMPONENT
android.permission.SHUTDOWN
android.permission.SIGNAL_PERSISTENT_PROCESSES
android.permission.START_ANY_ACTIVITY
android.permission.STATUS_BAR
android.permission.STATUS_BAR_SERVICE
android.permission.STOP_APP_SWITCHES
android.permission.UPDATE_DEVICE_STATS
android.permission.UPDATE_LOCK
android.permission.USE_SIP
android.permission.WRITE_APN_SETTINGS
android.permission.WRITE_GSERVICES
android.permission.WRITE_MEDIA_STORAGE
android.permission.WRITE_PROFILE
android.permission.WRITE_SECURE_SETTINGS
android.permission.WRITE_SOCIAL_STREAM
android.permission.WRITE_USER_DICTIONARY
结束!

你可能感兴趣的:(移动开发,java,测试)