繁体   English   中英

棒棒糖更新后无法正常工作的HTC ONE M8 IR Blaster

[英]HTC ONE M8 IR Blaster after Lollipop Update not working

我需要在HTC One设备上使用红外发射器。 在lolipop更新之前我可以做到这一点没有问题,但现在我的代码不起作用。

    ConsumerIrManager mCIR = (ConsumerIrManager)getSystemService(Context.CONSUMER_IR_SERVICE);
    mCIR.transmit(freq, pat);

其中freq和pattern是我的电视所需的值(来自制造商)

运行此代码时没有任何错误,唯一的问题是红外发射器没有点亮HTC一个设备。 (通过相机观看ir blaster)。 我不明白,完全相同的代码适用于galaxy s5设备。 我非常感谢能够让红外线工作在HTC设备上的人的任何帮助。

是的,这个问题似乎已在Android的官方错误跟踪器上报告

我正在开发一个使用Android 4.4 KitKat中引入的官方消费者IR API的应用程序。 自从Lollipop推出HTC One M8或三星Galaxy S5等流行设备后,我收到许多来自所述设备的用户的报告,我的应用程序没有在Lollipop上工作。 我自己没有Lollipop设备,但我借了M8并做了一些测试。

似乎ConsumerIrManager.transmit()方法是Lollipop上的无操作方法。 无论是给出模式,它都会立即返回。

在发现Galaxy S5用户遇到同样的问题之前,我就此问题联系了HTC支持,并被告知要联系Google支持。

似乎S5设备也遇到了同样的问题,虽然很难说,因为开发人员从S5所有者那里获得了相互矛盾的报道。

这是一个仅限HTC的修复程序 ,由于Lollipop更新,有人在M7停止工作后找到了它。 在他们切换到官方Google的api之前,他基本上恢复了早期版本的IR HTC API

否则,您应该在错误跟踪器上加注问题,并指出您自己的用户也可以这样做。 人们对此问题的关注度越高,优先级就越高。

我刚刚为三星设备解决了这个问题:

在Android 4.4.3之前,模式的每个元素都是开/关脉冲的周期数。

对于Android 4.4.3及以上版本的每个元素,如果开/关脉冲的微秒数。

例:

发射0.5s,0.5 off,0.5 on,38000Hz的波

在Android 4.4.3之前,你的模式是[19000,190000,19000] - 19000来自0.5s * 38000Hz

对于Android 4.4.3+,您的模式将是[500000,500000,500000] - 即您每次转换为微秒(我们)。

我要责怪谷歌这个:在4.4.3发布之前,他们的API表示要使用周期数,4.4.3之后更改为使用微秒(我们),三星只是按照API这样打破我们的应用。

*编辑:此修复程序的更新版本可在此处找到: https//stackoverflow.com/a/28934938/1042362

试一试:

/*
 * preforms some calculations on the codesets we have in order to make them work with certain models of phone.
 *
 * HTC devices need formula 1
 * Samsungs want formula 2
 *
 * Samsung Pre-4.4.3 want nothing, so just return the input data
 *
 */
private static int[] string2dec(int[] irData, int frequency) {
    int formula = shouldEquationRun();

    //Should we run any computations on the irData?
    if (formula != 0) {
        for (int i = 0; i < irData.length; i++) {
            if (formula == 1) {
                irData[i] = irData[i] * 1000000 / frequency; 
            } else if (formula == 2) {
                irData[i] = (int) Math.ceil(irData[i] * 26.27272727272727); //this is the samsung formula as per http://developer.samsung.com/android/technical-docs/Workaround-to-solve-issues-with-the-ConsumerIrManager-in-Android-version-lower-than-4-4-3-KitKat
            }
        }
    }
    return irData;
}

/*
 * This method figures out if we should be running the equation in string2dec,
 * which is based on the type of device. Some need it to run in order to function, some need it NOT to run
 *
 * HTC needs it on (HTC One M8)
 * Samsung needs occasionally a special formula, depending on the version
 * Android 5.0+ need it on. 
 * Other devices DO NOT need anything special.
 */
private static int shouldEquationRun() {
    //Some notes on what Build.X will return
    //System.out.println(Build.MODEL); //One M8
    //System.out.println(Build.MANUFACTURER); //htc
    //System.out.println(Build.VERSION.SDK_INT); //19

    //Samsung's way of finding out if their OS is too new to work without a formula:
    //int lastIdx = Build.VERSION.RELEASE.lastIndexOf(".");
    //System.out.println(Build.VERSION.RELEASE.substring(lastIdx+1)); //4

    //handle HTC
    if (Build.MANUFACTURER.equalsIgnoreCase("HTC")) {
        return 1;
    }
    //handle Lollipop (Android 5.0.1 == SDK 21) / beyond
    if (Build.VERSION.SDK_INT >= 21) {
        return 1;
    }
    //handle Samsung PRE-Android 5
    if (Build.MANUFACTURER.equalsIgnoreCase("SAMSUNG")) {
        if (Build.VERSION.SDK_INT >= 19) {
            int lastIdx = Build.VERSION.RELEASE.lastIndexOf(".");
            int VERSION_MR = Integer.valueOf(Build.VERSION.RELEASE.substring(lastIdx + 1));
            if (VERSION_MR < 3) {
                // Before version of Android 4.4.2
                //Note: NO formula here, not even the other one
                return 0;
            } else {
                // Later version of Android 4.4.3
                //run the special samsung formula here
                return 2;
            }
        }
    }
    //if something else...
    return 0;
}

库存遥控器自4月底以来一直停止。 下载剥离应用程序,它是M9上使用的品牌版本。

我在HTC One M7上的经验:1)KitKat 4.4.3 ConsumerIRManager代码工作正常,传递了一个微秒的数组。

2)更新到Lolipop 5.0.2并且IR Led没有传输,即无操作问题。 我重构了我的代码以使用HTC API,它需要“时钟滴答”而不是直接微秒的波形。 现在一切正常。

似乎我们不能在HTC One上使用ConsumerIRManager,除非是非常具体的版本,即4.4.3。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM