| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.stubs.am; |
| 18 |
|
| 19 |
import android.app.Service; |
| 20 |
import android.content.Intent; |
| 21 |
import android.os.Binder; |
| 22 |
import android.os.Bundle; |
| 23 |
import android.os.IBinder; |
| 24 |
import android.os.Message; |
| 25 |
import android.os.Messenger; |
| 26 |
import android.os.RemoteException; |
| 27 |
import android.util.Log; |
| 28 |
|
| 29 |
import com.android.frameworks.perftests.am.util.Constants; |
| 30 |
|
| 31 |
public class TestService extends Service { |
| 32 |
private static final String TAG = "TestService"; |
| 33 |
private static final boolean VERBOSE = InitService.VERBOSE; |
| 34 |
|
| 35 |
private Binder mStub = new Binder(); |
| 36 |
|
| 37 |
@Override |
| 38 |
public IBinder onBind(Intent intent) { |
| 39 |
if (VERBOSE) { |
| 40 |
Log.i(TAG, getPackageName() + " onBind()"); |
| 41 |
} |
| 42 |
return mStub; |
| 43 |
} |
| 44 |
|
| 45 |
@Override |
| 46 |
public int onStartCommand(Intent intent, int flags, int startId) { |
| 47 |
if (VERBOSE) { |
| 48 |
Log.i(TAG, getPackageName() + " onStartCommand()"); |
| 49 |
} |
| 50 |
return START_NOT_STICKY; |
| 51 |
} |
| 52 |
|
| 53 |
@Override |
| 54 |
public boolean onUnbind(Intent intent) { |
| 55 |
if (VERBOSE) { |
| 56 |
Log.i(TAG, getPackageName() + " onUnbind()"); |
| 57 |
} |
| 58 |
Messenger messenger = intent.getParcelableExtra(Constants.EXTRA_RECEIVER_CALLBACK); |
| 59 |
Message msg = Message.obtain(); |
| 60 |
msg.what = Constants.MSG_UNBIND_DONE; |
| 61 |
Bundle b = new Bundle(); |
| 62 |
b.putString(Constants.EXTRA_SOURCE_PACKAGE, getPackageName()); |
| 63 |
msg.obj = b; |
| 64 |
try { |
| 65 |
messenger.send(msg); |
| 66 |
} catch (RemoteException e) { |
| 67 |
Log.e(TAG, "Error in sending result back", e); |
| 68 |
} |
| 69 |
return false; |
| 70 |
} |
| 71 |
} |