'Waits for the current application to idle or window update event occurs.
Usage:
d.wait.idle(timeout=1000)
d.wait.update(timeout=1000, package_name="com.android.settings")'

@property
def wait(self):

    @param_to_property(action=['idle', 'update'])
    def _wait(action, timeout=1000, package_name=None):
        if (((timeout / 1000) + 5) > int(os.environ.get('JSONRPC_TIMEOUT', 90))):
            http_timeout = ((timeout / 1000) + 5)
        else:
            http_timeout = int(os.environ.get('JSONRPC_TIMEOUT', 90))
        if (action == 'idle'):
            return self.server.jsonrpc_wrap(timeout=http_timeout).waitForIdle(timeout)
        elif (action == 'update'):
            return self.server.jsonrpc_wrap(timeout=http_timeout).waitForWindowUpdate(package_name, timeout)
    return _wait
