Do not add SelectUsbConfigPreferenceController if USB is disabled.
Bug: 69479572 Test: Local cherry-picked to master-arc-dev, and deployed cheets_x86 to a ChromeOS device. Developer Options show up. Updated SelectUsbConfigPreferenceControllerTest. Change-Id: I8c6a4501849e67c92f50b8a3781260e9dbcdaf20
This commit is contained in:
@@ -20,6 +20,7 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
@@ -104,6 +105,14 @@ public class SelectUsbConfigPreferenceController extends
|
||||
mContext.unregisterReceiver(mUsbReceiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
final PackageManager packageManager = mContext.getPackageManager();
|
||||
|
||||
return packageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST)
|
||||
|| packageManager.hasSystemFeature(PackageManager.FEATURE_USB_ACCESSORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDeveloperOptionsSwitchEnabled() {
|
||||
mPreference.setEnabled(true);
|
||||
|
Reference in New Issue
Block a user