|
@@ -7,11 +7,16 @@ import android.media.AudioManager;
|
|
|
|
|
|
import android.net.Uri;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Looper;
|
|
|
import android.util.Log;
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
|
|
|
import androidx.core.content.FileProvider;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ch.jedge.llm.filter.glm.service.TVMufisService;
|
|
|
import com.changhong.qlib.QData;
|
|
|
import com.changhong.qlib.intf.QIData;
|
|
@@ -21,16 +26,28 @@ import com.changhong.tvos.common.exception.TVManagerNotInitException;
|
|
|
import com.changhong.tvos.model.ChOsType;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
+import okhttp3.Headers;
|
|
|
+import okhttp3.MediaType;
|
|
|
+import okhttp3.OkHttpClient;
|
|
|
+import okhttp3.Request;
|
|
|
+import okhttp3.RequestBody;
|
|
|
+import okhttp3.Response;
|
|
|
+import okhttp3.ResponseBody;
|
|
|
|
|
|
public class JeageTVBridge {
|
|
|
|
|
|
private static JeageTVBridge bridge = null;
|
|
|
private TVMufisService tvMufisService;
|
|
|
|
|
|
+ private static Toast toast;
|
|
|
+
|
|
|
private JeageTVBridge(){
|
|
|
|
|
|
}
|
|
@@ -51,6 +68,7 @@ public class JeageTVBridge {
|
|
|
// MsgContent msg = new MsgContent(content, MsgContent.TYPE_RECEIVED);
|
|
|
String msg = "glm@"+content;
|
|
|
tvMufisService.brodcastMsg(msg);
|
|
|
+ makeToast(content);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -59,6 +77,7 @@ public class JeageTVBridge {
|
|
|
// MsgContent msg = new MsgContent(content, MsgContent.TYPE_SENT);
|
|
|
String msg = "user@"+content;
|
|
|
tvMufisService.brodcastMsg(msg);
|
|
|
+ makeToast(content);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -79,6 +98,20 @@ public class JeageTVBridge {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void makeToast(String msg){
|
|
|
+ Handler handler = new Handler(Looper.getMainLooper());
|
|
|
+ handler.post(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ if(toast != null)
|
|
|
+ toast.cancel();
|
|
|
+
|
|
|
+ toast = Toast.makeText(tvMufisService, msg, Toast.LENGTH_SHORT);
|
|
|
+ toast.show();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
public void TVsetVolume(int volume) {
|
|
|
if((volume<0)||(volume>100))
|
|
|
return;
|
|
@@ -182,7 +215,7 @@ public class JeageTVBridge {
|
|
|
else {
|
|
|
for(HashMap<String, String>hmap : mapList){
|
|
|
String fname = hmap.get("name");
|
|
|
- if(name.equals(fname)) {
|
|
|
+ if(name.equals(fname)||fname.contains(name)) {
|
|
|
file = hmap.get("path");
|
|
|
break;
|
|
|
}
|
|
@@ -225,7 +258,7 @@ public class JeageTVBridge {
|
|
|
else {
|
|
|
for(HashMap<String, String>hmap : mapList){
|
|
|
String fname = hmap.get("name");
|
|
|
- if(name.equals(fname)) {
|
|
|
+ if(name.equals(fname)||fname.contains(name)) {
|
|
|
file = hmap.get("path");
|
|
|
break;
|
|
|
}
|
|
@@ -249,4 +282,85 @@ public class JeageTVBridge {
|
|
|
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE,true);
|
|
|
tvMufisService.startActivity(intent);
|
|
|
}
|
|
|
+
|
|
|
+ public void TVplayMovie(String name) {
|
|
|
+ String url = "http://124.70.7.59/chiq_webservice/services?appKey=mr3z5f&method=ch.tvmall.chiq.voice.search&v=3&format=json";
|
|
|
+
|
|
|
+ JSONObject root = new JSONObject();
|
|
|
+ JSONObject client = new JSONObject();
|
|
|
+
|
|
|
+ client.put("agent_name", "com.changhong.chrecommendersystem");
|
|
|
+ client.put("agent_ver", "2.1.12");
|
|
|
+ client.put("device", "TV");
|
|
|
+ client.put("mac", "b4:9e:80:b0:99:1f");
|
|
|
+// client.put("tv_model", "75Q10ART");
|
|
|
+ client.put("clienttype", "CH-ZM110ART-DTV-00-ICNTV");
|
|
|
+ client.put("tv_version", "ZM110ART_0.00031");
|
|
|
+
|
|
|
+ root.put("client", client);
|
|
|
+ root.put("providerCode", "chiq3");
|
|
|
+ root.put("resIconType", "VER_MIDDLE");
|
|
|
+ root.put("safeFlag", "2");
|
|
|
+ root.put("searchName", name);
|
|
|
+ root.put("searchDomain", "video");
|
|
|
+ root.put("sequence", 1);
|
|
|
+ root.put("word", "我想看"+name);
|
|
|
+ root.put("version", "5");
|
|
|
+
|
|
|
+ String reqBodyStr = root.toString();
|
|
|
+ RequestBody formBody = RequestBody.create(MediaType.get("application/json; charset=utf-8"), reqBodyStr);
|
|
|
+
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", "application/json; charset=utf-8");
|
|
|
+// headers.put("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
|
|
|
+ headers.put("Accept", "application/json; charset=utf-8");
|
|
|
+
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(url)
|
|
|
+ .post(formBody)
|
|
|
+ .headers(Headers.of(headers))
|
|
|
+ .build();
|
|
|
+
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
+ .connectTimeout(5, TimeUnit.SECONDS)
|
|
|
+ .readTimeout(3, TimeUnit.MINUTES)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ Response okHttpResp;
|
|
|
+ String resultDataStr;
|
|
|
+ JSONObject resp;
|
|
|
+ try {
|
|
|
+ okHttpResp = okHttpClient.newCall(request).execute();
|
|
|
+ ResponseBody respBody = okHttpResp.body();
|
|
|
+ resultDataStr = respBody.string();
|
|
|
+ resp = JSONObject.parseObject(resultDataStr);
|
|
|
+ JSONObject content = resp.getJSONObject("content");
|
|
|
+ String code = content.getString("code");
|
|
|
+ if(code!=null) {
|
|
|
+ if("1000".equals(code)) {
|
|
|
+ JSONArray resources = content.getJSONArray("resources");
|
|
|
+ if(resources.size() > 0) {
|
|
|
+ JSONObject job = resources.getJSONObject(0);
|
|
|
+ JSONObject startintent = job.getJSONObject("startintent");
|
|
|
+ String action = startintent.getString("action");
|
|
|
+ String pkgname = startintent.getString("pkgname");
|
|
|
+ String clsname = startintent.getString("clsname");
|
|
|
+ String starttype = startintent.getString("starttype");
|
|
|
+ String uri = startintent.getString("uri");
|
|
|
+
|
|
|
+ Intent intent = new Intent();
|
|
|
+
|
|
|
+ intent.setPackage(pkgname);
|
|
|
+ intent.setAction(action);
|
|
|
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
|
|
+ | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
|
+ intent.setData(Uri.parse(uri));
|
|
|
+ tvMufisService.startActivity(intent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|