Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 882b8829 authored by Nick Kralevich's avatar Nick Kralevich Committed by Android Git Automerger
Browse files

am 9831fad6: Merge "Modify how USB connections are handled." into mnc-dev

* commit '9831fad6':
  Modify how USB connections are handled.
parents 1a4df69f 9831fad6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ public class UsbCommand extends Svc.Command {
                IUsbManager usbMgr = IUsbManager.Stub.asInterface(ServiceManager.getService(
                        Context.USB_SERVICE));
                try {
                    usbMgr.setCurrentFunction((args.length >=3 ? args[2] : null), false);
                    usbMgr.setCurrentFunction((args.length >=3 ? args[2] : null));
                } catch (RemoteException e) {
                    System.err.println("Error communicating with UsbManager: " + e);
                }
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ interface IUsbManager
    void clearDefaults(String packageName, int userId);

    /* Sets the current USB function. */
    void setCurrentFunction(String function, boolean makeDefault);
    void setCurrentFunction(String function);

    /* Allow USB debugging from the attached host. If alwaysAllow is true, add the
     * the public key to list of host keys that the user has approved.
+34 −13
Original line number Diff line number Diff line
@@ -228,6 +228,23 @@ public class UsbManager {
     */
    public static final String EXTRA_PERMISSION_GRANTED = "permission";

    /**
     * The persistent property which stores whether adb is enabled or not. Other values are ignored.
     * Previously this value stored non-adb settings, but not anymore.
     * TODO: rename this to something adb specific, rather than using usb.
     *
     * {@hide}
     */
    public static final String ADB_PERSISTENT_PROPERTY = "persist.sys.usb.config";

    /**
     * The non-persistent property which stores the current USB settings.
     *
     * {@hide}
     */
    public static final String USB_SETTINGS_PROPERTY = "sys.usb.config";


    private final Context mContext;
    private final IUsbManager mService;

@@ -410,21 +427,26 @@ public class UsbManager {
        }
    }

    private static boolean propertyContainsFunction(String property, String function) {
        String functions = SystemProperties.get(property, "");
        int index = functions.indexOf(function);
        if (index < 0) return false;
        if (index > 0 && functions.charAt(index - 1) != ',') return false;
        int charAfter = index + function.length();
        if (charAfter < functions.length() && functions.charAt(charAfter) != ',') return false;
        return true;
    }

    /**
     * Returns the current default USB function.
     * Returns true if the specified USB function is currently enabled.
     *
     * @return name of the default function.
     * @param function name of the USB function
     * @return true if the USB function is enabled.
     *
     * {@hide}
     */
    public String getDefaultFunction() {
        String functions = SystemProperties.get("persist.sys.usb.config", "");
        int commaIndex = functions.indexOf(',');
        if (commaIndex > 0) {
            return functions.substring(0, commaIndex);
        } else {
            return functions;
        }
    public boolean isFunctionEnabled(String function) {
        return propertyContainsFunction(USB_SETTINGS_PROPERTY, function);
    }

    /**
@@ -432,13 +454,12 @@ public class UsbManager {
     * If function is null, then the current function is set to the default function.
     *
     * @param function name of the USB function, or null to restore the default function
     * @param makeDefault true if the function should be set as the new default function
     *
     * {@hide}
     */
    public void setCurrentFunction(String function, boolean makeDefault) {
    public void setCurrentFunction(String function) {
        try {
            mService.setCurrentFunction(function, makeDefault);
            mService.setCurrentFunction(function);
        } catch (RemoteException e) {
            Log.e(TAG, "RemoteException in setCurrentFunction", e);
        }
+6 −4
Original line number Diff line number Diff line
@@ -2919,18 +2919,20 @@
    <!-- USB_STORAGE_ERROR dialog  ok button-->
    <string name="dlg_ok">OK</string>

    <!-- USB_PREFERENCES: Notification for when the user connected to the charger only.  This is the title -->
    <string name="usb_charging_notification_title">USB for charging</string>
    <!-- USB_PREFERENCES: Notification for when the user connects the phone to a computer via USB in MTP mode.  This is the title -->
    <string name="usb_mtp_notification_title">Connected as a media device</string>
    <string name="usb_mtp_notification_title">USB for file transfer</string>
    <!-- USB_PREFERENCES: Notification for when the user connects the phone to a computer via USB in PTP mode.  This is the title -->
    <string name="usb_ptp_notification_title">Connected as a camera</string>
    <string name="usb_ptp_notification_title">USB for photo transfer</string>
    <!-- USB_PREFERENCES: Notification for when the user connects the phone to a computer via USB in MIDI mode.  This is the title -->
    <string name="usb_midi_notification_title">Connected as a MIDI device</string>
    <string name="usb_midi_notification_title">USB for MIDI</string>
    <!-- USB_PREFERENCES: Notification for when the user connects the phone to a computer via USB in mass storage mode (for installer CD image).  This is the title -->
    <string name="usb_cd_installer_notification_title">Connected as an installer</string>
    <!-- USB_PREFERENCES: Notification for when a USB accessory is attached.  This is the title -->
    <string name="usb_accessory_notification_title">Connected to a USB accessory</string>
    <!-- See USB_PREFERENCES. This is the message. -->
    <string name="usb_notification_message">Touch for other USB options.</string>
    <string name="usb_notification_message">Touch for more options.</string>

    <!-- External media format dialog strings -->
    <!-- This is the label for the activity, and should never be visible to the user. -->
+1 −0
Original line number Diff line number Diff line
@@ -1790,6 +1790,7 @@
  <java-symbol type="string" name="usb_accessory_notification_title" />
  <java-symbol type="string" name="usb_cd_installer_notification_title" />
  <java-symbol type="string" name="usb_mtp_notification_title" />
  <java-symbol type="string" name="usb_charging_notification_title" />
  <java-symbol type="string" name="usb_notification_message" />
  <java-symbol type="string" name="use_physical_keyboard" />
  <java-symbol type="string" name="usb_ptp_notification_title" />
Loading