How to allow FILES app (by Google) to access a USB stick in Kiosk mode?

I have modified the Advanced Android Kiosk Mode for my needs so it launches another app, and can also update it making the user choose an .apk file from a USB stick.

To choose the .apk file, the kiosk app launches the FILES app (by Google) that is present on the device, and the user should select the .apk file. The problem is that in Kiosk mode, the FILES app doesn’t see the USB stick.

In the Kiosk app, there is the following function that I have modified removing DISALLOW_MOUNT_PHYSICAL_MEDIA, but this don’t solve the problem:

function TKioskApplication.GetRestrictions: TArrayOfJStrings;
begin
//  SetLength(Result, 6);
  SetLength(Result, 5);
  Result[0] := StringToJString(TJUserManagerDISALLOW_FACTORY_RESET);
  Result[1] := StringToJString(TJUserManagerDISALLOW_SAFE_BOOT);
//  Result[2] := StringToJString(TJUserManagerDISALLOW_MOUNT_PHYSICAL_MEDIA);
  Result[2] := StringToJString(TJUserManagerDISALLOW_ADJUST_VOLUME);
  Result[3] := StringToJString(TJUserManagerDISALLOW_ADD_USER);
  Result[4] := StringToJString(TJUserManagerDISALLOW_CREATE_WINDOWS);
end;

The Android log while connecting the USB stick is the following:

2-1 new high-speed USB device number 4 using ehci-platform
2-1 New USB device found, idVendor=0718, idProduct=0619, bcdDevice= 1.00
2-1 New USB device strings: Mfr=1, Product=2, SerialNumber=3
2-1 Product: Trans-It Drive
2-1 Manufacturer: TDKMedia
2-1 SerialNumber: 07BA0703BE242FA7
2-1: 1.0: USB Mass Storage device detected
host0: usb-storage 2-1:1.0
uid=1000(system) android.fg identical 129 lines
Close system dialogs
USB device attached: vidpid 0718:0619 mfg/product/ver/serial TDKMedia/Trans-It Drive/1.00/07BA0703BE242FA7 hasAudio/HID/Storage: false/false/true
Close system dialogs
uid=10117(com.android.systemui) identical 130 lines
NotificationShadeWindow: com.android.systemui.statusbar.phone.NotificationShadeWindowView{dbf45aa I.E...... ......ID 0,0-1280,800} canPanelBeCollapsed(): false
1 configs
Added device UsbDevice[mName=/dev/bus/usb/002/004,mVendorId=1816,mProductId=1561,mClass=0,mSubclass=0,mProtocol=0,mManufacturerName=TDKMedia,mProductName=Trans-It Drive,mVersion=1.00,mSerialNumberReader=com.android.server.usb.UsbSerialReader@6898cac, mHasAudioPlayback=false, mHasAudioCapture=false, mHasMidi=false, mHasVideoCapture=false, mHasVideoPlayback=false, mConfigurations=[
UsbConfiguration[mId=1,mName=null,mAttributes=128,mMaxPower=100,mInterfaces=[
UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=8,mSubclass=6,mProtocol=80,mEndpoints=[
UsbEndpoint[mAddress=129,mAttributes=2,mMaxPacketSize=512,mInterval=0]
UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=512,mInterval=0]]]]
Clear notification
Close system dialogs
NotificationShadeWindow: com.android.systemui.statusbar.phone.NotificationShadeWindowView{dbf45aa I.E...... ......ID 0,0-1280,800} canPanelBeCollapsed(): false
0 0:0:0: Direct-Access TDKMedia Trans-It Drive PMAP PQ: 0 ANSI: 4
0 0:0:0: Attached scsi generic sg0 type 0
uid=10117(com.android.systemui) identical 26 lines
NotificationShadeWindow: com.android.systemui.statusbar.phone.NotificationShadeWindowView{dbf45aa I.E...... ......ID 0,0-1280,800} canPanelBeCollapsed(): false
Updating roots due to change on user 0at content://com.android.externalstorage.documents
NotificationShadeWindow: com.android.systemui.statusbar.phone.NotificationShadeWindowView{dbf45aa I.E...... ......ID 0,0-1280,800} canPanelBeCollapsed(): false
0 0:0:0: [sda] 7555072 512-byte logical blocks: (3.87 GB/3.60 GiB)
0 0:0:0: [sda] Write Protect is off
0 0:0:0: [sda] Mode Sense: 23 00 00 00
0 0:0:0: [sda] No Caching mode page found
0 0:0:0: [sda] Assuming drive cache: write through
sda1
uid=1000(system) android.fg identical 46 lines
Close system dialogs
/system/bin/sgdisk
--android-dump
/dev/block/vold/disk:8,0
0 0:0:0: [sda] Attached SCSI removable disk
DISK mbr
PART 1 c
uid=10117(com.android.systemui) identical 18 lines
NotificationShadeWindow: com.android.systemui.statusbar.phone.NotificationShadeWindowView{dbf45aa I.E...... ......ID 0,0-1280,800} canPanelBeCollapsed(): false
-----for all public volume is visible-----
Ignoring mount public:8,1 due to policy
Notifying volume state changed for session with id: public:8,1
No session found for sessionId: public:8,1
After updating volumes, found 1 active roots
Notifying about public volume: VolumeInfo{public:8,1}:
type=PUBLIC diskId=disk:8,0 partGuid= mountFlags=VISIBLE mountUserId=0
state=UNMOUNTED
fsType=null fsUuid=null fsLabel=null
path=null internalPath=null
After updating volumes, found 1 active roots
Close system dialogs
NotificationShadeWindow: com.android.systemui.statusbar.phone.NotificationShadeWindowView{dbf45aa I.E...... ......ID 0,0-1280,800} canPanelBeCollapsed(): false
uid=10117(com.android.systemui) identical 162 lines
NotificationShadeWindow: com.android.systemui.statusbar.phone.NotificationShadeWindowView{dbf45aa I.E...... ......ID 0,0-1280,800} canPanelBeCollapsed(): false
Updating roots due to change on user 0at content://com.android.externalstorage.documents
Updating roots due to change on user 0at content://com.android.externalstorage.documents
NotificationShadeWindow: com.android.systemui.statusbar.phone.NotificationShadeWindowView{dbf45aa I.E...... ......ID 0,0-1280,800} canPanelBeCollapsed(): false

In the first part, the USB stick is recognized. But, in the last part, the state is state=UNMOUNTED, so it is not accessible.

If the app is not in kiosk mode, everything works.

The target device runs Android 11, and I use Delphi 12.2 w/ patch 2.

Can anybody give me some help?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật