1 /* 2 * Copyright (C) 2017 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.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 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 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 55 public Map<Integer, RpcReceiverManager> getRpcReceiverManagers() { 56 return mFacadeManagers; 57 } 58 } 59