Service and Binder(2)

Aidl生成的接口文件:

 IRemoteService.java

/*
 * This file is auto-generated.  DO NOT MODIFY.
 * Original file: C:\\Documents and Settings\\qujianhua\\ApiTest\\src\\com\\bst\\test\\IRemoteService.aidl
 */
package com.bst.test;

/**
 * Example of defining an interface for calling on to a remote service (running
 * in another process).
 */
public interface IRemoteService extends android.os.IInterface {
	/** Local-side IPC implementation stub class. */
	public static abstract class Stub extends android.os.Binder implements
			com.bst.test.IRemoteService {
		private static final java.lang.String DESCRIPTOR = "com.bst.test.IRemoteService";

		/** Construct the stub at attach it to the interface. */
		public Stub() {
			this.attachInterface(this, DESCRIPTOR);
		}

		/**
		 * Cast an IBinder object into an com.bst.test.IRemoteService interface,
		 * generating a proxy if needed.
		 */
		public static com.bst.test.IRemoteService asInterface(
				android.os.IBinder obj) {
			if ((obj == null)) {
				return null;
			}
			android.os.IInterface iin = (android.os.IInterface) obj
					.queryLocalInterface(DESCRIPTOR);
			if (((iin != null) && (iin instanceof com.bst.test.IRemoteService))) {
				return ((com.bst.test.IRemoteService) iin);
			}
			return new com.bst.test.IRemoteService.Stub.Proxy(obj);
		}

		public android.os.IBinder asBinder() {
			return this;
		}

		@Override
		public boolean onTransact(int code, android.os.Parcel data,
				android.os.Parcel reply, int flags)
				throws android.os.RemoteException {
			switch (code) {
			case INTERFACE_TRANSACTION: {
				reply.writeString(DESCRIPTOR);
				return true;
			}
			case TRANSACTION_registerCallback: {
				data.enforceInterface(DESCRIPTOR);
				com.bst.test.IRemoteServiceCallback _arg0;
				_arg0 = com.bst.test.IRemoteServiceCallback.Stub
						.asInterface(data.readStrongBinder());
				this.registerCallback(_arg0);
				reply.writeNoException();
				return true;
			}
			case TRANSACTION_unregisterCallback: {
				data.enforceInterface(DESCRIPTOR);
				com.bst.test.IRemoteServiceCallback _arg0;
				_arg0 = com.bst.test.IRemoteServiceCallback.Stub
						.asInterface(data.readStrongBinder());
				this.unregisterCallback(_arg0);
				reply.writeNoException();
				return true;
			}
			case TRANSACTION_updateValue: {
				data.enforceInterface(DESCRIPTOR);
				this.updateValue();
				reply.writeNoException();
				return true;
			}
			}
			return super.onTransact(code, data, reply, flags);
		}

		private static class Proxy implements com.bst.test.IRemoteService {
			private android.os.IBinder mRemote;

			Proxy(android.os.IBinder remote) {
				mRemote = remote;
			}

			public android.os.IBinder asBinder() {
				return mRemote;
			}

			public java.lang.String getInterfaceDescriptor() {
				return DESCRIPTOR;
			}

			/**
			 * Often you want to allow a service to call back to its clients.
			 * This shows how to do so, by registering a callback interface with
			 * the service.
			 */
			public void registerCallback(com.bst.test.IRemoteServiceCallback cb)
					throws android.os.RemoteException {
				android.os.Parcel _data = android.os.Parcel.obtain();
				android.os.Parcel _reply = android.os.Parcel.obtain();
				try {
					_data.writeInterfaceToken(DESCRIPTOR);
					_data.writeStrongBinder((((cb != null)) ? (cb.asBinder())
							: (null)));
					mRemote.transact(Stub.TRANSACTION_registerCallback, _data,
							_reply, 0);
					_reply.readException();
				} finally {
					_reply.recycle();
					_data.recycle();
				}
			}

			/**
			 * Remove a previously registered callback interface.
			 */
			public void unregisterCallback(
					com.bst.test.IRemoteServiceCallback cb)
					throws android.os.RemoteException {
				android.os.Parcel _data = android.os.Parcel.obtain();
				android.os.Parcel _reply = android.os.Parcel.obtain();
				try {
					_data.writeInterfaceToken(DESCRIPTOR);
					_data.writeStrongBinder((((cb != null)) ? (cb.asBinder())
							: (null)));
					mRemote.transact(Stub.TRANSACTION_unregisterCallback,
							_data, _reply, 0);
					_reply.readException();
				} finally {
					_reply.recycle();
					_data.recycle();
				}
			}

			public void updateValue() throws android.os.RemoteException {
				android.os.Parcel _data = android.os.Parcel.obtain();
				android.os.Parcel _reply = android.os.Parcel.obtain();
				try {
					_data.writeInterfaceToken(DESCRIPTOR);
					mRemote.transact(Stub.TRANSACTION_updateValue, _data,
							_reply, 0);
					_reply.readException();
				} finally {
					_reply.recycle();
					_data.recycle();
				}
			}
		}

		static final int TRANSACTION_registerCallback = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
		static final int TRANSACTION_unregisterCallback = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
		static final int TRANSACTION_updateValue = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
	}

	/**
	 * Often you want to allow a service to call back to its clients. This shows
	 * how to do so, by registering a callback interface with the service.
	 */
	public void registerCallback(com.bst.test.IRemoteServiceCallback cb)
			throws android.os.RemoteException;

	/**
	 * Remove a previously registered callback interface.
	 */
	public void unregisterCallback(com.bst.test.IRemoteServiceCallback cb)
			throws android.os.RemoteException;

	public void updateValue() throws android.os.RemoteException;
}


IRemoteServiceCallback.java

/*
 * This file is auto-generated.  DO NOT MODIFY.
 * Original file: C:\\Documents and Settings\\qujianhua\\ApiTest\\src\\com\\bst\\test\\IRemoteServiceCallback.aidl
 */
package com.bst.test;

/**
 * Example of a callback interface used by IRemoteService to send synchronous
 * notifications back to its clients. Note that this is a one-way interface so
 * the server does not block waiting for the client.
 */
public interface IRemoteServiceCallback extends android.os.IInterface {
	/** Local-side IPC implementation stub class. */
	public static abstract class Stub extends android.os.Binder implements
			com.bst.test.IRemoteServiceCallback {
		private static final java.lang.String DESCRIPTOR = "com.bst.test.IRemoteServiceCallback";

		/** Construct the stub at attach it to the interface. */
		public Stub() {
			this.attachInterface(this, DESCRIPTOR);
		}

		/**
		 * Cast an IBinder object into an com.bst.test.IRemoteServiceCallback
		 * interface, generating a proxy if needed.
		 */
		public static com.bst.test.IRemoteServiceCallback asInterface(
				android.os.IBinder obj) {
			if ((obj == null)) {
				return null;
			}
			android.os.IInterface iin = (android.os.IInterface) obj
					.queryLocalInterface(DESCRIPTOR);
			if (((iin != null) && (iin instanceof com.bst.test.IRemoteServiceCallback))) {
				return ((com.bst.test.IRemoteServiceCallback) iin);
			}
			return new com.bst.test.IRemoteServiceCallback.Stub.Proxy(obj);
		}

		public android.os.IBinder asBinder() {
			return this;
		}

		@Override
		public boolean onTransact(int code, android.os.Parcel data,
				android.os.Parcel reply, int flags)
				throws android.os.RemoteException {
			switch (code) {
			case INTERFACE_TRANSACTION: {
				reply.writeString(DESCRIPTOR);
				return true;
			}
			case TRANSACTION_valueChanged: {
				data.enforceInterface(DESCRIPTOR);
				int _arg0;
				_arg0 = data.readInt();
				this.valueChanged(_arg0);
				return true;
			}
			}
			return super.onTransact(code, data, reply, flags);
		}

		private static class Proxy implements
				com.bst.test.IRemoteServiceCallback {
			private android.os.IBinder mRemote;

			Proxy(android.os.IBinder remote) {
				mRemote = remote;
			}

			public android.os.IBinder asBinder() {
				return mRemote;
			}

			public java.lang.String getInterfaceDescriptor() {
				return DESCRIPTOR;
			}

			/**
			 * Called when the service has a new value for you.
			 */
			public void valueChanged(int value)
					throws android.os.RemoteException {
				android.os.Parcel _data = android.os.Parcel.obtain();
				try {
					_data.writeInterfaceToken(DESCRIPTOR);
					_data.writeInt(value);
					mRemote.transact(Stub.TRANSACTION_valueChanged, _data,
							null, android.os.IBinder.FLAG_ONEWAY);
				} finally {
					_data.recycle();
				}
			}
		}

		static final int TRANSACTION_valueChanged = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
	}

	/**
	 * Called when the service has a new value for you.
	 */
	public void valueChanged(int value) throws android.os.RemoteException;
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值