1 /* 2 * Copyright (C) 2016 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * 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, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17 package com.googlecode.android_scripting.facade; 18 19 import android.app.Service; 20 import android.content.Intent; 21 22 import com.googlecode.android_scripting.jsonrpc.RpcReceiver; 23 import com.googlecode.android_scripting.jsonrpc.RpcReceiverManager; 24 import com.googlecode.android_scripting.jsonrpc.RpcReceiverManagerFactory; 25 26 import java.util.HashMap; 27 import java.util.Collection; 28 import java.util.Map; 29 30 public class FacadeManagerFactory implements RpcReceiverManagerFactory { 31 32 private final int mSdkLevel; 33 private final Service mService; 34 private final Intent mIntent; 35 private final Collection<Class<? extends RpcReceiver>> mClassList; 36 private final Map<Integer, RpcReceiverManager> mFacadeManagers; 37 FacadeManagerFactory(int sdkLevel, Service service, Intent intent, Collection<Class<? extends RpcReceiver>> classList)38 public FacadeManagerFactory(int sdkLevel, Service service, Intent intent, 39 Collection<Class<? extends RpcReceiver>> classList) { 40 mSdkLevel = sdkLevel; 41 mService = service; 42 mIntent = intent; 43 mClassList = classList; 44 mFacadeManagers = new HashMap<Integer, RpcReceiverManager>(); 45 } 46 47 @Override create(Integer UID)48 public FacadeManager create(Integer UID) { 49 FacadeManager facadeManager = new FacadeManager(mSdkLevel, mService, mIntent, mClassList); 50 mFacadeManagers.put(UID, facadeManager); 51 return facadeManager; 52 } 53 54 @Override getRpcReceiverManagers()55 public Map<Integer, RpcReceiverManager> getRpcReceiverManagers() { 56 return mFacadeManagers; 57 } 58 } 59