当前位置: 代码迷 >> Android >> Android手机中第三方签字应用程序无法获得的permission
  详细解决方案

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

热度:114   发布时间:2016-05-01 12:06:50.0
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文件中

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.ACCOUNT_MANAGER"/>
    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
    <uses-permission android:name="android.permission.BATTERY_STATS"/>
    <uses-permission android:name="android.permission.BIND_APPWIDGET"/>
    <uses-permission android:name="android.permission.BIND_DEVICE_ADMIN"/>
    <uses-permission android:name="android.permission.BIND_INPUT_METHOD"/>
    <uses-permission android:name="android.permission.BIND_WALLPAPER"/>
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <uses-permission android:name="android.permission.BRICK"/>
    <uses-permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED"/>
    <uses-permission android:name="android.permission.BROADCAST_SMS"/>
    <uses-permission android:name="android.permission.BROADCAST_STICKY"/>
    <uses-permission android:name="android.permission.BROADCAST_WAP_PUSH"/>
    <uses-permission android:name="android.permission.CALL_PHONE"/>
    <uses-permission android:name="android.permission.CALL_PRIVILEGED"/>
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/>
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
    <uses-permission android:name="android.permission.CLEAR_APP_CACHE"/>
    <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA"/>
    <uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES"/>
    <uses-permission android:name="android.permission.DELETE_CACHE_FILES"/>
    <uses-permission android:name="android.permission.DELETE_PACKAGES"/>
    <uses-permission android:name="android.permission.DEVICE_POWER"/>
    <uses-permission android:name="android.permission.DIAGNOSTIC"/>
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
    <uses-permission android:name="android.permission.DUMP"/>
    <uses-permission android:name="android.permission.EXPAND_STATUS_BAR"/>
    <uses-permission android:name="android.permission.FACTORY_TEST"/>
    <uses-permission android:name="android.permission.FLASHLIGHT"/>
    <uses-permission android:name="android.permission.FORCE_BACK"/>
    <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
    <uses-permission android:name="android.permission.GET_PACKAGE_SIZE"/>
    <uses-permission android:name="android.permission.GET_TASKS"/>
    <uses-permission android:name="android.permission.GLOBAL_SEARCH"/>
    <uses-permission android:name="android.permission.HARDWARE_TEST"/>
    <uses-permission android:name="android.permission.INJECT_EVENTS"/>
    <uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER"/>
    <uses-permission android:name="android.permission.INSTALL_PACKAGES"/>
    <uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
    <uses-permission android:name="android.permission.MANAGE_APP_TOKENS"/>
    <uses-permission android:name="android.permission.MASTER_CLEAR"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
    <uses-permission android:name="android.permission.MODIFY_PHONE_STATE"/>
    <uses-permission android:name="android.permission.MOUNT_FORMAT_FILESYSTEMS"/>
    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
    <uses-permission android:name="android.permission.PERSISTENT_ACTIVITY"/>
    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
    <uses-permission android:name="android.permission.READ_CALENDAR"/>
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.READ_FRAME_BUFFER"/>
    <uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
    <uses-permission android:name="android.permission.READ_INPUT_STATE"/>
    <uses-permission android:name="android.permission.READ_LOGS"/>
    <uses-permission android:name="android.permission.READ_OWNER_DATA"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.READ_SMS"/>
    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
    <uses-permission android:name="android.permission.READ_SYNC_STATS"/>
    <uses-permission android:name="android.permission.REBOOT"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.RECEIVE_MMS"/>
    <uses-permission android:name="android.permission.RECEIVE_SMS"/>
    <uses-permission android:name="android.permission.RECEIVE_WAP_PUSH"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.REORDER_TASKS"/>
    <uses-permission android:name="android.permission.RESTART_PACKAGES"/>
    <uses-permission android:name="android.permission.SEND_SMS"/>
    <uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER"/>
    <uses-permission android:name="android.permission.SET_ALWAYS_FINISH"/>
    <uses-permission android:name="android.permission.SET_ANIMATION_SCALE"/>
    <uses-permission android:name="android.permission.SET_DEBUG_APP"/>
    <uses-permission android:name="android.permission.SET_ORIENTATION"/>
    <uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS"/>
    <uses-permission android:name="android.permission.SET_PROCESS_LIMIT"/>
    <uses-permission android:name="android.permission.SET_TIME"/>
    <uses-permission android:name="android.permission.SET_TIME_ZONE"/>
    <uses-permission android:name="android.permission.SET_WALLPAPER"/>
    <uses-permission android:name="android.permission.SET_WALLPAPER_HINTS"/>
    <uses-permission android:name="android.permission.SIGNAL_PERSISTENT_PROCESSES"/>
    <uses-permission android:name="android.permission.STATUS_BAR"/>
    <uses-permission android:name="android.permission.SUBSCRIBED_FEEDS_READ"/>
    <uses-permission android:name="android.permission.SUBSCRIBED_FEEDS_WRITE"/>
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS"/>
    <uses-permission android:name="android.permission.USE_CREDENTIALS"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.WRITE_APN_SETTINGS"/>
    <uses-permission android:name="android.permission.WRITE_CALENDAR"/>
    <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_GSERVICES"/>
    <uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"/>
    <uses-permission android:name="android.permission.WRITE_OWNER_DATA"/>
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
    <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
    <uses-permission android:name="android.permission.WRITE_SMS"/>
    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>

测试结果显示,在HTC G10Android2.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
结束!
  相关解决方案