[DEV] Acessing IR interface

Peacemaker2000

New member
Oct 29, 2011
1
7
0
I just started developing for my new Sony tablet and was curious if I can send IR codes with my own app instead of using the Sony app. Here is what I've achieved so far. Maybe someone finds this information usefull and maybe we can provide further information based on this.

The service kinda works, the callbacks get called, I can read raw commands using learnKey() method and I can get the keys for specific devices using getKeyList() but sending IR pattern or key codes to devices seems not to be working quire right, although the callback gets status OK after sending.

Sony created a DataProvider to share data between the app and the service. Thanks to this fact I queried following URI content://com.sony.nfx.app.irremote.provider/learnt and found all custom learnt codes I added via the Sony app. But even using this exact data doesn't seem to do anything when sending to the device.

Access to IR service is restricted by permission and process so our AndroidManifest.xml should look like this:

Code:
<uses-permission android:name="com.sony.nfx.app.irremoteservice.permission.EXECUTE_SERVICE"/>
<application ... android:process=":remote">
   ...
</application>
Required AIDL files:
Code:
package com.sony.nfx.app.irremoteservice;

import com.sony.nfx.app.irremoteservice.IUEIControlServiceCallback; 

interface IUEIControlService {

	int sendKey(int i, int j, int k, byte byte0);
	int sendSonyCode(int i, int j, byte byte0, int k, byte byte1);
	int sendIRPattern(int i, int j, byte byte0, in byte[] pattern);
	int sendStopIRSend(int i);
	int getKeyList(int i, int j);
	int learnKey(int i);
	void registerCallback(IUEIControlServiceCallback callback);
	void unregisterCallback(IUEIControlServiceCallback callback);

}
Code:
package com.sony.nfx.app.irremoteservice;

interface IUEIControlServiceCallback {

	void onCommandComplete(int i, int j);
	void onLearntKey(int i, in byte[] abyte0);
	void onGetKeyList(int i, int j, in int[] ai);

}
Basic sample code:
Code:
package ir.remote.android;

import java.util.Arrays;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

import com.sony.nfx.app.irremoteservice.IUEIControlService;
import com.sony.nfx.app.irremoteservice.IUEIControlServiceCallback;

public class RemoteTest extends Activity implements ServiceConnection {

	private static final String LOG_TAG = "RemoteTest";

	private ServiceBinder serviceBinder = new ServiceBinder();
	private IUEIControlService remoteService = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		String serviceAction = IUEIControlService.class.getName();
		Intent serviceIntent = new Intent(serviceAction);
		bindService(serviceIntent, this, Context.BIND_AUTO_CREATE);
	}

	public void onServiceConnected(ComponentName name, IBinder service) {
		try {
			Log.d(LOG_TAG, "Service connected!");
			remoteService = IUEIControlService.Stub.asInterface(service);
			remoteService.registerCallback(serviceBinder);
		} catch (Exception e) {
			Log.e(LOG_TAG, "Error connecting to service!", e);
		}
	}

	public void onServiceDisconnected(ComponentName name) {
		Log.d(LOG_TAG, "Service disconnected!");
		remoteService = null;
	}

	public static class ServiceBinder extends IUEIControlServiceCallback.Stub {

		public void onCommandComplete(int i, int j) throws RemoteException {
			Log.d(LOG_TAG, "onCommandComplete(" + i + ", " + j + ")");
		}

		public void onGetKeyList(int i, int j, int[] ai) throws RemoteException {
			Log.d(LOG_TAG, "onGetKeyList(" + i + ", " + j + ", " + Arrays.toString(ai) + ")");
		}

		public void onLearntKey(int key, byte[] value) throws RemoteException {
			Log.d(LOG_TAG, "onLearntKey(" + key + ", " + Arrays.toString(value) + ")");
		}

	}

}
 
Last edited:

lbretth

Member
Jan 1, 2005
22
3
0
London
Good start

I'm really glad to see someone working on accessing the IR interface. The IR is the primary differentiator that made me decide to buy the Sony Tablet S. I haven't got it yet though, getting it on Monday evening.

I'm only a noob at development, but have started learning Android dev and the start you've made is bound to help. So thanks a lot.

I look forward to seeing your progress.

Luke
 
  • Like
Reactions: psxpetey

TomitomHTC

New member
Sep 17, 2009
2
0
0
Hello Peacemaker2000,

I'm quite new to programing on android (and in java for that matter) so, sorry for the noob questions here.

I have just received my sony tablet last week-end and I think building a custom remote to my needs would be a great hands on exercice :)

Also I'm a bit disapointed by the natif app which doe not support macro nor look customizaton.

I have tried to start working with all your samples and code to see what I can get to work, but my first concern is about the AIDL files, how do you import the "com.sony.nfx.app.irremoteservice.IUEIControlServiceCallback" ?
The only file that i have found on my tablet, in a "framewok" folder somewhere is "com.sony.nfx.app.irremoteserviceif.jar", I have tried to referenced it by adding to the build path but it is as far as I have been for now.

Any more help / explanation would be greatly appreciated !

Thanks,
Tom.
 

CHRIS-AUDIO

Member
Dec 23, 2011
10
2
0
Good Job Peacemaker,

Main reason i bought it is universal remote control (of course i m an android fan also). If you think that you have to pay 2000$ for a philips pronto remote, SONY did a good start. I am waiting for a customized remote software so to be able to add new buttons, keys etc.

Thank you,
Chris
 

arw01

Member
Jun 12, 2010
35
1
0
+1 for me. the ability to have a custom layed out remote with macros and such, I would buy that app.

I ASSUME you have signed up for the sony developers kit they just released, I dl'd it but don't have the time to get into development currently.

Alan
 

TomitomHTC

New member
Sep 17, 2009
2
0
0
I did subscripbe and download the sdk but only found samples / references for the largescreen / dualscreen layout of the 2 sony tablets, nothing related to the IR.
 

Bojanglez

Senior Member
May 21, 2010
96
10
0
I did look in to doing something with the IR blaster but couldn't find anything about how to access it. I might start digging around to build the app I was thinking of in my time off over Christmas :)
 
Last edited:

CHRIS-AUDIO

Member
Dec 23, 2011
10
2
0
Hello to everybody and i wish you a Happy New Year!!!!!!!!!

Any news about IR?

I wonder who will make a new software remote control more customizable, with macros, buttons etc.

Chris
Athens GREECE
 

fingerstoo

Senior Member
Apr 28, 2008
206
1
0
I agree with everyone so far about wanting a better app than the remote control one supplied by Sony. I tried learning a macro from my PDA with its universal remote control app, but it refused to learn it. It was OK with single key presses, indeed it is very sensitive.

I bought the Tablet S for my wife, simply because of the eBook reader capability amongst other things but also as a trial for a new replacement universal remote control. This is the first device for ages to have an IR facility built in. I use an old HP Jornada but the screen is mis-behaving after around 10 years of hard labour as a Universal Remote Control. I have found the ability to program my own designed GUI for my numerous cinema, TV etc. devices has been excellent. The Tablet S app is OK in that it has enough keys to cover most remotes. The facility to be able to re-label the keys and choose which of the icons can be which keys is good. It is slightly limited as most of the icons on the left hand panel are fixed labels. Therefore it could be improved.

I would support anyone writing such an app. I would even pay for it! Now that's novel..... Good luck developers.
 
Jan 17, 2012
26
40
0
Thank you so much Peacemaker2000 for sharing your code and ideas.

It works like a charm getting the keys from a remote control and using the data for your own app. I would really like to know what kind of parameters you have to send to get a full keylist of a TV.

Right now I'm just saving the key data from my remote control and don't have any clues how to generally get all possible keys my TV understands. Would be great if you or anybody else who knows this, could share it with us. :)

If anybody would like to have a functional piece of code from my current prototype, just let me know, right now I have no problems of controlling my Sony Bravia KDL-32W4000.
 
Jan 17, 2012
26
40
0
Seems to be quite easy to get a keylist from the actual service:

Code:
int REMOTE_TYPE_ID_KDL_32W4000 = 508;
remoteService.getKeyList(0, REMOTE_TYPE_ID_KDL_32W4000);
You'll get the list in IUEIControlServiceCallback.Stub.onGetKeyList() and execute the appropriate key with:

Code:
int REMOTE_TYPE_ID_KDL_32W4000 = 508;
int ON_OFF_KEY = 18;
remoteService.sendKey(0, REMOTE_TYPE_ID_KDL_32W4000, ON_OFF_KEY, (byte) 0);
remoteService.sendStopIRSend(0);

There you go, TV goes on and off. ;)
 

Maine_Coon

Senior Member
Sep 24, 2009
670
119
0
I will donate to anyone developing better IR control app.

It will put all that smart LCD screen remotes that they are selling for $1000 and more out of existence.

There is an example of really good IR remote control application. Extremely feature rich. It is called RemoteControl II from http://wincesoft.de/html/remotecontrol_ii.html.
It is only available for Windows CE/Mobile devices.
 

pisur2

New member
Apr 13, 2012
1
0
0
Paris
Hi,

I'm an Android beginner developer.
I recently bought a Sony Tablet S and trying to create my own IR Remote App...why?

Sony default IR Remote App don't provides macros.

Here are the main features i'm thiking about:
  1. A dialog box popup automatically when tablet is removed from his dock and shaked...this is managed by a local service)
  2. This dialog provides two options : 1) Default usage of the tablet or 2) Launch my own IR Remote App
  3. This custom App provides only 2 macros : 1) Listen to music or 2) Watch TV

Main challenges i'm facing (as you can easily imagine) is the IR interface implementation.
There's not much code sample on the web, probably because Sony Tablet S is the only device on the market embedding IR interface.

Here are my questions :
  1. Do some one has successfully experienced this technology ?
  2. Is it necessary to root the device before coding with IR interface ?
  3. Do Sony provides specific library to access to IR interface ?
  4. I suppose that each device that i want to remote control (Denon amplifier AVR-2311 and DVico Tvix 6600n for music listening) has an Infrared Hex Code. How do i use it in my classes ?

Waiting for your help :confused:

Regards
 

jameslindsey

Member
Dec 2, 2004
27
8
0
I for one am very interested in any application that comes close to a Philips Pronto in respect of functionality. The ability to design your own buttons and layouts as wll as have macros is all that is missing from the sony software and I'm sure its possible.
My Pronto is over 10 years old now and one of the reasons for purchasing the Tablet s was as a replacement.

Have a look at the pronto forums on remotecentral.com theres a vast array of downloads of layouts for Pronto edit and hence the hex codes which can be extracted. Many include discrete codes that can't be learned from remotes and are invaluable for macros.
You can also obtain the original editing software and load onto a virtual pronto. If you can produce an ap anything like that then I think you're onto a winner.

Apologies I'm unable to assist on a coding front as I'm a bit of a technonumpty.
 

agc93

Senior Member
Mar 14, 2011
348
83
0
Brisbane
Another very confused developer here trying to work out how Sony's bizarre remote calls function. To be honest, not having much luck, and Sony won't help.

If anyone knows how to get it going, please share, because that's all thats stopping me at the moment.
 
Jan 17, 2012
26
40
0
I already posted a working example for sending an IR signal with the tablet. ;-)

I'm also working on an own app with makro-capabilities, custom button layouting (own text, pictures, size, placement) and even custom gestures. I think I can give out a demo in about two weeks, so be a little bit more patient. ;-)

Of course the app will only work with the Tablet S. :D