Android OBB file not found for secondary user in Lock task mode(EMM)

24 Views Asked by At

In Android Enterprise management admin user can access OBB file and can open Angry-birds2 app. But for the secondary user OBB file not accessible. For the secondary user got stuck while try to access the OBB file.

How can I share the OBB file with the secondary user? Try to create directory and copy the files but doesn't work.

Note: Admin user working fine, but when switching to secondary user only than I am having issues.

                            if (obbFiles.isNotEmpty()) {
                                // Create obb dir
                                val obbDirFile = context.obbDir.parentFile
                                obbDirFile?.run {
                                    if (!exists()) mkdir()
                                }

                                val obbPackageDirFile =
                                    File("${obbDirFile?.path}/${app.packageName}")
                                if (!obbPackageDirFile.exists()) obbPackageDirFile.mkdir()

                                obbFiles.forEach {
                                    Log.d(TAG, "copying obb $it for ${app.packageName}")
                                    val pfd = loanManagerService?.openFile(it)
                                    val ins = ParcelFileDescriptor.AutoCloseInputStream(pfd)
                                    context.contentResolver.openOutputStream(Uri.parse(it))?.use { os ->
                                        ins.copyTo(os)
                                    }
                                }
                            }

Opening the app: testOpenAngryBirds2()

    fun testOpenAngryBirds2() {

        Log.d(TAG, " testOpenAngryBirds2: ????????")
        val permissions: List<AppPermission> = listOf()

        val appInfo = AppInfo(
            id = 259,
            name = "Angry Birds 2",
            packageName = "com.rovio.baba",
            description = "Play the Angry Birds game enjoyed by millions of players every day!",
            lockTaskMode = false,
            permissions = permissions,
            highlighted = true
        )

        deviceManager.setPermissionGrantState(Manifest.permission.WRITE_EXTERNAL_STORAGE)
        deviceManager.setPermissionGrantState(Manifest.permission.READ_EXTERNAL_STORAGE)

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            deviceManager.setPermissionGrantState(Manifest.permission.POST_NOTIFICATIONS)
        }
        deviceManager.setLockTaskPackages(listOf(appInfo))

        deviceManager.openApp(appInfo.packageName, appInfo.lockTaskMode)
    }
0

There are 0 best solutions below