-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpermission.go
80 lines (77 loc) · 2.37 KB
/
permission.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package faithdroid
import (
"strings"
)
func CheckSelfPermission(a IActivity, permission string) bool {
b := GlobalVars.UIs[a.GetMyActivity().UI].ViewGetAttr("Permission", "CheckSelfPermission:"+permission)
if b == "true" {
return true
}
return false
}
func RequestPermissions(a IActivity, perms []string, onResult func([]bool)) {
fnId := NewToken()
fn:=func(s string) string {
if onResult != nil {
var bs []bool
UnJson(s, &bs)
onResult(bs)
}
return ""
}
GlobalVars.EventHandlersMapLock.Lock()
GlobalVars.EventHandlersMap[fnId] = fn
GlobalVars.EventHandlersMapLock.Unlock()
GlobalVars.UIs[a.GetMyActivity().UI].ViewSetAttr("Permission", "RequestPermissions", fnId+":"+strings.Join(perms, "#")+":"+NewNumToken())
}
var Permissions = struct {
CAMERA string
WRITE_EXTERNAL_STORAGE string
READ_EXTERNAL_STORAGE string
READ_PHONE_STATE string
READ_CALENDAR string
WRITE_CALENDAR string
READ_CONTACTS string
WRITE_CONTACTS string
GET_ACCOUNTS string
ACCESS_FINE_LOCATION string
ACCESS_COARSE_LOCATION string
RECORD_AUDIO string
CALL_PHONE string
READ_CALL_LOG string
WRITE_CALL_LOG string
ADD_VOICEMAIL string
USE_SIP string
PROCESS_OUTGOING_CALLS string
BODY_SENSORS string
SEND_SMS string
RECEIVE_SMS string
READ_SMS string
RECEIVE_WAP_PUSH string
RECEIVE_MMS string
}{
"android.permission.CAMERA",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.READ_PHONE_STATE",
"android.permission.READ_CALENDAR",
"android.permission.WRITE_CALENDAR",
"android.permission.READ_CONTACTS",
"android.permission.WRITE_CONTACTS",
"android.permission.GET_ACCOUNTS",
"android.permission.ACCESS_FINE_LOCATION",
"android.permission.ACCESS_COARSE_LOCATION",
"android.permission.RECORD_AUDIO",
"android.permission.CALL_PHONE",
"android.permission.READ_CALL_LOG",
"android.permission.WRITE_CALL_LOG",
"android.permission.ADD_VOICEMAIL",
"android.permission.USE_SIP",
"android.permission.PROCESS_OUTGOING_CALLS",
"android.permission.BODY_SENSORS",
"android.permission.SEND_SMS",
"android.permission.RECEIVE_SMS",
"android.permission.READ_SMS",
"android.permission.RECEIVE_WAP_PUSH",
"android.permission.RECEIVE_MMS",
}