Debian Codegraph @

tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/TestService.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 }