@startuml
participant WifiManager as wm
participant WifiServiceImpl as wms
participant ContextImpl as context
participant ActivityManagerService as ams
participant ActivityManager as am
participant PackageManagerService as pkms
==wifi setEnabled without permission CHANGE_WIFI_STATE==
wm->wms:setWifiEnabled
activate wms
wms->wms: enforceChangePermission()
activate wms #ffff00
wms->context:mContext.<b>enforceCallingOrSelfPermission</b>\n(CHANGE_WIFI_STATE,"WifiService")
context->context:enforce(permission,\n<b>checkCallingOrSelfPermission(permission)</b>\n,true,Binder.getCallingUid(),message);
activate context
context->context:checkCallingOrSelfPermission(permission)
note right: do checkCallingOrSelfPermission first
activate context #55FFFF
context->context:checkPermission(permission,\n <b>Binder.getCallingPid(),Binder.getCallingUid()</b>)
context->ams:IActivityManager.checkPermission(permission, pid, uid)
ams->ams:checkComponentPermission(permission,\n pid, uid,owningUid=-1,exported=true)
ams->am:checkComponentPermission
ref over am
if appId == Process.<b>ROOT_UID</b> || appId == Process.<b>SYSTEM_UID</b>:
return PackageManager.PERMISSION_GRANTED;
if isIsolated(uid):
return PERMISSION_DENIED
other case as below
end ref
am->pkms: AppGlobals.getPackageManager().<b>checkUidPermission(permission, uid)</b>
pkms->pkms:Object obj = mSettings.getUserIdLPr\n(UserHandle.getAppId(uid));
note left: get the SharedUserSetting/PackageSetting according to the uid
alt find obj case
ref over pkms
SettingBase settingBase = (SettingBase) obj
permissionsState = settingBase.getPermissionsState()
if (permissionsState.hasPermission(permName, userId)):
return PERMISSION_GRANTED
else //Special case:
ACCESS_FINE_LOCATION permission includes ACCESS_COARSE_LOCATION
if permisson request is ACCESS_COARSE_LOCATION, return PERMISSION_GRANTED
if it have the permission of ACCESS_FINE_LOCATION
end
else no obj case ,maybe system have assigned the permission to this uid
ref over pkms
"like audioserver: is not a apk ==>no obj"
look for this (uid permisson) in <b>mSystemPermissions</b>
if system have assigned this permission to this uid:
return PERMISSION_GRANTED
end
else other case return PERMISSION_DENIED
end
pkms->context:return PERMISSION_GRANTED or PERMISSION_DENIED
deactivate context
context->context: if return is not <b>PERMISSION_GRANTED</b>:\n <font color=red><b>throw new SecurityException</font>
note right: log like "SecurityException: WifiService: Neither user 10080 nor current process has android.permission.CHANGE_WIFI_STATE."
context->wms:enforce return
deactivate context
wms->wms: if permission check ok:\n continue to do next thing
deactivate wms
deactivate wms
@enduml
wifi_enable_permisson_sequence@startumlparticipant WifiManager as wmparticipant WifiServiceImpl as wmsparticipant ContextImpl as contextparticipant ActivityManagerService as amsparticipant Activ...