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

Commit be3dd6a1 authored by Kiran S's avatar Kiran S
Browse files

Add test api to check if mode change is supported

Change-Id: I2b36ebb174e25ebbf1b9b304a0ba7b41619fd142
Bug: 323470419
Test: Manually verified that the api is returning the internal value
parent 93bc3f16
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -1840,6 +1840,14 @@ package android.hardware.soundtrigger {


}
}


package android.hardware.usb {

  public final class UsbPort {
    method @FlaggedApi("android.hardware.usb.flags.enable_is_mode_change_supported_api") @RequiresPermission(android.Manifest.permission.MANAGE_USB) public boolean isModeChangeSupported();
  }

}

package android.inputmethodservice {
package android.inputmethodservice {


  public abstract class AbstractInputMethodService extends android.window.WindowProviderService implements android.view.KeyEvent.Callback {
  public abstract class AbstractInputMethodService extends android.window.WindowProviderService implements android.view.KeyEvent.Callback {
+4 −0
Original line number Original line Diff line number Diff line
@@ -186,6 +186,10 @@ interface IUsbManager
    /* Gets the status of the specified USB port. */
    /* Gets the status of the specified USB port. */
    UsbPortStatus getPortStatus(in String portId);
    UsbPortStatus getPortStatus(in String portId);


    /* Returns if the specified USB port supports mode change. */
    @EnforcePermission("MANAGE_USB")
    boolean isModeChangeSupported(in String portId);

    /* Sets the port's current role. */
    /* Sets the port's current role. */
    void setPortRoles(in String portId, int powerRole, int dataRole);
    void setPortRoles(in String portId, int powerRole, int dataRole);


+15 −0
Original line number Original line Diff line number Diff line
@@ -1473,6 +1473,21 @@ public class UsbManager {
        }
        }
    }
    }


    /**
     * Checks if the given port supports mode change. Should only be called by
     * {@link UsbPort#isModeChangeSupported}.
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.MANAGE_USB)
    boolean isModeChangeSupported(UsbPort port) {
        try {
            return mService.isModeChangeSupported(port.getId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
    /**
     * Should only be called by {@link UsbPort#setRoles}.
     * Should only be called by {@link UsbPort#setRoles}.
     *
     *
+16 −0
Original line number Original line Diff line number Diff line
@@ -65,11 +65,14 @@ import static android.hardware.usb.DisplayPortAltModeInfo.DISPLAYPORT_ALT_MODE_S
import android.Manifest;
import android.Manifest;
import android.annotation.CallbackExecutor;
import android.annotation.CallbackExecutor;
import android.annotation.CheckResult;
import android.annotation.CheckResult;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.hardware.usb.flags.Flags;
import android.hardware.usb.UsbOperationInternal;
import android.hardware.usb.UsbOperationInternal;
import android.hardware.usb.V1_0.Constants;
import android.hardware.usb.V1_0.Constants;
import android.os.Binder;
import android.os.Binder;
@@ -374,6 +377,19 @@ public final class UsbPort {
        return mUsbManager.getPortStatus(this);
        return mUsbManager.getPortStatus(this);
    }
    }


    /**
     * Returns whether this USB port supports mode change
     *
     * @return true if mode change is supported.
     * @hide
     */
    @TestApi
    @RequiresPermission(Manifest.permission.MANAGE_USB)
    @FlaggedApi(Flags.FLAG_ENABLE_IS_MODE_CHANGE_SUPPORTED_API)
    public boolean isModeChangeSupported() {
        return mUsbManager.isModeChangeSupported(this);
    }

    /**
    /**
     * Queries USB Port to see if the port is capable of identifying
     * Queries USB Port to see if the port is capable of identifying
     * non compliant USB power source/cable/accessory.
     * non compliant USB power source/cable/accessory.
+7 −0
Original line number Original line Diff line number Diff line
@@ -6,3 +6,10 @@ flag {
    description: "Feature flag for the api to check if a port is PD compliant"
    description: "Feature flag for the api to check if a port is PD compliant"
    bug: "323470419"
    bug: "323470419"
}
}

flag {
    name: "enable_is_mode_change_supported_api"
    namespace: "usb"
    description: "Feature flag for the api to check if a port supports mode change"
    bug: "323470419"
}
Loading