Perfectly solve the problem of prohibiting PC from accessing mobile phone storage unit through MTP under the condition of Android m lock screen
@H_ 403_ 2@1 . main problem solving files: / m8976 / packages / providers / mediaprovider / SRC / COM / Android / providers / media / mtpservice.java
You need to add the lock screen condition limit in the updatedisabledstatelocked method in mtpservice.java:
As long as the screen is locked, mmtpdisabled is set to true.
This enables this function.
@H_ 403_ 2@2 . when unlocking, the mobile phone storage unit will be loaded automatically:
Add unlock listening
The broadcast code of unlocking status sent on Android m is not removed. You can view / m8976 / frameworks / base / packages / systemui / SRC / COM / Android / systemui / keyguard / keyguardviewmediator.java
As can be seen from the keyguardviewmediator.java file, intent.action is sent when unlocking_ USER_ Present broadcast, and then in mtpservice.java
Receive and process mmtpdisabled.
The above article perfectly solves the problem of prohibiting PC from accessing mobile phone storage unit through MTP when Android m is locked. I hope it can give you a reference and support more programming tips.