Remote device management service

Remote Device Management Service is built on the DataTransactor and used for the remote control of the remote device.

Basic concept

RemoteDeviceService

It is used to manage the watch connected to the mobile phone. It provides the function of installing / deleting / querying the application, monitoring the status of the remote device, inquiring the remote device information, and releasing the bonding relationship with the watch. Features.

RemoteDeviceServiceManager

It represents the remote device manager. It is the interface provided by the remote device management service. The remote device management operation can be performed by the user as long as the device object is acquired.

RemoteCallbackList

The remote device management service allows multiple client accesses, access to the results obtained through the callback in the form of the need for clients to register the relevant callback to the list of the callback list, the remote device management services to access the remote device management service client callback list,

How to use

The Remote Device Management service is a subservice of the IWDS system service, which is used in accordance with the IWDS service framework.

ServiceClient mServiceClient = new ServiceClient(mContext,
                RemoteDeviceServiceManager.SERVICE_REMOTE_DEVICE, mConnectionCallbacks);
mServiceClient.connect();
//inmConnectionCallbacks's onConnected get RemoteDeviceServiceManager instance

public void onConnected(ServiceClient serviceClient) {
    mRemoteDeviceManager = (RemoteDeviceServiceManager) serviceClient.getServiceManagerContext();
    ... ...
    mRemoteDeviceManager.registerUnbondListener(m_remoteDeviceUnbondListener);// mRemoteDeviceBondListener listen result
    mRemoteDeviceManager.requestNotifyUnbond(mBondLink.getLocalDescriptor()); // unbond
    ... ...
}

Interface

/**
     * {@link RemoteDeviceAppListener#onRemoteAppInfoListAvailable(List)} return
     */
    public void requestGetAppList();

    /**
     * {@link RemoteDeviceAppListener#onRemoteStorageInfoAvailable(RemoteStorageInfo)}
     * return。
     */
    public void requestGetStorageInfo();

    /**
     * {@link RemoteDeviceAppListener#onDoneInstallApp(String, int)}return。
     * 
     * @param apkFilePath
     * @param isInstalledInExternal
     *
     */
    public void requestInstallApp(String apkFilePath, boolean isInstalledInExternal);

    /**
     * {@link RemoteDeviceAppListener#onDoneDeleteApp(String, int)}
     * 
     * @param packageName
     */
    public void requestDeleteApp(String packageName);

    /**
     * {@link RemoteDeviceAppListener#onResponsePkgSizeInfo(PackageStats, int)}
     * @param packageName
     */
    public void requestPkgSizeInfo(String packageName);

    /**
     * {@link RemoteDeviceAppListener#onResponseClearAppDataOrCache(String, int, int)}
     * 
     * @param packageName
     * @param requestType
     *            {@link RemoteDeviceManagerInfo#TYPE_CLEAR_APP_USER_DATA},
     *            {@link RemoteDeviceManagerInfo#TYPE_CLEAR_APP_CACHE}
     */
    public void requestClearAppDataOrCache(String packageName, int requestType);

    /**
     * {@link RemoteDeviceAppListener#onResponseClearAllAppDataAndCache(int, int, String, int, int)}
     */
    public void requestClearAllAppDataAndCache();

    /**
     * {@link RemoteDeviceProcessListener#onResponseSystemMemoryInfo(long, long)}
     */
    public void requestSystemMemoryInfo();

    /**
     * {@link RemoteDeviceProcessListener#onResponseRunningAppProcessInfo(List)}
     */
    public void requestRunningAppProcessInfo();

    /**
     * {@link RemoteDeviceProcessListener#onDoneKillProcess(String)}
     * 
     * @param packageName
     */
    public void requestKillProcess(String packageName);

    /**
     *
     * @param decctiptor
     */
    public void requestNotifyUnbond(DeviceDescriptor descriptor);

   /**
     *
     * @param listener
     * @return
     */
    public boolean registerUnbondListener(RemoteDeviceUnbondListener listener);

    /**
     */
    public void unregisterUnbondListener();

    ... ...

There are also paired registerXXXListener, unregisterXXXListener registered to log out of the interface for monitoring or remote device management operations to take the results.

Bond and unbond:

  • Bonding and unbonding operations are initiated by the mobile phone, the watch is a passive acceptance. For bonding, the mobile phone  scans the QR code in the watch to obtain its bluetooth address,  and calls bondAddress method to bond the watch. One phone can only bonds one watch, and the bonding request will be refused when the watch was bonded by other phone.

    

private boolean bondAddressLocked(String pkg, String addr) {

        if (mIsBondWatch && mBondDescriptor != null
                && !mBondDescriptor.devAddress.equals(addr)) {
            return false;
        }
        … … //then call Link's bondAddress
}

  • For unbonding,  the mobile phone needs to call requestNotifyUnbond method in the remote device management, and the unbonding result could be got by RemoteDeviceUnbondListener. Please refer to our demo's code: elf/WatchManager/src/com/ingenic/watchmanager/service/IwdsMobileServiceProxy.java.

    

	private RemoteDeviceUnbondListener mRemoteDeviceBondListener = new RemoteDeviceUnbondListener() {
        @Override
        public void onResquestDeviceUnbondResult(int resultCode) {

            if (resultCode == RemoteDeviceManagerInfo.REQUEST_SUCCEEDED
                    || resultCode == RemoteDeviceManagerInfo.REQUEST_NOTIFY_UNBOND_FAILED) {
                synchronized (mLocked) {
                    mIsBondWatch = false;
                    mBondDescriptor = null;
	      IwdsUtils.saveBondStatus(mContext, mIsBondWatch);
                    IwdsUtils.saveBondDescriptor(mContext, mBondDescriptor);

                }
            }
        }
    };
	mRemoteDeviceManager.registerUnbondListener(mRemoteDeviceBondListener);

mRemoteDeviceManager.requestNotifyUnbond(mBondLink.getLocalDescriptor());