1

当我在 android 上使用 apache http 客户端时,我在 logcat 中收到一条可疑消息。

I/APACHE HTTP (thCr=2252) - NafHttpAuthStrategyDefault(9949): (thUse=2252) NafHttpAuthStrategyDefault()
I/APACHE HTTP (thCr=2252) - NafHttpAuthStrategyDefault(9949): (thUse=2252)    cached value : gbaSupportIsPossible=null
I/APACHE HTTP (thCr=2252) - NafHttpAuthStrategyDefault(9949): (thUse=2252)    The current context is NOT a context of GBA service.
I/APACHE HTTP (thCr=2252) - GbaSupportPermissionRequestCheckerImpl(9949): (thUse=2252) isCurrentProcessRequestedGba()#finished   result=false
I/APACHE HTTP (thCr=2252) - GbaSupportPermissionRequestCheckerImpl(9949): (thUse=2252) isCurrentProcessAllowedToUseGba()#started   result=false
I/APACHE HTTP (thCr=2252) - NafHttpAuthStrategyDefault(9949): (thUse=2252)    The GBA permission wasn't requested for this process.
I/APACHE HTTP (thCr=2252) - NafHttpAuthStrategyDefault(9949): (thUse=2252) It is impossible to support GBA now (many possible reasons: no Android Context, current client is GBA service, etc.), then it will be just usual HTTP.
I/APACHE HTTP (thCr=2252) - NafRequestExecutorWrapperRedirectionHandler(9949): (thUse=2252)    It isn't GBA flow, redirection responses are not handled.

我只是像下面这样使用:

HttpClient httpClient = new DefaultHttpClient();
HttpContext httpContext = new BasicHttpContext();

HttpPost postRequest = new HttpPost(url);
postRequest.addHeader("User-Agent", String.format("%s %s %s %s %s", Build.MANUFACTURER, Build.MODEL, Build.PRODUCT, Build.CPU_ABI, Config.appStr));

MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

reqEntity.addPart("sessionId", new StringBody(sessionId));

ByteArrayBody bab = new ByteArrayBody(afp, "afp");
reqEntity.addPart("afp", bab);

if (pcm != null)
{
    ByteArrayBody bab2 = new ByteArrayBody(pcm, "pcm");
    reqEntity.addPart("pcm", bab2);
}

postRequest.setEntity(reqEntity);

HttpResponse response = httpClient.execute(postRequest, httpContext);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
String sResponse;
StringBuilder s = new StringBuilder();
while ((sResponse = reader.readLine()) != null) {
    s = s.append(sResponse);
    System.out.println(sResponse);
}

GBA 服务的含义是什么?我怎样才能获得GBA许可?收到消息后,发送此请求的线程看起来像是遇到异常并被停止。我在 Galaxy Notes 上执行了代码。

4

5 回答 5

4

GBA - 通用引导架构(由 3GPP 标准定义的身份验证机制)... http://en.wikipedia.org/wiki/Generic_Bootstrapping_Architecture了解更多信息。

在 Galaxy Note 上(我相信它是 T-mobile 版本),T-mobile 修改了 APACHE HTTP 客户端,包括用于通过 WiFi 进行身份验证的 GBA 客户端,尤其是通过 WiFi 上的 MMS。

问题是为什么要使用GBA?它通常用于使用 ISIM 密钥进行身份验证,运营商将其用于他们的服务。

如果您的应用程序是常规应用程序,您最好的选择是坚持使用默认的 android HTTP 客户端,并且不要使用 Apache HTTP 客户端。

于 2012-12-18T00:34:30.153 回答
2

简短版:忽略消息。

支持 WiFi 通话和其他一些功能的 T-Mobile 设备使用称为 GBA 的 GSM 移动标准来通过 T-Mobile 验证其服务。有问题的消息是日志语句,表明您的应用程序未被识别为 T-Mobile 应用程序,因此 GBA 不会在请求标头中进行广告。如果您确实支持 GBA,您将看到的唯一区别是在您的请求的用户代理标头中包含“gba”。

如果您的客户端与之通信的服务器应用程序支持 GBA,那么开发人员应该与 T-Mobile 有关系,并且可以告诉您如何在您的应用程序中启用 GBA 身份验证。

于 2013-05-17T00:46:33.203 回答
1

我相信您所指的 GBA 服务在此处进行了描述:http ://en.wikipedia.org/wiki/Generic_Bootstrapping_Architecture

我的日志中也出现了该消息,但网络连接对我来说仍然成功完成。

有一次我在尝试从主线程建立网络连接时遇到异常,我认为这是不允许的。

于 2012-08-14T16:36:20.803 回答
0

您应该更改为 HttpURLConnection,这是使用 HTTP 服务的首选方式。您可以在此处了解更多信息:

http://android-developers.blogspot.com.br/2011/09/androids-http-clients.html

于 2013-04-03T18:25:29.793 回答
0

卸载应用程序后修复,重新安装!

于 2015-03-11T12:55:49.043 回答