Require authentication for changing USB preferences.
Test: atest SettingsRoboTests Test: also tested manually Bug: 317367746 Change-Id: I17daaad7c7772664cae6d12cf2322991827f33bb
This commit is contained in:
@@ -78,13 +78,15 @@ public class UsbDetailsTranscodeMtpController extends UsbDetailsController
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
SystemProperties.set(TRANSCODE_MTP_SYS_PROP_KEY,
|
||||
Boolean.toString(mSwitchPreference.isChecked()));
|
||||
requireAuthAndExecute(() -> {
|
||||
SystemProperties.set(TRANSCODE_MTP_SYS_PROP_KEY,
|
||||
Boolean.toString(mSwitchPreference.isChecked()));
|
||||
|
||||
final long previousFunctions = mUsbBackend.getCurrentFunctions();
|
||||
// Toggle the MTP connection to reload file sizes for files shared via MTP clients
|
||||
mUsbBackend.setCurrentFunctions(previousFunctions & ~UsbManager.FUNCTION_MTP);
|
||||
mUsbBackend.setCurrentFunctions(previousFunctions);
|
||||
final long previousFunctions = mUsbBackend.getCurrentFunctions();
|
||||
// Toggle the MTP connection to reload file sizes for files shared via MTP clients
|
||||
mUsbBackend.setCurrentFunctions(previousFunctions & ~UsbManager.FUNCTION_MTP);
|
||||
mUsbBackend.setCurrentFunctions(previousFunctions);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user