package com.example.aperture.core;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;


/** Base class for a module.
*/
public abstract class Module extends Service {


    /** Intent extra key for a plain text query.
    */
    public final static String QUERY_TEXT =
            "com.example.aperture.core.Module.QUERY_TEXT";

    /** Intent extra key for a plain text response from a module.
    */
    public final static String RESPONSE_TEXT =
            "com.example.aperture.core.Moduel.RESPONSE_TEXT";

    /** Intent extra key for an icon response from a module. Not currently
    used, but will be incorporated in the future as part of the results.
    */
    public final static String RESPONSE_THUMBNAIL =
            "com.example.aperture.core.Moduel.RESPONSE_THUMBNAIL";


    /** Singleton instance of the exposed interface for a module.
    Not strictly a singleton, but effectively so because there should only
    ever be one instance of a particular module.
    @see com.example.aperture.core.IModule, an AIDL-generated interface.
    */
    protected IBinder mBinder = null;


    /** Return the communication channel to this module.

    @param intent The Intent used to bind to this module. Must have the action
    {@link com.example.aperture.core.ModuleManagement#ACTION_BIND_MODULE}.

    @return an IBinder through which other contexts may query this module, or
    <code>null</code> if an incorrect action is supplied.
    */
    public IBinder onBind(Intent intent) {
        if(intent.getAction().equals(ModuleManagement.ACTION_BIND_MODULE)) {
            if(mBinder == null) {
                mBinder = createBinder();
            }
            return mBinder;
        }
        else return null;
    }


    /** Create the communication channel to this module.
    <p>The IBinder instance constructed here must extend
    {@link com.example.aperture.core.IModule.Stub} as generated by AIDL.</p>
    <p>Queries are provided as extras in the input Intent parameter, under keys
    defined in the constants above.</p>
    <p>Responses are computed by the IBinder instance and sent back to the
    requesting context in a List. Each response should consist of zero or more
    well-formed Intents; i.e. each response should be immediately usable as the
    parameter to <code>Context.startActivity()</code>. Custom response text
    (and, in the future, icons) can be set by adding the appropriate extras to
    the response Intent.</p>
    @return An {@link com.example.aperture.core.IModule.Stub} instance.
    */
    protected abstract IBinder createBinder();

}

package com.example.aperture.core;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;


/** Base class for a module.
*/
public abstract class Module extends Service {


    /** Intent extra key for a plain text query.
    */
    public final static String QUERY_TEXT =
            "com.example.aperture.core.Module.QUERY_TEXT";

    /** Intent extra key for a plain text response from a module.
    */
    public final static String RESPONSE_TEXT =
            "com.example.aperture.core.Module.RESPONSE_TEXT";

    /** Intent extra key for an icon response from a module. Not currently
    used, but will be incorporated in the future as part of the results.
    */
    public final static String RESPONSE_THUMBNAIL =
            "com.example.aperture.core.Module.RESPONSE_THUMBNAIL";


    /** Singleton instance of the exposed interface for a module.
    Not strictly a singleton, but effectively so because there should only
    ever be one instance of a particular module.
    @see com.example.aperture.core.IModule, an AIDL-generated interface.
    */
    protected IBinder mBinder = null;


    /** Return the communication channel to this module.

    @param intent The Intent used to bind to this module. Must have the action
    {@link com.example.aperture.core.ModuleManagement#ACTION_BIND_MODULE}.

    @return an IBinder through which other contexts may query this module, or
    <code>null</code> if an incorrect action is supplied.
    */
    public IBinder onBind(Intent intent) {
        if(intent.getAction().equals(ModuleManagement.ACTION_BIND_MODULE)) {
            if(mBinder == null) {
                mBinder = createBinder();
            }
            return mBinder;
        }
        else return null;
    }


    /** Create the communication channel to this module.
    <p>The IBinder instance constructed here must extend
    {@link com.example.aperture.core.IModule.Stub} as generated by AIDL.</p>
    <p>Queries are provided as extras in the input Intent parameter, under keys
    defined in the constants above.</p>
    <p>Responses are computed by the IBinder instance and sent back to the
    requesting context in a List. Each response should consist of zero or more
    well-formed Intents; i.e. each response should be immediately usable as the
    parameter to <code>Context.startActivity()</code>. Custom response text
    (and, in the future, icons) can be set by adding the appropriate extras to
    the response Intent.</p>
    @return An {@link com.example.aperture.core.IModule.Stub} instance.
    */
    protected abstract IBinder createBinder();

}

Fix spelling of Module.