connect fail 解决结果回调， 由 HMSAgentActivity 在 onActivityResult 中调用
@param result 解决结果
7504
void onResolveErrorRst(int result) {
        HMSAgentLog.d("result="+result);
        isResolving = false;
        resolveActivity = null;
        hasOverActivity = false;

        if(result == ConnectionResult.SUCCESS) {
            HuaweiApiClient client =  getApiClient();
            if (client != null && !client.isConnecting() && !client.isConnected() && curLeftResolveTimes > 0) {
                startConnect();
                return;
            }
        }

        onConnectEnd(result);
    }
887071
public ChatResult adaptResult(ComapiResult<?> result, Boolean success) {

        return new ChatResult(result.isSuccessful() && success, result.isSuccessful() ? null : new ChatResult.Error(result));
    }
1079693
@Override
    public void onConnect(int rst, HuaweiApiClient client) {
        if (client == null || !ApiClientMgr.INST.isConnect(client)) {
            HMSAgentLog.e("client not connted");
            onPushTokenResult(rst, null);
            return;
        }

        PendingResult<TokenResult> tokenResult = HuaweiPush.HuaweiPushApi.getToken(client);
        tokenResult.setResultCallback(new ResultCallback<TokenResult>() {
            @Override
            public void onResult(TokenResult result) {
                if (result == null) {
                    HMSAgentLog.e("result is null");
                    onPushTokenResult(HMSAgent.AgentResultCode.RESULT_IS_NULL, null);
                    return;
                }

                Status status = result.getStatus();
                if (status == null) {
                    HMSAgentLog.e("status is null");
                    onPushTokenResult(HMSAgent.AgentResultCode.STATUS_IS_NULL, null);
                    return;
                }

                int rstCode = status.getStatusCode();
                HMSAgentLog.d("status=" + status);
                // 需要重试的错误码，并且可以重试
                if ((rstCode == CommonCode.ErrorCode.SESSION_INVALID
                        || rstCode == CommonCode.ErrorCode.CLIENT_API_INVALID) && retryTimes > 0) {
                    retryTimes--;
                    connect();
                } else {
                    onPushTokenResult(rstCode, result);
                }
            }
        });
    }
261291
private void onSignInResult(int rstCode, SignInHuaweiId result) {
        HMSAgentLog.i("signIn:callback=" + StrUtils.objDesc(handler) +" retCode=" + rstCode);
        if (handler != null) {
            new Handler(Looper.getMainLooper()).post(new CallbackResultRunnable<SignInHuaweiId>(handler, rstCode, result));
            handler = null;
        }
        signInResultForDispose = null;
        retryTimes = MAX_RETRY_TIMES;
    }
522143
static void setResult(ImageView target, Context context, RequestHandler.Result result,
      boolean noFade, boolean debugging) {
    Drawable placeholder = target.getDrawable();
    if (placeholder instanceof Animatable) {
      ((Animatable) placeholder).stop();
    }

    Bitmap bitmap = result.getBitmap();
    if (bitmap != null) {
      Picasso.LoadedFrom loadedFrom = result.getLoadedFrom();
      PicassoDrawable drawable =
          new PicassoDrawable(context, bitmap, placeholder, loadedFrom, noFade, debugging);
      target.setImageDrawable(drawable);
      return;
    }

    Drawable drawable = result.getDrawable();
    if (drawable != null) {
      target.setImageDrawable(drawable);
      if (drawable instanceof Animatable) {
        ((Animatable) drawable).start();
      }
    }
  }
1032807
synchronized void result(@Nullable T res) {
        if (isFinished) {
            throw new RuntimeException("Promise " + this + " already completed!");
        }
        isFinished = true;
        result = res;
        deliverResult();
    }
268301
public static <R> MethodResult<R> failure(Throwable failure) {
        return new MethodResult<>(null, failure, false);
    }
955342
public Future<V> submit(Runnable task, V result) {
        if (task == null) throw new NullPointerException();
        NotifyingFuture<V> f = executor.submit(task, result);
        f.setListener(listener);
        return f;
    }
1254041
function (error, result) {
    // If the login method returns its result but the connection is lost
    // before the data is in the local cache, it'll set an onReconnect (see
    // above). The onReconnect will try to log in using the token, and *it*
    // will call userCallback via its own version of this
    // loggedInAndDataReadyCallback. So we don't have to do anything here.
    if (reconnected)
      return;

    // Note that we need to call this even if _suppressLoggingIn is true,
    // because it could be matching a _setLoggingIn(true) from a
    // half-completed pre-reconnect login method.
    Accounts._setLoggingIn(false);
    if (error || !result) {
      error = error || new Error(
        "No result from call to " + options.methodName);
      onceUserCallback(error);
      return;
    }
    try {
      options.validateResult(result);
    } catch (e) {
      onceUserCallback(e);
      return;
    }

    // Make the client logged in. (The user data should already be loaded!)
    makeClientLoggedIn(result.id, result.token, result.tokenExpires);
    onceUserCallback();
  }
269376
private ChannelFuture respond(Encodable result) {
    SocketAddress remoteAddress = channel.remoteAddress();
    return channel.writeAndFlush(result).addListener(future -> {
      if (future.isSuccess()) {
        logger.trace("Sent result {} to client {}", result, remoteAddress);
      } else {
        logger.error(String.format("Error sending result %s to %s; closing connection",
          result, remoteAddress), future.cause());
        channel.close();
      }
    });
  }
1355235
public void onActivityResult(int requestCode, int resultCode, Intent data) {
        onActivityResult(requestCode, resultCode, data, null);
    }
1056757
@Override
    protected  void checkDeviceConnection(DeviceProxy device,
                        String attribute, DeviceData deviceData, String event_name) throws DevFailed {

        String deviceName = device.name();
        if (!device_channel_map.containsKey(deviceName)) {
            connect(device, attribute, event_name, deviceData);
            if (!device_channel_map.containsKey(deviceName)) {
                Except.throw_event_system_failed("API_NotificationServiceFailed",
                        "Failed to connect to event channel for device",
                        "EventConsumer.subscribe_event()");
            }
        }
    }
808718
public void record(CircuitBreakerStateImpl.CircuitBreakerResult result) {
        boolean isFailure = (result == FAILURE);
        if (resultCount < size) {
            // Window is not yet full
            resultCount++;
        } else {
            // Window is full, roll off the oldest result
            boolean oldestResultIsFailure = results.get(nextResultIndex);
            if (oldestResultIsFailure) {
                failures--;
            }
        }

        results.set(nextResultIndex, isFailure);
        if (isFailure) {
            failures++;
        }

        nextResultIndex++;
        if (nextResultIndex >= size) {
            nextResultIndex = 0;
        }
    }
660069
@Override
    public void onConnected() {
        HMSAgentLog.d("connect success");
        timeoutHandler.removeMessages(APICLIENT_TIMEOUT_HANDLE_MSG);
        onConnectEnd(ConnectionResult.SUCCESS);
    }
444442
@Override
    public void onConnect(int rst, HuaweiApiClient client) {

        HMSAgentLog.d("onConnect:" + rst);

        if (client == null || !ApiClientMgr.INST.isConnect(client)) {
            HMSAgentLog.e("client not connted");
            onLoginResult(rst, null);
            return;
        }

        Activity curActivity = ActivityMgr.INST.getLastActivity();
        if (curActivity == null) {
            HMSAgentLog.e("activity is null");
            onLoginResult(HMSAgent.AgentResultCode.NO_ACTIVITY_FOR_USE, null);
            return;
        }

        /**
         * 调用login接口，传入成功回调。 此回调仅在成功时回调。
         */
        HMSAgentLog.d("begin login by HMS-SDK");
        PendingResult<GameLoginResult> loginPending = HuaweiGame.HuaweiGameApi.login(client, curActivity, forceLogin, new GameLoginHandler(){

            @Override
            public void onResult(int retCode, GameUserData userData) {
                HMSAgentLog.d("onResult:retCode=" + retCode + "  userData=" + StrUtils.objDesc(userData));
                onLoginResult(retCode, userData);
            }

            @Override
            public void onChange() {
                HMSAgentLog.d("onChange");

                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    @Override
                    public void run() {
                        if (handler != null) {
                            handler.onChange();
                        }
                    }
                });
            }
        });

        loginPending.setResultCallback(new ResultCallback<GameLoginResult>() {
            @Override
            public void onResult(GameLoginResult result) {

                if (result == null) {
                    HMSAgentLog.e("result is null");
                    onLoginResult(HMSAgent.AgentResultCode.RESULT_IS_NULL, null);
                    return;
                }

                Status status = result.getStatus();
                if (status == null) {
                    HMSAgentLog.e("status is null");
                    onLoginResult(HMSAgent.AgentResultCode.STATUS_IS_NULL, null);
                    return;
                }

                int rstCode = status.getStatusCode();
                HMSAgentLog.d("status=" + status);

                if (!result.getStatus().isSuccess()) {
                    // 需要重试的错误码，并且可以重试
                    if ((rstCode == CommonCode.ErrorCode.SESSION_INVALID
                            || rstCode == CommonCode.ErrorCode.CLIENT_API_INVALID) && retryTimes > 0) {
                        retryTimes--;
                        connect();
                    } else {
                        onLoginResult(rstCode, null);
                    }
                } else {
                    // 经确认，成功的情况下会走上面handler里面的2个回调,
                    // 这边不需要任何处理
                }
            }
        });
    }
1148631
private void addResult(ValidationResult result) {
		if (result == null || result.count() == 0) {
			return;
		}
		this.results.add(result);
	}
395711
private void connectionFailed() {
        // Send a failure message back to the Activity
        Message msg = mHandler.obtainMessage(ISOBlueDemo.MESSAGE_TOAST);
        Bundle bundle = new Bundle();
        bundle.putString(ISOBlueDemo.TOAST, "Unable to connect device");
        msg.setData(bundle);
        mHandler.sendMessage(msg);

        // Start the service over to restart listening mode
        BluetoothService.this.start();
    }