Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d5b16e3 authored by Timo Wendt's avatar Timo Wendt Committed by Gerrit Code Review
Browse files

Irda: Add Irda System Service

This is not a perfect solution yet, but it does work and should therefore be a starting point.
It needs work to be functional on devices other than the Galaxy S4

* The Irda service is not started by default. It can be enabled via overlay.
* Uses a HAL module to communicate with sysfs

Change-Id: If0c4b2e59144b1f199c44add399a3f528ac11e5b
parent 723a590f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ LOCAL_SRC_FILES += \
	core/java/android/app/IActivityController.aidl \
	core/java/android/app/IActivityPendingResult.aidl \
	core/java/android/app/IAlarmManager.aidl \
	core/java/android/hardware/IIrdaManager.aidl \
	core/java/android/app/IBackupAgent.aidl \
	core/java/android/app/IInstrumentationWatcher.aidl \
	core/java/android/app/INotificationManager.aidl \
+9 −0
Original line number Diff line number Diff line
@@ -87,6 +87,8 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.IPowerManager;
import android.os.IUserManager;
import android.hardware.IIrdaManager;
import android.hardware.IrdaManager;
import android.os.Looper;
import android.os.PowerManager;
import android.os.Process;
@@ -574,6 +576,13 @@ class ContextImpl extends Context {
                    IFmTransmitter service = IFmTransmitter.Stub.asInterface(b);
                    return new FmTransmitterImpl(service);
                }});

        registerService(IRDA_SERVICE, new StaticServiceFetcher() {
                public Object createStaticService() {
                    IBinder b = ServiceManager.getService(IRDA_SERVICE);
                    IIrdaManager service = IIrdaManager.Stub.asInterface(b);
                    return new IrdaManager(service);
                }});
    }

    static ContextImpl getImpl(Context context) {
+15 −0
Original line number Diff line number Diff line
@@ -1769,6 +1769,9 @@ public abstract class Context {
     *  <dt> {@link #ALARM_SERVICE} ("alarm")
     *  <dd> A {@link android.app.AlarmManager} for receiving intents at the
     *  time of your choosing.
     *  <dt> {@link #IRDA_SERVICE} ("irda")
     *  <dd> A {@link android.hardware.IrdaManager} for sending IR codes
     *  with the IR emitter
     *  <dt> {@link #NOTIFICATION_SERVICE} ("notification")
     *  <dd> A {@link android.app.NotificationManager} for informing the user
     *   of background events.
@@ -1816,6 +1819,8 @@ public abstract class Context {
     * @see android.os.PowerManager
     * @see #ALARM_SERVICE
     * @see android.app.AlarmManager
     * @see #IRDA_SERVICE
     * @see android.hardware.IrdaManager
     * @see #NOTIFICATION_SERVICE
     * @see android.app.NotificationManager
     * @see #KEYGUARD_SERVICE
@@ -1907,6 +1912,16 @@ public abstract class Context {
     */
    public static final String ALARM_SERVICE = "alarm";

    /**
     * Use with {@link #getSystemService} to retrieve a
     * {@link android.hardware.IrdaManager} for sending IR codes
     * with the IR emitter
     *
     * @see #getSystemService
     * @see android.hardware.IrdaManager
     */
    public static final String IRDA_SERVICE = "irda";

    /**
     * Use with {@link #getSystemService} to retrieve a
     * {@link android.app.NotificationManager} for informing the user of
+28 −0
Original line number Diff line number Diff line
/* //device/java/android/android/hardware/IIrdaManager.aidl
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
package android.hardware;

/**
 * System private API for talking with the irda service.
 *
 * {@hide}
 */
interface IIrdaManager {
    void write_irsend(String code);
}

+77 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware;

import android.os.RemoteException;

/**
 * This class provides access to the system irda services.
 *
 * <p>You do not
 * instantiate this class directly; instead, retrieve it through
 * {@link android.content.Context#getSystemService
 * Context.getSystemService(Context.IRDA_SERVICE)}.
 */
public class IrdaManager
{
    private final IIrdaManager mService;

    /**
     * package private on purpose
     */
    public IrdaManager(IIrdaManager service) {
        mService = service;
    }

    /**
     * Send IR code via the emitter
     *
     * The format of the code can be converted from the pronto format
     * as follows
     *
     * Example pronto code:
     * 0000 006D 0000 0022 00AC 00AB 0015 0041 0015 0041 0015 0041 0015
     * 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0041 0015 0041
     * 0015 0041 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015
     * 0016 0015 0016 0015 0016 0015 0041 0015 0041 0015 0016 0015 0016
     * 0015 0041 0015 0041 0015 0041 0015 0041 0015 0016 0015 0016 0015
     * 0041 0015 0041 0015 0016 0015 0689
     *
     * 1. word 0000: not needed
     * 2. word 006D: this has to be converted to the frequency as follows:
     *    first vonvert it to decimal 109
     *    now caculate the frequency 1000000/(109 * .241246) = 38000 rounded
     * 3. word 0000: not needed
     * 4. word 0022: not needed
     * all the remaining numbers have to be converted to decimal
     *
     * now build a comma separated string without spaces with the frequency
     * and the remaining numbers as follows:
     *
     * 38000,172,171,21,65,21,65,21,65,21,22,21,22,21,22,21,22,21,22,21,65,
     * 21,65,21,65,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,65,21,
     * 65,21,22,21,22,21,65,21,65,21,65,21,65,21,22,21,22,21,65,21,65,21,22,
     * 21,1673
     *
     */
    public void write_irsend(String code) {
        try {
            mService.write_irsend(code);
        } catch (RemoteException ex) {
        }
    }
}
Loading