[Sony Tablet S] Peacemaker2000:
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:

<uses-permission android:name="com.sony.nfx.app.irremoteservice.permission.EXECUTE_SERVICE"/>
<application ... android:process=":remote">
...
</application>

Required AIDL files:

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);

}

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:

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) + ")");
}

}

}