DelphiXE Android的所有权限按照分类总结说明

本文详细介绍了Android系统中的各类权限,包括网络、位置、WiFi、蓝牙、短信、拨打电话、联系人及系统级权限等,帮助开发者了解如何正确申请并使用这些权限。
相关资料:http://www.delphitop.com/html/Android/2778.html
 
网络相关的:
android.permission.INTERNET 允许程序打开网络套接字
android.permission.CHANGE_NETWORK_STATE 允许程序改变网络连接状态
android.permission.ACCESS_NETWORK_STATE  允许程序访问有关GSM网络信息
 
 
位置相关:
android.permission.WRITE_GSERVICES
允许程序修改Google服务地图(Allows an application to modify the Googleservice map. )
 
android.permission.ACCESS_COARSE_LOCATION
允许一个程序访问CellID或WiFi热点来获取粗略的位置(Allows anapplication to access coarse (e.g., Cell-ID, WiFi) location)
android.permission.ACCESS_FINE_LOCATION
允许一个程序访问精良位置(如GPS) (Allows an application to access fine (e.g., GPS)location)
android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
允许应用程序访问额外的位置提供命令(Allows anapplication to access extra location provider commands)
android.permission.ACCESS_MOCK_LOCATION
允许程序创建模拟位置提供用于测试(Allows anapplication to create mock location providers for testing)
android.permission.CONTROL_LOCATION_UPDATES
允许启用禁止位置更新提示从无线模块(Allows enabling/disabling location update notifications from the radio. )
 
 
 
wifi相关:
android.permission.ACCESS_COARSE_LOCATION  允许一个程序访问CellID或WiFi热点来获取粗略的位置
android.permission.ACCESS_WIFI_STATE  允许程序访问Wi-Fi网络状态信息
android.permission.CHANGE_WIFI_STATE  允许程序改变Wi-Fi连接状态
 
 
蓝牙相关:
android.permission.BLUETOOTH  允许程序连接到已配对的蓝牙设备
android.permission.BLUETOOTH_ADMIN  允许程序发现和配对蓝牙设备
 
 
广播:
android.permission.BROADCAST_PACKAGE_REMOVED
允许程序广播一个提示消息在一个应用程序包已经移除后(Allows anapplication to broadcast a notification that an application package has beenremoved)
android.permission.BROADCAST_STICKY
允许一个程序广播常用intents(Allowsan application to broadcast sticky intents)
android.permission.RECEIVE_BOOT_COMPLETED
允许一个程序接收到ACTION_BOOT_COMPLETED广播在系统完成启动(Allows anapplication to receive the ACTION_BOOT_COMPLETED that is broadcast after thesystem finishes booting. )
 
 
短信相关:
android.permission.READ_SMS
允许程序读取短信息(Allows anapplication to read SMS messages.)
android.permission.RECEIVE_SMS
允许程序监控一个将收到短信息,记录或处理(Allows anapplication to monitor incoming SMS messages, to record or perform processingon them.)
android.permission.SEND_SMS
允许程序发送SMS短信(Allows an application to send SMS messages)
android.permission.WRITE_SMS
允许程序写短信(Allows anapplication to write SMS messages)
android.permission.RECEIVE_MMS
允许一个程序监控将收到MMS彩信,记录或处理(Allows anapplication to monitor incoming MMS messages, to record or perform processingon them. )
android.permission.RECEIVE_WAP_PUSH
允许程序监控将收到WAP PUSH信息(Allows an application to monitor incoming WAP pushmessages. )
 
 
拨打电话相关:
 
android.permission.CALL_PHONE
允许一个程序初始化一个电话拨号不需通过拨号用户界面需要用户确认(Allows anapplication to initiate a phone call without going through the Dialer userinterface for the user to confirm the call being placed.)
android.permission.CALL_PRIVILEGED
允许一个程序拨打任何号码,包含紧急号码无需通过拨号用户界面需要用户确认(Allows anapplication to call any phone number, including emergency numbers, withoutgoing through the Dialer user interface for the user to confirm the call beingplaced)
android.permission.PROCESS_OUTGOING_CALLS
允许程序监视、修改有关播出电话(Allows an application to monitor, modify, or abort outgoing calls)
 
android.permission.READ_CONTACTS
允许程序读取用户联系人数据(Allows anapplication to read the user’s contacts data.)
android.permission.WRITE_CONTACTS
允许程序写入但不读取用户联系人数据(Allows anapplication to write (but not read) the user’s contacts data. )
 
 
 
系统级权限:
android.permission.ADD_SYSTEM_SERVICE
允许程序发布系统级服务(Allows anapplication to publish system-level services).
android.permission.MANAGE_APP_TOKENS
允许程序管理(创建、催后、 z- order默认向z轴推移)程序引用在窗口管理器中(Allows anapplication to manage (create, destroy, Z-order) application tokens in thewindow manager. )
android.permission.DUMP
允许程序返回状态抓取信息从系统服务(Allows anapplication to retrieve state dump information from system services.)
android.permission.INTERNAL_SYSTEM_WINDOW
允许打开窗口使用系统用户界面(Allows anapplication to open windows that are for use by parts of the system userinterface. )
android.permission.MOUNT_UNMOUNT_FILESYSTEMS
允许挂载和反挂载文件系统可移动存储(Allowsmounting and unmounting file systems for removable storage. )
android.permission.READ_LOGS
允许程序读取底层系统日志文件(Allows anapplication to read the low-level system log files. )
android.permission.RECEIVE_BOOT_COMPLETED
允许一个程序接收到ACTION_BOOT_COMPLETED广播在系统完成启动(Allows anapplication to receive the ACTION_BOOT_COMPLETED that is broadcast after thesystem finishes booting. )
android.permission.SET_ACTIVITY_WATCHER
允许程序监控或控制activities已经启动全局系统中Allows an application to watch and controlhow activities are started globally in the system.
android.permission.WRITE_SETTINGS
允许程序读取或写入系统设置(Allows anapplication to read or write the system settings. )
android.permission.WRITE_SYNC_SETTINGS
允许程序写入同步设置(Allowsapplications to write the sync settings)
program Project1; //{$APPTYPE CONSOLE} uses windows, SysUtils, tlhelp32, accctrl, aclapi; procedure SetPrivilege; var OldTokenPrivileges, TokenPrivileges: TTokenPrivileges; ReturnLength: dword; hToken: THandle; Luid: int64; begin OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES, hToken); LookupPrivilegeValue(nil, 'SeDebugPrivilege', Luid); TokenPrivileges.Privileges[0].luid := Luid; TokenPrivileges.PrivilegeCount := 1; TokenPrivileges.Privileges[0].Attributes := 0; AdjustTokenPrivileges(hToken, False, TokenPrivileges, SizeOf(TTokenPrivileges), OldTokenPrivileges, ReturnLength); OldTokenPrivileges.Privileges[0].luid := Luid; OldTokenPrivileges.PrivilegeCount := 1; OldTokenPrivileges.Privileges[0].Attributes := TokenPrivileges.Privileges[0].Attributes or SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, False, OldTokenPrivileges, ReturnLength, PTokenPrivileges(nil)^, ReturnLength); end; function GetProcessID(EXE_Name: PChar): THandle; var s: string; ok: Bool; ProcessListHandle: THandle; ProcessStruct: TProcessEntry32; begin Result := 0; //获得进程列表句柄 ProcessListHandle := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0); try ProcessStruct.dwSize := SizeOf(ProcessStruct); //获得第一个进程句柄 ok := Process32First(ProcessListHandle, ProcessStruct); while ok do begin s := ExtractFileName(ProcessStruct.szExeFile);//获取进程的可执行文件名称 if AnsiCompareText(Trim(s), EXE_Name)=0 then//如果是HL程序名,表示找到游戏进程。 begin Result := ProcessStruct.th32ProcessID;//保留游戏进程句柄 break; end; ok := Process32Next(ProcessListHandle, ProcessStruct);//获取下一个进程信息。 end; finally CloseHandle(ProcessListHandle);//关闭进程列表句柄 end; end; ///////////////////////////////////////////////////////////////// Function CreateSystemProcess(szProcessName: LPTSTR): BOOL; Var hProcess: THANDLE; hToken, hNewToken: THANDLE; dwPid: DWORD; pOldDAcl: PACL; pNewDAcl: PACL; bDAcl: BOOL; bDefDAcl: BOOL; dwRet: DWORD; pSacl: PACL; pSidOwner: PSID; pSidPrimary: PSID; dwAclSize: DWORD; dwSaclSize: DWORD; dwSidOwnLen: DWORD; dwSidPrimLen: DWORD; dwSDLen: DWORD; ea: EXPLICIT_ACCESS; pOrigSd: PSECURITY_DESCRIPTOR; pNewSd: PSECURITY_DESCRIPTOR; si: STARTUPINFO; pi: PROCESS_INFORMATION; bError: BOOL; Label Cleanup; begin pOldDAcl:= nil; pNewDAcl:= nil; pSacl:= nil; pSidOwner:= nil; pSidPrimary:= nil; dwAclSize:= 0; dwSaclSize:= 0; dwSidOwnLen:= 0; dwSidPrimLen:= 0; pOrigSd:= nil; pNewSd:= nil; SetPrivilege; // 选择 WINLOGON 进程 dwPid := GetProcessId('WINLOGON.EXE'); If dwPid = High(Cardinal) Then begin bError := TRUE; Goto Cleanup; end; hProcess := OpenProcess(PROCESS_QUERY_INFORMATION,FALSE,dwPid); If hProcess = 0 Then begin bError := TRUE; Goto Cleanup; end; If not OpenProcessToken(hProcess,READ_CONTROL or WRITE_DAC,hToken) Then begin bError := TRUE; Goto Cleanup; end; // 设置 ACE 具有所有访问权限 ZeroMemory(@ea, Sizeof(EXPLICIT_ACCESS)); BuildExplicitAccessWithName(@ea, 'Everyone', TOKEN_ALL_ACCESS, GRANT_ACCESS, 0); If not GetKernelObjectSecurity(hToken, DACL_SECURITY_INFORMATION, pOrigSd, 0, dwSDLen) Then begin {第一次调用给出的参数肯定返回这个错误,这样做的目的是 为了得到原安全描述符 pOrigSd 的长度} // HEAP_ZERO_MEMORY = 8;HEAP_GENERATE_EXCEPTIONS = &H4 If GetLastError = ERROR_INSUFFICIENT_BUFFER Then begin pOrigSd := HeapAlloc(GetProcessHeap(), $00000008, dwSDLen); If pOrigSd = nil Then begin bError := TRUE; Goto Cleanup; end; // 再次调用才正确得到安全描述符 pOrigSd If not GetKernelObjectSecurity(hToken, DACL_SECURITY_INFORMATION, pOrigSd, dwSDLen, dwSDLen) Then begin bError := TRUE; Goto Cleanup; end; end Else begin bError := TRUE; Goto Cleanup; end; end;//GetKernelObjectSecurity() // 得到原安全描述符的访问控制列表 ACL If not GetSecurityDescriptorDacl(pOrigSd,bDAcl,pOldDAcl,bDefDAcl) Then begin bError := TRUE; goto Cleanup; end; // 生成新 ACE 权限的访问控制列表 ACL dwRet := SetEntriesInAcl(1,@ea,pOldDAcl,pNewDAcl); If dwRet ERROR_SUCCESS Then begin pNewDAcl := nil; bError := TRUE; goto Cleanup; end; If not MakeAbsoluteSD(pOrigSd, pNewSd, dwSDLen, pOldDAcl^, dwAclSize, pSacl^, dwSaclSize, pSidOwner, dwSidOwnLen, pSidPrimary, dwSidPrimLen) Then begin {第一次调用给出的参数肯定返回这个错误,这样做的目的是 为了创建新的安全描述符 pNewSd 而得到各项的长度} If GetLastError = ERROR_INSUFFICIENT_BUFFER Then begin pOldDAcl := HeapAlloc(GetProcessHeap(), $00000008, dwAclSize); pSacl := HeapAlloc(GetProcessHeap(), $00000008, dwSaclSize); pSidOwner := HeapAlloc(GetProcessHeap(), $00000008, dwSidOwnLen); pSidPrimary := HeapAlloc(GetProcessHeap(), $00000008, dwSidPrimLen); pNewSd := HeapAlloc(GetProcessHeap(), $00000008, dwSDLen); If (pOldDAcl = nil) or (pSacl = nil) or (pSidOwner = nil) or (pSidPrimary = nil) or (pNewSd = nil) Then begin bError := TRUE; goto Cleanup; end; {再次调用才可以成功创建新的安全描述符 pNewSd 但新的安全描述符仍然是原访问控制列表 ACL} If not MakeAbsoluteSD(pOrigSd, pNewSd, dwSDLen, pOldDAcl^, dwAclSize, pSacl^, dwSaclSize, pSidOwner, dwSidOwnLen, pSidPrimary, dwSidPrimLen) Then begin bError := TRUE; goto Cleanup; end; end Else begin bError := TRUE; goto Cleanup; end; end; {将具有所有访问权限的访问控制列表 pNewDAcl 加入到新的 安全描述符 pNewSd 中} If not SetSecurityDescriptorDacl(pNewSd,bDAcl,pNewDAcl,bDefDAcl) Then begin bError := TRUE; goto Cleanup; end; // 将新的安全描述符加到 TOKEN 中 If not SetKernelObjectSecurity(hToken,DACL_SECURITY_INFORMATION,pNewSd) Then begin bError := TRUE; goto Cleanup; end; // 再次打开 WINLOGON 进程的 TOKEN,这时已经具有所有访问权限 If not OpenProcessToken(hProcess,TOKEN_ALL_ACCESS,hToken) Then begin bError := TRUE; goto Cleanup; end; // 复制一份具有相同访问权限的 TOKEN If not DuplicateTokenEx(hToken, TOKEN_ALL_ACCESS, nil, SecurityImpersonation, TokenPrimary, hNewToken) Then begin bError := TRUE; goto Cleanup; end; ZeroMemory(@si,Sizeof(STARTUPINFO)); si.cb := Sizeof(STARTUPINFO); {不虚拟登陆用户的话,创建新进程会提示 1314 客户没有所需的特权错误} ImpersonateLoggedOnUser(hNewToken); {我们仅仅是需要建立高权限进程,不用切换用户 所以也无需设置相关桌面,有了新 TOKEN 足够} // 利用具有所有权限的 TOKEN,创建高权限进程 If not CreateProcessAsUser(hNewToken, nil, szProcessName, nil, nil, FALSE, 0, nil, nil, si, pi) Then begin bError := TRUE; goto Cleanup; end; bError := FALSE; Cleanup: If pOrigSd = nil Then HeapFree(GetProcessHeap(),0,pOrigSd); If pNewSd = nil Then HeapFree(GetProcessHeap(),0,pNewSd); If pSidPrimary = nil Then HeapFree(GetProcessHeap(),0,pSidPrimary); If pSidOwner = nil Then HeapFree(GetProcessHeap(),0,pSidOwner); If pSacl = nil Then HeapFree(GetProcessHeap(),0,pSacl); If pOldDAcl = nil Then HeapFree(GetProcessHeap(),0,pOldDAcl); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); CloseHandle(hToken); CloseHandle(hNewToken); //CloseHandle(hProcess); If bError Then Result := FALSE Else Result := True; end; begin CreateSystemProcess('test.exe'); { TODO -oUser -cConsole Main : Insert code here } end.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值