1 /* 2 * Copyright (C) 2014 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.omadm.plugin.dev; 18 19 import android.app.Service; 20 import android.content.Intent; 21 import android.os.IBinder; 22 import android.util.Log; 23 24 import com.android.omadm.plugin.IDmtPlugin; 25 26 public class DevService extends Service { 27 private static final String TAG = "DM_DevService"; 28 private static final boolean DBG = true; 29 30 private IDmtPlugin.Stub mBinder; 31 32 @Override 33 public IBinder onBind(Intent intent) { 34 String action = intent.getAction(); 35 if (DevPlugin.class.getName().equals(action)) { 36 String rootPath = intent.getStringExtra("rootPath"); 37 if (DBG) logd("rootPath: " + rootPath); 38 IDmtPlugin.Stub binder = mBinder; 39 if (binder == null) { 40 if (DBG) logd("mBinder is null, create it!"); 41 binder = new DevPlugin(this); 42 mBinder = binder; 43 } else { 44 if (DBG) logd("mBinder already exists"); 45 } 46 return binder; 47 } 48 if (DBG) logd("onBind(): unknown action: " + action + " for intent: " + intent); 49 return null; 50 } 51 52 @Override 53 public boolean onUnbind(Intent intent) { 54 super.onUnbind(intent); 55 if (DBG) logd("enter onUnbind()"); 56 mBinder = null; 57 return true; 58 } 59 60 private static void logd(String msg) { 61 Log.d(TAG, msg); 62 } 63 } 64