Commit 4b684c1e 4b684c1ed475a7faf5e386a6625cba656a2159b8 by 胡国瑞

华为盒子无法获取EPG SERVER和TOKEN问题

1 parent a730aac7
package org.cocos2dx.javascript.common;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
......@@ -92,13 +93,20 @@ public class CommonUtils {
public static String getToken(Context context) {
String value = "";
Uri uri = Uri.parse("content://stbconfig/authentication/user_token");
String userToken = "";
Uri uri = Uri.parse("content://stbconfig/authentication");
Cursor c = null;
try {
c = context.getContentResolver().query(uri, null, "name = ?", new String[]{"user_token"}, null); // 建议使用这种name=?参数化的查询语句来操作
if (c != null && c.moveToFirst()) {
value = c.getString(c.getColumnIndex("value"));
ContentResolver cr = context.getContentResolver();
c = cr.query(uri, null, null, null, null);
while (null != c && c.moveToNext()) {
String name = c.getString(c.getColumnIndex("name"));
String value = c.getString(c.getColumnIndex("value"));
Log.d(TAG, name + ": " + value);
if (TextUtils.equals(name, "user_token")) {
userToken = value;
break;
}
}
} catch (Exception e) {
e.printStackTrace();
......@@ -108,17 +116,26 @@ public class CommonUtils {
}
}
// Log.d(TAG, "获取机顶盒token..." + value);
return value;
Log.d(TAG, "got user token: " + userToken);
return userToken;
}
public static String getServer(Context context) {
String value = "";
Uri uri = Uri.parse("content://stbconfig/authentication/epg_server");
String epgServer = "";
// Uri uri = Uri.parse("content://stbconfig/authentication/epg_server");
Uri uri = Uri.parse("content://stbconfig/authentication");
Cursor c = null;
try {
c = context.getContentResolver().query(uri, null, "name = ?", new String[]{"epg_server"}, null); // 建议使用这种name=?参数化的查询语句来操作
if (c != null && c.moveToFirst()) {
value = c.getString(c.getColumnIndex("value"));
ContentResolver cr = context.getContentResolver();
c = cr.query(uri, null, null, null, null);
while (null != c && c.moveToNext()) {
String name = c.getString(c.getColumnIndex("name"));
String value = c.getString(c.getColumnIndex("value"));
Log.d(TAG, name + ": " + value);
if (TextUtils.equals(name, "epg_server")) {
epgServer = value;
break;
}
}
} catch (Exception e) {
e.printStackTrace();
......@@ -128,7 +145,8 @@ public class CommonUtils {
}
}
// Log.d(TAG, "获取机顶盒token..." + value);
return value;
Log.d(TAG, "got epg server: " + epgServer);
return epgServer;
}
//检查网络
......