Skip to content

DeviceHelper

Pico edited this page Jul 23, 2021 · 22 revisions

String getPUIVersion()

Get PUI version of the device.
Returns:
PUI version, e.g. 3.4.0.


String getDeviceType()

Get type of the device.
Returns:
the device type, e.g. Pico G2.


String getSN()

Get serial number of the device.
Returns:
the serial number, e.g. PA7940MGD4120145B.


void silentInstall(String apkpath, String packagename) (*)

Install the application without user interaction.
Parameters:
apkpath - the path of the APK you want to install;
packagename - the package name of your current application, not the package name of the application being installed.


void silentUninstall(String packagename) (*)

Uninstall the application without user interaction.
Parameters:
packagename - package name of the application you want to uninstall.

Use callback for silentInstall and silentUninstall:
1. Create a game object in your scene named "installer".
2. Mount a script on the "installer" object.
3. Write two functions in the script:
   public void InstallCallback (string s){
      //This function will be invoked after the installation completed.
      //s equals "success" if installation success.
      //s contains failed reason if the installation failed.
   }
   public void UninstallCallback (string s){
      //This function will be invoked after the uninstallation completed.
      //s equals "1" if uninstallation success.
      //s equals "-1" if uninstallation failed.
   }

void killApp(Context context, String pkgName)

Kill the application.
Parameters:
pkgName - package name of the application to kill.


void launchBrowser(int browser, String link)

Call specified browser to open the link.
Parameters:
browser -
0: PUI built-in browser.
1: WebVR browser.
2: Firefox VR browser.
link - the link to open.


void launchBrowserWithLinkInFile(int browser, String filePath)

Call specified browser to open the link in the file.
Parameters:
browser -
0: PUI built-in browser.
1: WebVR browser.
2: Firefox VR browser.
filePath - the config file path.


void goToApp(String packagename)

Start an application.
Parameters:
packagename - package name of the application you want to open.


void startVRShell(Int way, String[] args)

Launch Android 2D application.
2D applications that are launched using this interface have higher resolution than 2D applications that are normally launched, and can also use VR input methods.
Parameters:
way=0, launch with ComponentName, args is an array of length 2 consisting of PackageName and ClassName;
way=1, launch with PackageName, args is an array of length 1 consisting of PackageName;
way=2, launch with Action, args is an array of length 1 consisting of Action.
sample:
Open controller setting
deviceHelper.Call("startVRShell", 2, new string[] { "pui.settings.action.CONTROLLER_SETTINGS" });


String getAppList()

Get a list of installed applications in JSON format.
Returns:
list of installed applications. See return sample.


void registerHomeReceiver()

Register the receiver for Home event broadcast.


void unregisterHomeReceiver()

Unregister the receiver for Home event broadcast.


void openRecenterApp()

Adjust startup calibration application.


void installApp(String apkPath)

Install the application. Unlike silentInstall interface, installApp will call up Android installation UI, Click "Install" button to complete the installation.
Parameters:
apkpath - the path of the APK you want to install.


boolean setSystemProp(String key, String value)

Set specified system property. Available system properties can be found here.
Parameters:
key - the key of property.
value - the attribute for this property.
Returns:
return true if set it successfully, return false otherwise.


String getSystemProp(String key, String defaultValue)

Get specific system property. Available system properties can be found here.
Parameters:
key - The key of property.
defaultValue - The value to return if get the prop failed.
Returns:
the value of the specified key.

Clone this wiki locally