簡體   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