System

published on: 2022-06-07 08:19:20

Through the relevant interfaces of System edition, developers can obtain and set some system configurations on Pico enterprise edition devices

Supported equipments:

Neo 3 Pro series.

Before you begin

Please initialize System Service before using the APIs in this chapter. Detailed description is as follows:

Initializing and bind Service, the object name refers to name of the object which is used to receive callback.

private void Awake()
{
    PXR_System.InitSystemService(objectName);
    PXR_System.BindSystemService();
}

Unbind the Service

private void OnDestory()
{
   PXR_Plugin.System.UnBindSystemService();
}

Add 4 callback methods to allow corresponding callback to be received.

private void BoolCallback(string value)
{
    if (PXR_Plugin.System.BoolCallback != null) PXR_Plugin.System.BoolCallback(bool.Parse(value));
    PXR_Plugin.System.BoolCallback = null;
}
private void IntCallback(string value)
{
    if (PXR_Plugin.System.IntCallback != null) PXR_Plugin.System.IntCallback(int.Parse(value));
    PXR_Plugin.System.IntCallback = null;
}
private void LongCallback(string value)
{
    if (PXR_Plugin.System.LongCallback != null) PXR_Plugin.System.LongCallback(int.Parse(value));
    PXR_Plugin.System.LongCallback = null;
}
private void StringCallback(string value)
{
    if (PXR_Plugin.System.StringCallback != null) PXR_Plugin.System.StringCallback(value);
    PXR_Plugin.System.StringCallback = null;
}

Make sure Service is bound successfully before calling the interface. For callback of Service binding success, please add the following code to the initialization script. After Service binding success, this method will be called.

public void toBServiceBind(string s)
{
    Debug.Log( Bind success. );
}

Common APIs

image.png

StateGetDeviceInfo

Function name: public static string UPxr_StateGetDeviceInfo(SystemInfoEnum type)

Functions: Get device info

Parameter: type - get the device info type

public enum SystemInfoEnum
{
    ELECTRIC_QUANTITY,                     // Battery Power
    PUI_VERSION,                           // PUI Version
    EQUIPMENT_MODEL,                       // Device Model
    EQUIPMENT_SN,                          // Device SN code
    CUSTOMER_SN,                           // Customer SN code
    INTERNAL_STORAGE_SPACE_OF_THE_DEVICE,  // Device Storage
    DEVICE_BLUETOOTH_STATUS,               // Bluetooth Status
    BLUETOOTH_NAME_CONNECTED,              // Bluetooth Name
    BLUETOOTH_MAC_ADDRESS,                 // Bluetooth MAC Address
    DEVICE_WIFI_STATUS,                    // Wi-Fi connection status
    WIFI_NAME_CONNECTED,                   // Connected Wi-Fi ID
    WLAN_MAC_ADDRESS,                      // WLAN MAC Adress
    DEVICE_IP,                             // Device IP Address
    CHARGING_STATUS                        // Device charging status(return value: 2-charging 3-not charging)
}

Return value: string - device info

Method of calling: PXR_System.StateGetDeviceInfo(SystemInfoEnum.PUI_VERSION);

ControlSetAutoConnectWIFI

Function name: public static void ControlSetAutoConnectWIFI(string ssid, string pwd,Action callback)

Functions: Connect to the specified WiFi

Parameter:

  • ssid: WiFi name,

  • pwd: WiFi password,

  • Action callback: successful/failed connection

Return value: None

Method of calling: PXR_System.ControlSetAutoConnectWIFI(ssid, pwd,callback);

ControlClearAutoConnectWIFI

Function name: public static void ControlClearAutoConnectWIFI(Action callback)

Functions: Clear the specified WiFi

Parameter:

Action callback: successful/failed clearance

Return value: None

Method of calling: PXR_System.ControlClearAutoConnectWIFI(callback);

PropertySetHomeKey

Function name: public static void PropertySetHomeKey(HomeEventEnum eventEnum, HomeFunctionEnum function, Action callback)

Functions: Set Home key. It will redefine Home key and affect the function of Home key defined by the system. Please use this function with discretion.

Parameter:

  • HomeEventEnum eventEnum
public enum HomeEventEnum
{
    SINGLE_CLICK,    // single click
    DOUBLE_CLICK     // double click
}

  • HomeFunctionEnum function
public enum HomeFunctionEnum
{
    VALUE_HOME_GO_TO_SETTING = 0,    // Go to settings
    VALUE_HOME_RECENTER = 2,         // Recenter
    VALUE_HOME_DISABLE = 4,          // Disable the event of Home key
    VALUE_HOME_GO_TO_HOME = 5        // Go to Home
}

  • Action callback: successful/failed

Return value: None

Method of calling: PXR_System.PropertySetHomeKey(eventEnum,function,callback);

PropertySetHomeKeyAll

Function name: public static void PropertySetHomeKeyAll(HomeEventEnum eventEnum, HomeFunctionEnum function, int timesetup, string pkg, string className, Action callback)

Functions: Extended settings for Home key

Parameter:

  • HomeEventEnum eventEnum
public enum HomeEventEnum
{
    SINGLE_CLICK,    // single click
    DOUBLE_CLICK     // double click
}

  • HomeFunctionEnum function
public enum HomeFunctionEnum
{
    VALUE_HOME_GO_TO_SETTING = 0,    // Go to settings
    VALUE_HOME_RECENTER = 2,         // Recenter
    VALUE_HOME_DISABLE = 4,          // Disable the event of Home key
    VALUE_HOME_GO_TO_HOME = 5        // Go to Home
}

  • int timesetup: The interval of key pressing is set only if there are events when double clicking or long pressing event. When short pressed, it will return 0.

  • string pkg: When Function is HOME_FUNCTION_OPEN_APP, input specified package name; other situations input null.

  • string className: When Function is HOME_FUNCTION_OPEN_APP, input specified class name; other situations input null.

  • Action callback: successful/failed

Return value: None

Method of calling: PXR_System.PropertySetHomeKeyAll(eventEnum,function, timesetup, pkg, className, callback);

PropertyDisablePowerKey

Function name: public static void PropertyDisablePowerKey(bool isSingleTap, bool enable,Action callback)

Functions: Set power key

Parameter:

  • bool isSingleTap: single click event [true], long press event [false],

  • bool enable: key enabling status;

  • Action callback: successful/failed setting

Return value: None

Method of calling: PXR_System.PropertyDisablePowerKey(isSingleTap, enable,callback);

PropertySetScreenOffDelay

Function name: public static void PropertySetScreenOffDelay(ScreenOffDelayTimeEnum timeEnum,Action callback)

Functions: Set screen off delay

Parameter:

  • ScreenOffDelayTimeEnum timeEnum: screen off delay,please note that screen off timeout should not be larger than system sleep timeout
public enum ScreenOffDelayTimeEnum
{
    THREE = 3,              // 3 seconds
    TEN = 10,               // 10 seconds
    THIRTY = 30,            // 30 seconds
    SIXTY = 60,             // 60 seconds
    THREE_HUNDRED = 300,    // 5 minutes
    SIX_HUNDRED = 600,      // 10 minutes
    NEVER = -1              // Never
}

  • Action callback: successful/failed setting

Return value: None

Method of calling: PXR_System.PropertySetScreenOffDelay(timeEnum,callback);

PropertySetSleepDelay

Function name: public static void PropertySetSleepDelay(SleepDelayTimeEnum timeEnum)

Functions: Set sleep delay

Parameter:

  • SleepDelayTimeEnum timeEnum: system sleep delay
public enum ScreenOffDelayTimeEnum
{
    THREE = 3,              // 3 seconds
    TEN = 10,               // 10 seconds
    THIRTY = 30,            // 30 seconds
    SIXTY = 60,             // 60 seconds
    THREE_HUNDRED = 300,    // 5 minutes
    SIX_HUNDRED = 600,      // 10 minutes
    NEVER = -1              // Never
}

Return value: None

Method of calling: PXR_System.PropertySetSleepDelay(timeEnum);

SwitchSystemFunction

Function name: public static void SwitchSystemFunction(SystemFunctionSwitchEnum systemFunction, SwitchEnum switchEnum)

Functions: Set switch system funtion

Parameter:

  • SystemFunctionSwitchEnum systemFunction: type of function, switchEnum: switch value
public enum SystemFunctionSwitchEnum
{
    SFS_USB,                        // USB Debugging
    SFS_AUTOSLEEP,                  // Auto Sleep
    SFS_SCREENON_CHARGING,          // Screen-On Charging
    SFS_OTG_CHARGING,               // OTG Charging
    SFS_RETURN_MENU_IN_2DMODE,      // Return Button In 2D Mode
    SFS_COMBINATION_KEY,            // Key Combination
    SFS_CALIBRATION_WITH_POWER_ON,  // Recenter/Re-Calibration On Device Boot
    SFS_SYSTEM_UPDATE,              // System Update
    SFS_CAST_SERVICE,               // Casting Service (This Property is not valid when using Pico Enterprise Solution)
    SFS_EYE_PROTECTION,             // Eye-Protection Mode
    SFS_SECURITY_ZONE_PERMANENTLY,  // Disable 6Dof Safety Boundary Permanently
    SFS_Auto_Calibration,           // Auto Recenter/Re-Calibrate
    SFS_USB_BOOT,                   // USB Plug-in Boot
    SFS_VOLUME_UI,                  // Global volume UI
    SFS_CONTROLLER_UI,              // Global Controller connected UI
    SFS_NAVGATION_SWITCH,           // Navigation Bar 
    SFS_SHORTCUT_SHOW_RECORD_UI,    // Screen recording button UI
    SFS_SHORTCUT_SHOW_FIT_UI,       // Pico Fit UI 
    SFS_SHORTCUT_SHOW_CAST_UI,      // Screencast button UI
    SFS_SHORTCUT_SHOW_CAPTURE_UI,   // Screenshot button UI
    SFS_STOP_MEM_INFO_SERVICE,      // Kill 2D application
    SFS_USB_FORCE_HOST              // Set Neo3 device as host device Set Neo3 device as host device
}

  • SwitchEnum switchEnum: switch value
public enum SwitchEnum
{
    S_ON,    // enable
    S_OFF    // disable
}

Method of calling: PXR_System.SwitchSystemFunction(systemFunction,switchEnum);

SwitchSetUsbConfigurationOption

Function name: public static void SwitchSetUsbConfigurationOption(USBConfigModeEnum uSBConfigModeEnum)

Functions: Set USB configuration (MTP, charging )

Parameter:

  • USBConfigModeEnum uSBConfigModeEnum
public enum USBConfigModeEnum
{
    MTP,     // MTP Mode
    CHARGE   // Charging Mode
}

Return value: None

Method of calling: PXR_System.SwitchSetUsbConfigurationOption(uSBConfigModeEnum);

EnableEnterKey

Function name: public static void EnableEnterKey()

Functions: Enable Confirm key

Parameters: None

Return value: None

Method of calling: PXR_System.EnableEnterKey();

DisableEnterKey

Function name: public static void DisableEnterKey()

Functions: Disable Confirm key

Parameters: None

Return value: None

Method of calling: PXR_System.DisableEnterKey();

EnableVolumeKey

Function name: public static void EnableVolumeKey()

Functions: Enable Volume key

Parameters: None

Return value: None

Method of calling: PXR_System.EnableVolumeKey();

DisableVolumeKey

Function name: public static void DisableVolumeKey()

Functions: Disable Volume key

Parameters: None

Return value: None

Method of calling: PXR_System.DisableVolumeKey();

EnableBackKey

Function name: public static void EnableBackKey()

Functions: Enable Back key

Parameters: None

Return value: None

Method of calling: PXR_System.EnableBackKey();

DisableBackKey

Function name: public static void DisableBackKey()

Functions: Disable Back key

Parameters: None

Return value: None

Method of calling: PXR_System.DisableBackKey();

WriteConfigFileToDataLocal

Function name: public static void WriteConfigFileToDataLocal(string path, string content, Action callback)

Functions: Write configuration file to Data/local/tmp

Parameters:

  • string path: configure file path (“/data/local/tmp/config.txt”)

  • string content: configure file content

  • Action callback: whether the configuration file has been successfully written

Return value: None

Method of calling: PXR_System.WriteConfigFileToDataLocal(string path, string content, Action callback);

ResetAllKeyToDefault

Function name: public static void ResetAllKeyToDefault (Action callback)

Functions: Reset all keys to default

Parameters: callback: whether all keys have been successfully reset to default

Return value: None

Method of calling: PXR_System. ResetAllKeyToDefault (Action callback);

OpenMiracast

Function name: public static void OpenMiracast()

Functions: Turn on the screencast function.

Parameter: None

Return value: None

Method of calling: PXR_System. OpenMiracast();

IsMiracastOn

Function name: public static void IsMiracastOn()

Functions: Get the status of the screencast.

Parameter: None

Return value: true: on; false: off

Method of calling: PXR_System.IsMiracastOn();

CloseMiracast

Function name: public static void CloseMiracast()

Function: Turn off the screencast function.

Parameter: None

Return value: None

Method of callilng : PXR_System. CloseMiracast();

StartScan

Function name: public static void StartScan()

Functions: Start scanning for devices that can be screened.

Parameter: None

Return value: None

Method of calling: PXR_System. StartScan();

StopScan

Function name: public static void StopScan()

Functions: Stop scanning for devices that can be screened.

Parameter: None

Return value: None

Method of calling: PXR_System. StopScan();

SetWDJsonCallback

Function name: public static void SetWDJsonCallback()

Function: Set callback of scanning result, return a string in json format, including devices connected and scanned before. StringCallBack can be called only after this interface is executed.

Parameter: None

Return value: None

Method of calling: PXR_System. SetWDJsonCallback();

ConnectWifiDisplay

Function name: public static void ConnectWifiDisplay(string modelJson)

Functions: Project to the specified device.

Parameter:

  • string modelJson
{
    deviceAddress :  e2:39.bf:9.:33:c6 ,
    deviceName :  \u5BA2\u5385\u9.84\u5C0F\u9.9.\u9.35\u89C6 ,
    isAvailable :  true ,
       canConnect :  true ,
       isRemembered :  false ,
       statusCode :  -1 ,
       status :   ,
       description :   
}

Return value: None

Method of calling: PXR_System. ConnectWifiDisplay(modelJson);

DisConnectWifiDisplay

Function name: public static void DisConnectWifiDisplay()

Functions: Disconnected for screencast.

Parameter: None

Return value: None

Method of calling: PXR_System. DisConnectWifiDisplay();

ForgetWifiDisplay

Function name: public static void ForgetWifiDisplay(string address)

Functions: Forget the devices that have been connected.

Parameter: address: the adress of the device.

Return value: None

Method of calling: PXR_System. ForgetWifiDisplay(address);

RenameWifiDisplay

Function name: public static void RenameWifiDisplay (string address, string newName)

Functions: Modify the name of the connected device (only the name for local storage)

Parameter:

  • string address: the MAC address of the device;

  • string newName: target name of the device.

Return value: None

Method of calling: PXR_System. RenameWifiDisplay (address, newName);

UpdateWifiDisplays

Function name: public static void UpdateWifiDisplays(Actioncallback)

Functions: Manually update the list.

Parameter:

Action callback: the result of the SetWDJsonCallback.

Return value: None

Method of calling: PXR_System. UpdateWifiDisplays(callback);

GetConnectedWD

Function name: public static string GetConnectedWD()

Functions: Get the information of the currently connected device.

Parameter: None

Return value: Return the currently connected device information.

Method of calling: PXR_System. GetConnectedWD();

GetCpuUsages

Gets the CPU utilization of the current device.

public static float[] GetCpuUsages() 

Method

PXR_System.GetCpuUsages();

Input parameters

None

Returns

The CPU utilization of the current device.

GetDeviceTemperatures

Gets device temperature in Celsius.

public static float[] GetDeviceTemperatures(int type, int source) 

Method

PXR_System.GetDeviceTemperatures(int type, int source);

Input parameters

Name Type Required Description
type int Yes The requested type of device temperature:
* 0: CPU temperature (DEVICE_TEMPERATURE_CPU)
* 1: GPU temperature (DEVICE_TEMPERATURE_GPU)
* 2: battery temperature (DEVICE_TEMPERATURE_BATTERY)
* 3: surface temperature (DEVICE_TEMPERATURE_SKIN)
source int Yes The requested source of device temperature:
* 0: current temperature (TEMPERATURE_CURRENT)
* 1: temperature threshold for throttling (TEMPERATURE_THROTTLING)
* 2: temperature threshold for shutdown (TEMPERATURE_SHUTDOWN)
* 3: temperature threshold for throttling (TEMPERATURE_THROTTLING_BELOW_VR_MIN). If the actual temperature is higher than the threshold, the lowest clock frequency for VR mode will not be met.

Returns

float[], an array of requested device temperatures in Celsius.

Capture

Captures the current screen.

public static void Capture() 

Method

PXR_System.Capture();

Input parameters

None

Returns

None

Record

Records the screen. Call this function again to stop recording.

public static void Record()

Method

PXR_System.Record();

Input parameters

None

Returns

None

ControlSetAutoConnectWIFIWithErrorCodeCallback

Connects to a specified Wi-Fi.

public static void ControlSetAutoConnectWIFIWithErrorCodeCallback(String ssid, String pwd, int ext, Action<int> callback) 

Method

PXR_System.ControlSetAutoConnectWIFIWithErrorCodeCallback(ssid,pwd,callback);

Input parameters

Name Type Required Description
ssid string Yes Wi-Fi name.
pwd string Yes Wi-Fi password.
ext int Yes Reserved parameter, set to 0 by default.
callback action Yes The callback for indicating whether the Wi-Fi connection is successful:
* 0: connected
* 1: password error
* 2: unknown error

Returns

None

AppKeepAlive

Keeps an app active. In other words, improves the priority of an app, thereby making the system not to force quit the app.

public static void AppKeepAlive(String appPackageName, bool keepAlive, int ext) 

Method

PXR_System.AppKeepAlive(appPackageName,keepAlive,ext);

Input parameters

Name Type Required Description
appPackageName string Yes App package name.
keepAlive int Yes Determines whether to keep the app active (i.e., whether to enhance the priority of the app):
* true: yes
* false: no
ext int Yes Reserved parameter, set to 0 by default.

Returns

None

RecenterSuccess

Sets up the callback event for the long press of the Home button. This function is used with delegated calls.

Method

  • PXR_Plugin.System.RecenterSuccess +=: add the callback event for the long press of the Home button, the method is defined by yourself

  • PXR_Plugin.System.RecenterSuccess -=: delete the callback event for the long press of the Home button, the method is defined by yourself

Protected interfaces

Note: To call the following interfaces, it is required to add this label to the manifest. If this label is added, the app will not be available in the Pico Store.

<meta-data android:name= pico_advance_interface  android:value= 0 />

ControlSetDeviceAction

Function name: public static void ControlSetDeviceAction(DeviceControlEnum deviceControl,Action callback)

Functions: Make the device shut down or reboot

Parameter:

  • DeviceControlEnum deviceControl: Make the device shut down or reboot
public enum DeviceControlEnum
{
    DEVICE_CONTROL_REBOOT,     // Reboot
    DEVICE_CONTROL_SHUTDOWN    // Shut down
}

  • Action callback: callback interface, successful/failed shut down/ reboot

Return value: None

Method of calling: PXR_System.ControlSetDeviceAction(DeviceControlEnum.DEVICE_CONTROL_SHUTDOWN,callback);

ControlAPPManger

Function name: public static void ControlAPPManger(PackageControlEnum packageControl, string path, Action callback)

Functions: Silently install or uninstall app

Parameter:

  • PackageControlEnum packageControl
public enum PackageControlEnum
{
    PACKAGE_SILENCE_INSTALL,   // silence install
    PACKAGE_SILENCE_UNINSTALL  // silence uninstall
}

  • string path: The path to the installation package for the silent installation or the name of the app package when silently uninstalled;

  • Action callback: callback interface, successful/ failed installation/ uninstallation

Return value: None

Method of calling: PXR_System.ControlAPPManger(PackageControlEnum.PACKAGE_SILENCE_UNINSTALL, “com.xxx.xxx”,callback);

ScreenOn

Function name: public static void ScreenOn()

Functions: Turn screen on

Parameter: None

Return value: None

Method of calling: PXR_System.ScreenOn();

ScreenOff

Function name: public static void ScreenOff()

Functions: Turn screen off

Parameter: None

Return value: None

Method of calling: PXR_System. ScreenOff()

KillAppsByPidOrPackageName

Function name: public static void KillAppsByPidOrPackageName(int[] pids, string[] packageNames)

Functions: Kill the application by passing in the application pid or package name.

Parameter:

  • int[] pids: an array of application pid,

  • string[] packageNames: an array of package names.

Return value: None

Method of calling: PXR_System. KillAppsByPidOrPackageName(pids, packageNames);

KillBackgroundAppsWithWhiteList

Function name: public static void KillBackgroundAppsWithWhiteList(string[] packageNames)

Functions: Kill background applications, the package names array passed in is used as a white list, the corresponding apps will not be Killed.

Parameter:

  • string[] packageNames: An array of package names as a whitelist.

Return value: None

Method of calling: PXR_System.KillBackgroundAppsWithWhiteList(packageNames);