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 17package com.android.layoutlib.bridge.remote.client.adapters; 18 19import com.android.ide.common.rendering.api.AdapterBinding; 20import com.android.ide.common.rendering.api.IImageFactory; 21import com.android.ide.common.rendering.api.ResourceReference; 22import com.android.ide.common.rendering.api.SessionParams; 23import com.android.ide.common.rendering.api.SessionParams.Key; 24import com.android.ide.common.rendering.api.SessionParams.RenderingMode; 25import com.android.layout.remote.api.RemoteAssetRepository; 26import com.android.layout.remote.api.RemoteHardwareConfig; 27import com.android.layout.remote.api.RemoteILayoutPullParser; 28import com.android.layout.remote.api.RemoteLayoutLog; 29import com.android.layout.remote.api.RemoteLayoutlibCallback; 30import com.android.layout.remote.api.RemoteRenderResources; 31import com.android.layout.remote.api.RemoteSessionParams; 32import com.android.tools.layoutlib.annotations.NotNull; 33 34import java.rmi.RemoteException; 35import java.rmi.server.UnicastRemoteObject; 36import java.util.Map; 37 38public class RemoteSessionParamsAdapter extends RemoteRenderParamsAdapter implements RemoteSessionParams { 39 private final SessionParams mDelegate; 40 41 private RemoteSessionParamsAdapter(@NotNull SessionParams params) { 42 super(params); 43 mDelegate = params; 44 } 45 46 public static RemoteSessionParams create(@NotNull SessionParams params) throws RemoteException { 47 return (RemoteSessionParams) UnicastRemoteObject.exportObject( 48 new RemoteSessionParamsAdapter(params), 0); 49 } 50 51 @Override 52 public RenderingMode getRenderingMode() { 53 return mDelegate.getRenderingMode(); 54 } 55 56 @Override 57 public boolean isLayoutOnly() { 58 return mDelegate.isLayoutOnly(); 59 } 60 61 @Override 62 public Map<ResourceReference, AdapterBinding> getAdapterBindings() { 63 return mDelegate.getAdapterBindings(); 64 } 65 66 @Override 67 public boolean getExtendedViewInfoMode() { 68 return mDelegate.getExtendedViewInfoMode(); 69 } 70 71 @Override 72 public int getSimulatedPlatformVersion() { 73 return mDelegate.getSimulatedPlatformVersion(); 74 } 75 76 @Override 77 public RemoteILayoutPullParser getLayoutDescription() throws RemoteException { 78 return RemoteILayoutPullParserAdapter.create(mDelegate.getLayoutDescription()); 79 } 80} 81