public class ModManager extends Object
ModManager.ACTION_BIND_MANAGER
, the app will also need to have the permission
ModManager.PERMISSION_MOD_ACCESS_INFO
in order to bind to it.Modifier and Type | Field and Description |
---|---|
static String |
ACTION_BIND_MANAGER
Action to be used to bind to the Moto Mod Manager Service.
|
static String |
ACTION_MOD_ATTACH
A broadcast action which is sent when a Moto Mod is attached to the
device.
|
static String |
ACTION_MOD_ATTACH_FAILED
A broadcast action which is sent when a Moto Mod is attached to the
device but the attach failed, due to an incorrect manifest or other
attach failure.
|
static String |
ACTION_MOD_CAPABILITY_CHANGED
A broadcast action which is sent when the capability of the Moto Mod has
been changed, this is used for asynchronous messaging between a Moto Mod
and a device, and typically used by a Moto Mod to reflects changes which
degrades one of its capability (such as the Moto Mod battery getting low,
or the Moto Mod thermal treshold being reached).
|
static String |
ACTION_MOD_DETACH
A broadcast action which is sent when a Moto Mod is detached from the
device.
|
static String |
ACTION_MOD_ENUMERATION_DONE
A broadcast action sent when the phone has finished enumerating all the
functionalities of a Moto Mod.
|
static String |
ACTION_MOD_ERROR
A broadcast action which is sent when an error happened to the device,
i.e., communication error
|
static String |
ACTION_MOD_FIRMWARE_UPDATE_DONE
A broadcast action sent when the firmware update of the Moto Mod
firmware completed.
|
static String |
ACTION_MOD_FIRMWARE_UPDATE_START
A broadcast action sent when the device starts firmware update on an
attached Moto Mod.
|
static String |
ACTION_MOD_REQUEST_FIRMWARE
A broadcast action which is sent when a Moto Mod is being attached to the
device but but is unable to boot due to missing or invalid firmware, and
request userspace to give the firmware.
|
static String |
EXTRA_MOD_DEVICE
Intent Extra.
|
static String |
EXTRA_MOD_ERROR
|
static String |
EXTRA_PRODUCT
Intent Extra.
|
static String |
EXTRA_PRODUCT_ID
Intent Extra.
|
static String |
EXTRA_PROTOCOLS
Intent Extra.
|
static String |
EXTRA_REASON
Intent Extra.
|
static String |
EXTRA_RESULT_CODE
Intent Extra.
|
static String |
EXTRA_UNIQUE_ID
Intent Extra which returns the Unique ID of a Moto Mod.
|
static String |
EXTRA_VENDOR
Intent Extra.
|
static String |
EXTRA_VENDOR_ID
Intent Extra.
|
static int |
MOD_ERROR_COMMUNICATION_RESET
There was communication error with the Moto Mod, trying to reset it.
|
static int |
MOD_ERROR_RECOVERY_ATTEMPT
There was an error in the Moto Mod and trying to recover it.
|
static int |
MOD_ERROR_RECOVERY_FAILED
There was an error in the Moto Mod and tried to recover it, but failed.
|
static int |
MOD_ERROR_RECOVERY_SUCCESS
There was an error in the Moto Mod and tried to recover it, and successed.
|
static int |
MOD_ERROR_SHORT_DETECTED
There was a circuit shortage on the PIN while attaching the Moto Mod
|
static int |
MOD_ERROR_SHORT_RECOVERY_FAIL
There was a circuit shortage on the PIN while attaching the Moto Mod and
tried to recover it, but failed.
|
static int |
MOD_EVENT_USB_CONFLICT |
static ComponentName |
MOD_SERVICE_NAME
The instance of ComponentName, which can be set in the
intent
ModManager.ACTION_BIND_MANAGER to bind to the Moto Mod Service. |
static String |
PACKAGE_SCHEME
A Moto Mod can indicate, in its hardware manifest, its associated
optional Android application.
|
static String |
PERMISSION_MOD_ACCESS_INFO
The permission which protects access to Moto Mod device information, the
protection level of this permission is normal.
|
static String |
PERMISSION_MOD_INTERNAL
The permission which protects the management of Moto Mod device.
|
static String |
PERMISSION_USE_RAW_PROTOCOL
The permission which protects access to the RAW interface of a Moto Mod.
|
static int |
SERVICE_DISABLED
This is a status code returned by the
ModManager.isModServicesAvailable(android.content.Context) . |
static int |
SERVICE_INVALID
This is a status code returned by the
ModManager.isModServicesAvailable(android.content.Context) . |
static int |
SERVICE_MISSING
This is a status code returned by the
ModManager.isModServicesAvailable(android.content.Context) . |
static int |
SERVICE_UPDATING
This is a status code returned by the
ModManager.isModServicesAvailable(android.content.Context) . |
static int |
SERVICE_VERSION_UPDATE_REQUIRED
This is a status code returned by the
ModManager.isModServicesAvailable(android.content.Context) . |
static int |
SUCCESS
This is a status code returned for the
ModManager.isModServicesAvailable(android.content.Context) . |
Constructor and Description |
---|
ModManager(Context context,
IModManager manager)
Constructor for ModManager, the instance of IModManager can be retrieved
from bindService(new Intent(
ModManager.ACTION_BIND_MANAGER ).setComponent(
ModManager.MOD_SERVICE_NAME ), ...); |
Modifier and Type | Method and Description |
---|---|
Object |
getClassManager(Class serviceClass)
A convenient version of
ModManager.getClassManager(ModDevice, Class) . |
Object |
getClassManager(ModDevice device,
Class serviceClass)
Returns the handle to the individual class interface manager
corresponding to the SERVICE CLASS, which the caller app could use to
control the Moto Mod.
|
Object |
getClassManager(ModDevice device,
ModProtocol.Protocol protocol)
Returns the handle to the class interface manager corresponding to the
PROTOCOL, which the calling application could use to control the Moto Mod.
|
Object |
getClassManager(ModProtocol.Protocol protocol)
A convenient version of
#getClassManager(ModDevice, Protocol) . |
List |
getConnectionsByDevice(ModDevice device)
Retrieves all the connections associated with a given device.
|
String |
getDefaultModPackage(ModDevice mod)
Retrieves the default Android application associated with the currently
attached Moto Mod, as read from the Moto Mod hardware manifest.
|
List |
getModInterfaceDelegationsByProtocol(ModDevice device,
ModProtocol.Protocol protocol)
This function returns the list of ModInterfaceDelegation corresponding to
the Linux devices on the Moto Mod that support a particular protocol.
|
List |
getModList(boolean onlineOnly)
Returns the list of attached Moto Mods.
|
List |
getModList(int[] protocols,
boolean onlineOnly)
Returns the list of attached Moto Mods.
|
static int |
getModPlatformSDKVersion()
This function returns the SDK version supported by the Phone's core platform.
|
static int |
getModSdkVersion(Context context)
This function returns the SDK version supported by the ModService that is installed
on the phone, independently of your device core Moto Mod Platform version.
|
boolean |
initSetupComplete(ModDevice device)
If the Moto Mod specifies a package name in its manifest file and if
that package is installed on the smartphone, the ModManager will not
display the initial setup screens, but will let the app handle it.
|
static int |
isModServicesAvailable(Context context)
Verifies that the Moto Mod service is installed and enabled on this
device, and that the version installed on this device is compatible with
the one required by this application (is not older than the one required
by the calling application).
|
ParcelFileDescriptor |
openModInterface(ModInterfaceDelegation iface,
int mode)
This function opens a file descriptor to access the given ModInterfaceDelegation.
|
boolean |
registerModListener(ModListener listener,
int[] protocols)
Register a callback function which will be called when a Moto Mod is
attached or detached from a device.
|
int |
requestUpdateFirmware(ModDevice device,
List locations)
Request to update firmware for the device with the given firmware.
|
public static final String PERMISSION_MOD_ACCESS_INFO
public static final String PERMISSION_MOD_INTERNAL
public static final String PERMISSION_USE_RAW_PROTOCOL
public static final String ACTION_BIND_MANAGER
public static final String ACTION_MOD_ATTACH
Extras include ModManager.EXTRA_VENDOR_ID
, ModManager.EXTRA_PRODUCT_ID
,
ModManager.EXTRA_UNIQUE_ID
, ModManager.EXTRA_VENDOR
ModManager.EXTRA_PRODUCT
and ModManager.EXTRA_MOD_DEVICE
public static final String ACTION_MOD_DETACH
Extras include ModManager.EXTRA_VENDOR_ID
, ModManager.EXTRA_PRODUCT_ID
and ModManager.EXTRA_UNIQUE_ID
and ModManager.EXTRA_MOD_DEVICE
public static final String ACTION_MOD_ENUMERATION_DONE
Extras include ModManager.EXTRA_VENDOR_ID
, ModManager.EXTRA_PRODUCT_ID
,
ModManager.EXTRA_UNIQUE_ID
, ModManager.EXTRA_VENDOR
ModManager.EXTRA_PRODUCT
and ModManager.EXTRA_MOD_DEVICE
public static final String ACTION_MOD_FIRMWARE_UPDATE_START
Extras include ModManager.EXTRA_VENDOR_ID
, ModManager.EXTRA_PRODUCT_ID
ModManager.EXTRA_UNIQUE_ID
.
public static final String ACTION_MOD_FIRMWARE_UPDATE_DONE
Extras include ModManager.EXTRA_VENDOR_ID
, ModManager.EXTRA_PRODUCT_ID
ModManager.EXTRA_UNIQUE_ID
,
ModManager.EXTRA_RESULT_CODE
and ModManager.EXTRA_REASON
.
public static final String ACTION_MOD_ATTACH_FAILED
Extras include ModManager.EXTRA_RESULT_CODE
, which is an error code defined
in android.os.OsConstant, and ModManager.EXTRA_VENDOR_ID
,
ModManager.EXTRA_PRODUCT_ID
, ModManager.EXTRA_UNIQUE_ID
public static final String ACTION_MOD_REQUEST_FIRMWARE
The extras of this intent is ModManager.EXTRA_MOD_DEVICE
;
receiver of this intent requires to have permission
ModManager.PERMISSION_MOD_ACCESS_INFO
.
public static final String ACTION_MOD_CAPABILITY_CHANGED
After receiving this intent, an appication can Use the API
ModDevice.getCapabilityLevel()
,
ModDevice.getCapabilityReason()
or
ModDevice.getCapabilityVendor()
to query the detailed changes;
the extras includes ModManager.EXTRA_MOD_DEVICE
.
public static final String ACTION_MOD_ERROR
The extra includes ModManager.EXTRA_MOD_ERROR
; receiver of this
intent is required to have permission ModManager.PERMISSION_MOD_ACCESS_INFO
.
public static final int MOD_EVENT_USB_CONFLICT
public static final int MOD_ERROR_SHORT_DETECTED
public static final int MOD_ERROR_SHORT_RECOVERY_FAIL
public static final int MOD_ERROR_RECOVERY_ATTEMPT
public static final int MOD_ERROR_RECOVERY_FAILED
public static final int MOD_ERROR_RECOVERY_SUCCESS
public static final int MOD_ERROR_COMMUNICATION_RESET
public static final int SUCCESS
ModManager.isModServicesAvailable(android.content.Context)
. ModManager.isModServicesAvailable(android.content.Context)
will
return ModManager.SUCCESS
when the device supports Moto Mod and minimum
Moto Mod platform version required by your application is supported on
the target device. This means the Moto ModService is there and compatible
with this device.public static final int SERVICE_MISSING
ModManager.isModServicesAvailable(android.content.Context)
. ModManager.isModServicesAvailable(android.content.Context)
will
return ModManager.SERVICE_MISSING
when the device on which your application
does not support the Moto Mod interface.public static final int SERVICE_UPDATING
ModManager.isModServicesAvailable(android.content.Context)
. ModManager.isModServicesAvailable(android.content.Context)
will
return ModManager.SERVICE_UPDATING
when the device supports Moto Mod
but the Moto ModManager service is being updated.public static final int SERVICE_VERSION_UPDATE_REQUIRED
ModManager.isModServicesAvailable(android.content.Context)
. ModManager.isModServicesAvailable(android.content.Context)
will
return ModManager.SERVICE_VERSION_UPDATE_REQUIRED
when the device
supports Moto Mod, but it needs to be updated; the client app should
prompt the user to update the ModService in
order to continue to use this App.public static final int SERVICE_DISABLED
ModManager.isModServicesAvailable(android.content.Context)
. When ModManager.isModServicesAvailable(android.content.Context)
returns ModManager.SERVICE_DISABLED
, then Moto ModService is available on the
target device, but currently disabled.public static final int SERVICE_INVALID
ModManager.isModServicesAvailable(android.content.Context)
. ModManager.isModServicesAvailable(android.content.Context)
will
return ModManager.SERVICE_INVALID
when the device on which your application
is running does not support the Moto Mod interface.public static final ComponentName MOD_SERVICE_NAME
ModManager.ACTION_BIND_MANAGER
to bind to the Moto Mod Service.public static final String EXTRA_VENDOR_ID
public static final String EXTRA_PRODUCT_ID
public static final String EXTRA_UNIQUE_ID
public static final String EXTRA_VENDOR
public static final String EXTRA_PRODUCT
public static final String EXTRA_RESULT_CODE
public static final String EXTRA_REASON
ModManager.EXTRA_RESULT_CODE
.public static final String EXTRA_PROTOCOLS
public static final String EXTRA_MOD_DEVICE
public static final String EXTRA_MOD_ERROR
ModManager.ACTION_MOD_ERROR
, the value include:
ModManager.MOD_ERROR_SHORT_DETECTED
,
ModManager.MOD_ERROR_SHORT_RECOVERY_FAIL
,
ModManager.MOD_ERROR_RECOVERY_FAILED
,
ModManager.MOD_ERROR_RECOVERY_ATTEMPT
,
ModManager.MOD_ERROR_RECOVERY_SUCCESS
,
ModManager.MOD_ERROR_COMMUNICATION_RESET
.public static final String PACKAGE_SCHEME
ModManager.getDefaultModPackage(com.motorola.mod.ModDevice)
to retrieve this package name or URI.public ModManager(Context context, IModManager manager)
ModManager.ACTION_BIND_MANAGER
).setComponent(
ModManager.MOD_SERVICE_NAME
), ...);IllegalStateException
- If your target SDK version is lower than
Android API level 23 (6.0)public boolean registerModListener(ModListener listener, int[] protocols)
listener
- - the callbackprotocols
- - This is an array of protocol IDs, that this listener
wants to get notified when a Moto Mod with these specified
protocols is attached/detached. The IDs are int value
of the Protocol
, or use
the constant value ModProtocol.PROTOCOL_ALL
to be notified of changes for all protocols. A null
value will unregister this listener.public List getModList(boolean onlineOnly) throws RemoteException
onlineOnly
- - true: return only attached Moto Mod;
false: return all known Moto ModRemoteException
public List getModList(int[] protocols, boolean onlineOnly) throws RemoteException
protocols
- - This is an array of protocol IDs, it could be used
as a filter, meaning only the ModDevice with these
protocols will be returned. Use the constant value
ModProtocol.PROTOCOL_ALL
if you don't care
the protocols. A null value will result null returnonlineOnly
- - true: return only attached Moto Mod;
false: return all known Moto ModRemoteException
public String getDefaultModPackage(ModDevice mod)
mod
- - the Moto Mod devicepublic List getConnectionsByDevice(ModDevice device) throws RemoteException
ModManager.PERMISSION_MOD_ACCESS_INFO
.device
- - The device we are going to inquiryRemoteException
public int requestUpdateFirmware(ModDevice device, List locations) throws RemoteException
This API will only work if a Moto Mod specifically allows unsecure flashing. This will only be functional for the Moto Mod developer kit and associated development board.
Note this API is an aynchronous call, it will return immediately without waiting for
the completion of the firmware update, caller of this API should listen on the
broadcast intent ModManager.ACTION_MOD_FIRMWARE_UPDATE_DONE
, and check the result via
ModManager.EXTRA_RESULT_CODE
.
device
- - The Moto Mod device we are going to update firmwarelocations
- - The location of the new firmwares, it's a list of firmware imagesRemoteException
public List getModInterfaceDelegationsByProtocol(ModDevice device, ModProtocol.Protocol protocol) throws RemoteException
RemoteException
public ParcelFileDescriptor openModInterface(ModInterfaceDelegation iface, int mode) throws RemoteException
ModManager.PERMISSION_USE_RAW_PROTOCOL
permission if the device is a raw device. Otherwise this is protected by
the ModManager.PERMISSION_MOD_INTERNAL
which is only available to system
appslications.iface
- - The instance of ModInterfaceDelegation to be openedmode
- - Read/Write, refer to AOSP android.os.ParcelFileDescriptorRemoteException
public final Object getClassManager(ModDevice device, ModProtocol.Protocol protocol)
Current available protocols are:
Protocol | Class Manager |
---|---|
ModProtocol.Protocol.BATTERY |
ModBattery |
ModProtocol.Protocol.MODS_DISPLAY |
ModDisplay |
ModProtocol.Protocol.LIGHTS |
ModBacklight |
device
- The Moto Mod device that the class interface manager will
operate on.protocol
- The protocol of the desired class interface managerpublic final Object getClassManager(ModDevice device, Class serviceClass)
Current available classes are:
ModBattery
,
ModDisplay
,
ModBacklight
device
- The Moto Mod device that the class interface manager will
operate on.serviceClass
- The class of the desired servicepublic final Object getClassManager(ModProtocol.Protocol protocol)
#getClassManager(ModDevice, Protocol)
.
It retrieves the current attached Moto Mod if and calls
#getClassManager(ModDevice, Protocol)
with the first Moto Mod device
passed from ModManager.getModList(boolean)
.protocol
- The protocol of the desired class interface managerpublic final Object getClassManager(Class serviceClass)
ModManager.getClassManager(ModDevice, Class)
. It
retrieves the current attached Moto Mod, and then calls
ModManager.getClassManager(ModDevice, Class)
with the first Moto Mod
device we get from ModManager.getModList(boolean)
.serviceClass
- The class of the desired servicepublic static int isModServicesAvailable(Context context)
In order to specify which Moto Mod service version your App is building against, you will need:
<meta-data android:name="com.motorola.mod.version" android:value="@integer/moto_mod_services_version" / >
After that, in your code you should call this API to check the availability of this service in the target device.
ModManager.SUCCESS
, ModManager.SERVICE_MISSING
,
ModManager.SERVICE_UPDATING
, ModManager.SERVICE_VERSION_UPDATE_REQUIRED
,
ModManager.SERVICE_DISABLED
, ModManager.SERVICE_INVALID
.public static int getModSdkVersion(Context context)
ModManager.getModPlatformSDKVersion()
to get the platform supported SDK version.context
- Caller's contextpublic static int getModPlatformSDKVersion()
ModManager.getModSdkVersion(Context)
to get the SDK version
supported by ModService.public boolean initSetupComplete(ModDevice device) throws RemoteException
device
- The Moto Mod deviceRemoteException
(c) 2016 Motorola Mobility LLC. All Rights Reserved
MOTOROLA and the Stylized M Logo are registered trademarks of Motorola Trademark Holdings, LLC
Android, Google, Google Play, Nexus and other marks are trademarks of Google Inc.