华为盒子无法获取EPG SERVER和TOKEN问题
Showing
1 changed file
with
30 additions
and
12 deletions
| 1 | package org.cocos2dx.javascript.common; | 1 | package org.cocos2dx.javascript.common; |
| 2 | 2 | ||
| 3 | import android.app.AlertDialog; | 3 | import android.app.AlertDialog; |
| 4 | import android.content.ContentResolver; | ||
| 4 | import android.content.Context; | 5 | import android.content.Context; |
| 5 | import android.content.DialogInterface; | 6 | import android.content.DialogInterface; |
| 6 | import android.content.Intent; | 7 | import android.content.Intent; |
| ... | @@ -92,13 +93,20 @@ public class CommonUtils { | ... | @@ -92,13 +93,20 @@ public class CommonUtils { |
| 92 | 93 | ||
| 93 | 94 | ||
| 94 | public static String getToken(Context context) { | 95 | public static String getToken(Context context) { |
| 95 | String value = ""; | 96 | String userToken = ""; |
| 96 | Uri uri = Uri.parse("content://stbconfig/authentication/user_token"); | 97 | Uri uri = Uri.parse("content://stbconfig/authentication"); |
| 97 | Cursor c = null; | 98 | Cursor c = null; |
| 98 | try { | 99 | try { |
| 99 | c = context.getContentResolver().query(uri, null, "name = ?", new String[]{"user_token"}, null); // 建议使用这种name=?参数化的查询语句来操作 | 100 | ContentResolver cr = context.getContentResolver(); |
| 100 | if (c != null && c.moveToFirst()) { | 101 | c = cr.query(uri, null, null, null, null); |
| 101 | value = c.getString(c.getColumnIndex("value")); | 102 | while (null != c && c.moveToNext()) { |
| 103 | String name = c.getString(c.getColumnIndex("name")); | ||
| 104 | String value = c.getString(c.getColumnIndex("value")); | ||
| 105 | Log.d(TAG, name + ": " + value); | ||
| 106 | if (TextUtils.equals(name, "user_token")) { | ||
| 107 | userToken = value; | ||
| 108 | break; | ||
| 109 | } | ||
| 102 | } | 110 | } |
| 103 | } catch (Exception e) { | 111 | } catch (Exception e) { |
| 104 | e.printStackTrace(); | 112 | e.printStackTrace(); |
| ... | @@ -108,17 +116,26 @@ public class CommonUtils { | ... | @@ -108,17 +116,26 @@ public class CommonUtils { |
| 108 | } | 116 | } |
| 109 | } | 117 | } |
| 110 | // Log.d(TAG, "获取机顶盒token..." + value); | 118 | // Log.d(TAG, "获取机顶盒token..." + value); |
| 111 | return value; | 119 | Log.d(TAG, "got user token: " + userToken); |
| 120 | return userToken; | ||
| 112 | } | 121 | } |
| 113 | 122 | ||
| 114 | public static String getServer(Context context) { | 123 | public static String getServer(Context context) { |
| 115 | String value = ""; | 124 | String epgServer = ""; |
| 116 | Uri uri = Uri.parse("content://stbconfig/authentication/epg_server"); | 125 | // Uri uri = Uri.parse("content://stbconfig/authentication/epg_server"); |
| 126 | Uri uri = Uri.parse("content://stbconfig/authentication"); | ||
| 117 | Cursor c = null; | 127 | Cursor c = null; |
| 118 | try { | 128 | try { |
| 119 | c = context.getContentResolver().query(uri, null, "name = ?", new String[]{"epg_server"}, null); // 建议使用这种name=?参数化的查询语句来操作 | 129 | ContentResolver cr = context.getContentResolver(); |
| 120 | if (c != null && c.moveToFirst()) { | 130 | c = cr.query(uri, null, null, null, null); |
| 121 | value = c.getString(c.getColumnIndex("value")); | 131 | while (null != c && c.moveToNext()) { |
| 132 | String name = c.getString(c.getColumnIndex("name")); | ||
| 133 | String value = c.getString(c.getColumnIndex("value")); | ||
| 134 | Log.d(TAG, name + ": " + value); | ||
| 135 | if (TextUtils.equals(name, "epg_server")) { | ||
| 136 | epgServer = value; | ||
| 137 | break; | ||
| 138 | } | ||
| 122 | } | 139 | } |
| 123 | } catch (Exception e) { | 140 | } catch (Exception e) { |
| 124 | e.printStackTrace(); | 141 | e.printStackTrace(); |
| ... | @@ -128,7 +145,8 @@ public class CommonUtils { | ... | @@ -128,7 +145,8 @@ public class CommonUtils { |
| 128 | } | 145 | } |
| 129 | } | 146 | } |
| 130 | // Log.d(TAG, "获取机顶盒token..." + value); | 147 | // Log.d(TAG, "获取机顶盒token..." + value); |
| 131 | return value; | 148 | Log.d(TAG, "got epg server: " + epgServer); |
| 149 | return epgServer; | ||
| 132 | } | 150 | } |
| 133 | 151 | ||
| 134 | //检查网络 | 152 | //检查网络 | ... | ... |
-
Please register or sign in to post a comment