package org.uiautomation.ios.command.uiautomation;

import org.json.JSONException;
import org.json.JSONObject;
import org.uiautomation.ios.IOSServerManager;
import org.uiautomation.ios.command.UIAScriptHandler;
import org.uiautomation.ios.communication.WebDriverLikeRequest;
import org.uiautomation.ios.utils.JSTemplate;

public class DeactivateAppHandler extends UIAScriptHandler {

    private static final JSTemplate template = new JSTemplate(
            "UIATarget.localTarget().deactivateAppForDuration(%:duration$f);" +
                    "UIAutomation.createJSONResponse('%:sessionId$s',0,'')",
            "sessionId", "duration");

    public DeactivateAppHandler(IOSServerManager driver, WebDriverLikeRequest request) {
        super(driver, request);

        JSONObject payload = request.getPayload();

        String js = template.generate(
                request.getSession(),
                payload.optDouble("duration"));
        setJS(js);
    }

    @Override
    public JSONObject configurationDescription() throws JSONException {
        return noConfigDefined();
    }

}

@@ -1,8 +1,638 @@
+/*%0A * Copyright 2012-2015 eBay Software Foundation and ios-driver committers%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22); you may not use this file except%0A * in compliance with the License. You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software distributed under the License%0A * is distributed on an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express%0A * or implied. See the License for the specific language governing permissions and limitations under%0A * the License.%0A */%0A%0A
 package 

add copyright boilerplate