Make phone call while app is in kiosk mode

生来就可爱ヽ(ⅴ<●) 提交于 2020-12-06 04:10:05

问题


We are working on an Android app which is intended to replace the default Android dialer and handle by itself all the calls going on in the device. So far, the app works as expected and we are able to both handle incoming calls and make calls by launching ACTION_CALL intents.

However, this app is intended to be run in kiosk mode via Android Management API. Whenever we fire the ACTION_CALL intent, kiosk mode blocks it, although the app is set as default dialer.

After some debugging we discovered the problem is that, when launching the intent, before our app takes back the control of the request, the systems tries to start com.android.server.telecom/.components.UserCallActivity. As our app runs in kiosk mode, we got following error in logcat:

10-25 20:29:44.560  1186  3677 E ActivityTaskManager: Attempted Lock Task Mode violation mStartActivity=ActivityRecord{e45f03 u0 com.android.server.telecom/.components.UserCallActivity t24}

We have tries different workaround, but none seems to work. We have messed with Android Managment API parameters such as persistentPreferredActivities or delegatedScopes. Right now, we think our best bet is trying to add com.android.server.telecom to the locktask whitelist, with something like this:

var dpm = (DevicePolicyManager)MainActivity.GetSystemService(Context.DevicePolicyService);
if (dpm.IsDeviceOwnerApp(MainActivity.PackageName)){
    dpm.SetLockTaskPackages(XXX, new[] { MainActivity.PackageName, "com.android.server.telecom"})
}

but this approach makes necessary to set our app as device admin, something that we don't know if is possible as long as we are using Android Management API. We have also tried calling directly the DPC package, but again without any success.

Any help will be appreciated.


回答1:


First of all thanks for asking this question as a new question -as discussed- in Sof so other developers can contributes and it may help others in futur.

I have a question about your solution and app... why don't you opt for ConnectionService as self managed app, so you will avoid the need to be the default phone application in system and you will be able to use your own custom Ui instead of default system inCallUi.

Other point , the DPC installed on fully managed and dedicated devices is referred to as the device owner and device owner is only set on first install of device not later (using Nfc or QrCode provisioning).

Other also point is , "device admin" is not a device owner and device admin is no more supported so also this solution will not help.

i m not familiar with Android Managment API but just find this : Link a kiosk app to additional apps.

"applications": [
{
"packageName": "com.example.app",
"installType": "KIOSK",
"defaultPermissionPolicy": "GRANT"
},
{
"packageName": "com.google.android.dialer",
"installType": "FORCE_INSTALLED",
"defaultPermissionPolicy": "GRANT"
},
{
"packageName": "com.android.server.telecom",
"installType": "FORCE_INSTALLED",
"defaultPermissionPolicy": "GRANT"
}
]

let me know if this worked for u please , thanks



来源:https://stackoverflow.com/questions/64634738/make-phone-call-while-app-is-in-kiosk-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!