
com.smartdevicelink.proxy.rpc.OnButtonPress Maven / Gradle / Ivy
/*
* Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package com.smartdevicelink.proxy.rpc;
import androidx.annotation.NonNull;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
import com.smartdevicelink.proxy.rpc.enums.ButtonName;
import com.smartdevicelink.proxy.rpc.enums.ButtonPressMode;
import java.util.Hashtable;
/**
*
* Notifies application of button press events for buttons to which the
* application is subscribed. SDL supports two button press events defined as
* follows:
*
*
* - SHORT - Occurs when a button is depressed, then released within two
* seconds. The event is considered to occur immediately after the button is
* released.
* - LONG - Occurs when a button is depressed and held for two seconds or
* more. The event is considered to occur immediately after the two second
* threshold has been crossed, before the button is released
*
* HMI Status Requirements:
*
* HMILevel:
*
* - The application will receive OnButtonPress notifications for all
* subscribed buttons when HMILevel is FULL.
* - The application will receive OnButtonPress notifications for subscribed
* media buttons when HMILevel is LIMITED.
* - Media buttons include SEEKLEFT, SEEKRIGHT, TUNEUP, TUNEDOWN, and
* PRESET_0-PRESET_9.
* - The application will not receive OnButtonPress notification when HMILevel
* is BACKGROUND or NONE.
*
* AudioStreamingState:
*
* - Any
*
* SystemContext:
*
* - MAIN, VR. In MENU, only PRESET buttons. In VR, pressing any subscribable
* button will cancel VR.
*
*
*
* Parameter List:
*
*
* Name
* Type
* Description
* Req
* Notes
* SmartDeviceLink Ver Available
*
*
* buttonName
* {@linkplain ButtonName}
* Name of the button which triggered this event
*
*
* SmartDeviceLink 1.0
*
*
* buttonPressMode
* {@linkplain ButtonPressMode}
* Indicates whether this is an SHORT or LONG button press event.
*
*
* SmartDeviceLink 1.0
*
*
* customButtonID
* Integer
* If ButtonName is "CUSTOM_BUTTON", this references the integer ID passed
* by a custom button. (e.g. softButton ID)
* N
* Minvalue=0 Maxvalue=65536
* SmartDeviceLink 2.0
*
*
*
*
* @see SubscribeButton
* @see UnsubscribeButton
* @since SmartDeviceLink 1.0
*/
public class OnButtonPress extends RPCNotification {
public static final String KEY_BUTTON_PRESS_MODE = "buttonPressMode";
public static final String KEY_BUTTON_NAME = "buttonName";
public static final String KEY_CUSTOM_BUTTON_ID = "customButtonID";
/**
* Constructs a newly allocated OnButtonPress object
*/
public OnButtonPress() {
super(FunctionID.ON_BUTTON_PRESS.toString());
}
/**
*
* Constructs a newly allocated OnButtonPress object indicated by the
* Hashtable parameter
*
*
* @param hash The Hashtable to use
*/
public OnButtonPress(Hashtable hash) {
super(hash);
}
/**
* Constructs a newly allocated OnButtonPress object
*
* @param buttonName name of the button
* @param buttonPressMode indicates whether this is a short or long press
*/
public OnButtonPress(@NonNull ButtonName buttonName, @NonNull ButtonPressMode buttonPressMode) {
this();
setButtonName(buttonName);
setButtonPressMode(buttonPressMode);
}
/**
* Returns an {@linkplain ButtonName} the button's name
*
* @return ButtonName Name of the button
*/
public ButtonName getButtonName() {
return (ButtonName) getObject(ButtonName.class, KEY_BUTTON_NAME);
}
/**
* Set the button's name
*
* @param buttonName name of the button
*/
public OnButtonPress setButtonName(@NonNull ButtonName buttonName) {
setParameters(KEY_BUTTON_NAME, buttonName);
return this;
}
/**
* Returns {@linkplain ButtonPressMode}
*
* @return ButtonPressMode whether this is a long or short button press event
*/
public ButtonPressMode getButtonPressMode() {
return (ButtonPressMode) getObject(ButtonPressMode.class, KEY_BUTTON_PRESS_MODE);
}
/**
* Set the button press mode of the event
*
* @param buttonPressMode indicates whether this is a short or long press
*/
public OnButtonPress setButtonPressMode(@NonNull ButtonPressMode buttonPressMode) {
setParameters(KEY_BUTTON_PRESS_MODE, buttonPressMode);
return this;
}
/**
* Set CustomButtonID of the button
* If ButtonName is "CUSTOM_BUTTON", this references the integer ID passed by a custom button. (e.g. softButton ID)
*
* @param customButtonID CustomButtonID of the button
*/
public OnButtonPress setCustomButtonID(Integer customButtonID) {
setParameters(KEY_CUSTOM_BUTTON_ID, customButtonID);
return this;
}
/**
* Get CustomButtonID of the button
* If ButtonName is "CUSTOM_BUTTON", this references the integer ID passed by a custom button. (e.g. softButton ID)
*
* @return CustomButtonID of the button
*/
public Integer getCustomButtonID() {
return getInteger(KEY_CUSTOM_BUTTON_ID);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy