当前位置:网站首页>Using fuser to view file usage
Using fuser to view file usage
2022-06-23 07:00:00 【Ti-laser】
stay android Sometimes we need to check whether a file has been operated by other files through the application , stay linux On the command line, you can use fuser Command view , If the upper class android When the application directly calls the program, it cannot view because of permission (fuser Will pass /proc File system to collect information about related operation files ), namely fuser Only in root Only with permission can you give full play to the problem of viewing occupancy . To achieve this goal , Can be fuer Become a running on root On demand service under permission , Through this service, you can indirectly view files . The communication between services and applications can be through property To carry out . As follows :
modify init.rc file , Join in fuser service.
service fuser /system/bin/fuser.sh user root oneshot disabled increase fuser.sh Run the script as follows :#!/system/bin/busybox sh#app will set boot.CHK_FILE to the file(absolute path) he wants to check,then trigger this service#the result will be incuded in the proprity ,0 means occupied, 1 means file not exist or some error occuor./system/bin/setprop "boot.LOOK_PROG_RES" ""/system/bin/setprop "boot.LOOK_PROG_STAT" "beginning"PRG=`/system/bin/getprop "boot.CHK_FILE"`/system/bin/busybox fuser $PRGCHK_RESULT=$?echo check prg=$PRG,result=$CHK_RESULT/system/bin/setprop "boot.LOOK_PROG_RES" "$CHK_RESULT"/system/bin/setprop "boot.LOOK_PROG_STAT" "end"Embed the following code in the application code :
SystemProperties.set("boot.CHK_FILE", "/sdcard/music/zh.mp3"); SystemProperties.set("boot.LOOK_PROG_STAT",""); SystemService.start("fuser"); try{Thread.sleep(1000);}catch(Exception e){}while(SystemProperties.get("boot.LOOK_PROG_STAT").compareTo("end")!=0){
Log.v("boot.LOOK_PROG_STAT="+SystemProperties.get("boot.LOOK_PROG_STAT")); try{Thread.sleep(100);}catch(Exception e){}}Log.v("====get check result:"+SystemProperties.get("boot.LOOK_PROG_RES")); Whether to check or not can be realized /sdcard/music/zh.mp3 Whether it is operated by other programs .Pay attention to the manifest You need to add system jurisdiction :
android:sharedUserId="android.uid.system"In addition, it needs to be adjusted property_service.c, Add new boot Yes system Authority .
边栏推荐
- C language operator priority formula
- Chrome remove duplicate bookmarks
- js 动态创建a href 循环下载文件只能下载10个或者固定数目的问题
- Data indicators and data analysis models that designers need to understand
- 2022年养老理财产品有哪些?风险小的
- 微信小程序 - 全局监听globalData的某个属性变化,例如监听网络状态切换
- English grammar_ Adverb - ever / once
- [project training] multi segment line expanded to parallel line
- /Bin/sh no such file or directory problem
- Storage mode of data in memory (C language)
猜你喜欢

XML schema record

Data indicators and data analysis models that designers need to understand

MySQL重做日志 redo log

Children's programming for comprehensively cultivating students' mental thinking

【STL】关联容器之map用法总结

QT中的item views与Item widgets控件的用法总结

Xxl-sso enables SSO single sign on

leetcode - 572. 另一棵树的子树

MySQL basic query

疫情下的传媒产业,小程序生态驱动数字化转型探索
随机推荐
Children's programming for comprehensively cultivating students' mental thinking
[QT] basic learning notes
[STL] summary of map usage of associated containers
C语言学习总结
Open source oauth2 framework for SSO single sign on
Haas506 2.0 development tutorial -sntp (only versions above 2.2 are supported)
Haas506 2.0 development tutorial -hota (only supports versions above 2.2)
Haas506 2.0 development tutorial - Advanced Component Library -modem SMS (only supports versions above 2.2)
Focusing on the smart city, Huawei cooperates with China Science and technology Xingtu to jointly develop a new digital blue ocean
【毕业季·进击的技术er】自己的选择,跪着也要走
[project training] multi segment line expanded to parallel line
English grammar_ Adjective comparative - Level 3 change
MySQL function
xml schem 记录
【STL】顺序容器之deque用法总结
Cetos7 record
ssm + ftp +ueditor
Usage Summary of item views and item widgets controls in QT
Chrome删除重复书签
Summary of qvariant use in QT