yy1717
2021-02-22 c3c7b977e5616950bfaedaa02008dfc40c6ade18
升级用到配置的省市ID
5个文件已修改
61 ■■■■■ 已修改文件
lib/src/main/cpp/native-lib.cpp 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/native-lib.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/rtk_platform/platform.cpp 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/java/com/anyun/exam/lib/RemoteService.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/java/com/anyun/exam/lib/Upgrade.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/native-lib.cpp
@@ -288,6 +288,37 @@
    }
}
void GetUpgrade(int province, int city)
{
    JNIEnv *env;
    bool ready_in_java_env = false;
    if (sg_jvm->GetEnv((void **)&env, JNI_VERSION_1_6) != JNI_OK) {
        // Attach主线程
        if (sg_jvm->AttachCurrentThread(&env, NULL) != JNI_OK) {
            LOGE("%s: AttachCurrentThread() failed", __FUNCTION__);
            return;
        }
    } else {
        ready_in_java_env = true;
    }
    jclass cls = env->GetObjectClass(sg_obj);
    jmethodID fun = env->GetMethodID(cls, "GetUpgrade", "(II)V");
    env->CallVoidMethod(sg_obj, fun, province, city);
    env->DeleteLocalRef(cls);
    if (!ready_in_java_env) {
        //Detach主线程
        if (sg_jvm->DetachCurrentThread() != JNI_OK) {
            LOGE("%s: DetachCurrentThread() failed", __FUNCTION__);
        }
    }
}
void SendToBluetooth(const uint8_t *data, int length)
{
    JNIEnv *env;
lib/src/main/cpp/native-lib.h
@@ -28,6 +28,7 @@
int PlayTTS(const char *string, void (*callback)(int));
int PlayTTS(std::string &tts, void (*callback)(int));
void PlayRing(void);
void GetUpgrade(int province, int city);
void SendToBluetooth(const uint8_t *data, int length);
void ConnectToBluetooth(const char *addr, const char *pin);
void DisconnectBluetooth(void);
lib/src/main/cpp/rtk_platform/platform.cpp
@@ -203,6 +203,7 @@
    eventQueue = NULL;
    memset(&platformStatus, 0, sizeof(platformStatus));
    memset(&deviceInfo, 0, sizeof(deviceInfo));
    sem_init(&sem_status_changed, 0, 0);
@@ -225,19 +226,27 @@
void ConfigPlatform(const rtk_platform_cfg_t *p)
{
    DEBUG("配置RTK平台资讯 sn %s device_model %s, imei %s, phone %02X%02X%02X%02X%02X%02X%02X%02X", p->device_sn, p->device_model, p->imei, p->phone[0],
    DEBUG("配置RTK平台资讯 sn %s device_model %s, imei %s, phone %02X%02X%02X%02X%02X%02X%02X%02X, province %d city %d",
            p->device_sn, p->device_model, p->imei, p->phone[0],
          p->phone[1],
          p->phone[2],
          p->phone[3],
          p->phone[4],
          p->phone[5],
          p->phone[6],
          p->phone[7]);
          p->phone[7],
          p->province,
          p->city);
    AppTimer_delete(ReqRtkPlatformConfigTimeout);
    strcpy(exceptSocket.domain_name, p->domain_name);
    exceptSocket.port = p->port;
    if (deviceInfo.province != p->province || deviceInfo.city != p->city) {
        GetUpgrade(p->province, p->city);
    }
    deviceInfo.province = p->province;
    deviceInfo.city = p->city;
    strcpy((char *)deviceInfo.device_model, p->device_model);
lib/src/main/java/com/anyun/exam/lib/RemoteService.java
@@ -133,7 +133,6 @@
//        new Thread(new AutoUpdateMcuThread(this)).start();
        upgrade = Upgrade.getInstance(getApplicationContext());
        upgrade.CheckUpgrade();
        ringUri = GetRingIndex(this, "Antimony");
//        PlayRing(this, ringUri);
@@ -429,6 +428,12 @@
        }
    }
    public void GetUpgrade(int province, int city) {
        if (upgrade != null) {
            upgrade.CheckUpgrade(province, city);
        }
    }
    public void ConnectBluetooth(String name, String pin) {
        if (mBluetooth != null && mChatService != null) {
            Log.d(TAG, "执行蓝牙连接请求 " + name);
lib/src/main/java/com/anyun/exam/lib/Upgrade.java
@@ -31,6 +31,9 @@
    private static final String newProgramIndUrl = "http://upgrade.safeluck.com/ftp/aykj4/aks3.json";
    private static Upgrade instance = null;
    private Context context;
    private int province;
    private int city;
    private DownloadManagerUtil downloadManagerUtil = null;
    private InstallUtil installUtil = null;
    private static final String SAVE_FILE_NAME = "aks3.apk";
@@ -219,7 +222,7 @@
            String result = CheckNewVersion(newProgramIndUrl);
            if (result != null) {
                DfuFileInfo dfuFileInfo = parseJson(result, 53, 100);
                DfuFileInfo dfuFileInfo = parseJson(result, province, city);
                if (dfuFileInfo != null && dfuFileInfo.getValid()) {
                    if (dfuFileInfo.getAppVerCode() > 0 && dfuFileInfo.getAppUrl() != null) {
                        if (installUtil.getVerCode() < dfuFileInfo.getAppVerCode()) {
@@ -248,7 +251,9 @@
        }
    };
    public void CheckUpgrade() {
    public void CheckUpgrade(int province, int city) {
        this.province = province;
        this.city = city;
        handlerCheckNewVersion.removeCallbacks(runnableCheckNewVersion);
        handlerCheckNewVersion.postDelayed(runnableCheckNewVersion, 100);
    }