0 votes
by (120 points)
edited by

Unity 2020.3.30f1
PicoXR Plugin 1.2.4
PUI 4.0.7

Hi all,

im trying to update the screen off delay property following the docs.

In PXR_System.cs there is an InitSystemService method which is calling

PXR_Plugin.System.UPxr_InitBatteryVolClass()

what is it for?

This call results a crash for me.

If Im commenting out this line the service initialization call seems to run fine, but after that when i try to bind the service with

PXR_System.BindSystemService() 

im getting a

AndroidJavaException: java.lang.NullPointerException: Attempt to
invoke virtual method 'java.lang.String
android.content.Context.getPackageName()' on a null object reference

Which refers to a line

at com.pvr.tobservice.ToBServiceHelper.bindTobService(ToBServiceHelper.java:65)

Why am I getting null for the context here?

thanks,

G-

2 Answers

0 votes
by (5.3k points)

What`s your PUI version? System API needs PUI version 3.11.3 and above on G2 4k. As you can see in their docs.
https://developer.pico-interactive.com/docs/en/12058/225818/#_7-8-system-related

by (120 points)

PUI version is 4.0.7

by (5.3k points)

you can try initialize System Service in a second like this
enter image description here

by (120 points)

thanks, but unfortunately delaying the call does not solve the issue

0 votes
by (35.8k points)

Dear developer,
Could you please provide a Demo project or apk that can reproduce this problem?
And could you please provide these information, equipment type, PUI version, Unity version and SDK version in your mail.
Please send it to our email: pico_devanswers@bytedance.com.
We'll test it.
And please use the title of your question as the subject of your email.

by (35.8k points)
edited by

Dear developer
You can try to create a new empty gameobject and add this script on it.
https://bytedance.feishu.cn/file/boxcncAGB8yRRYa3L2rMjEOu7Fe
or https://github.com/WinterZmorgen/System-Api.git
Thanks

ago by (35.8k points)

Dear developer,
We have updated our use of screen off delay property.
This is the instruction of the function:

PXR_Plugin.System.UPxr_InitBatteryVolClass()

UPvrInitBatteryVolClass # Function name: public bool
UPvr
InitBatteryVolClass() Functions: Initialize power, volume and
brightness service Parameter: None Return value: true: Successful
false: Failure (Please call this interface to initialize before using
services such as power, volume, brightness, etc.)

Here is a test code for this function:

private void Start()
    {
        PXR_System.InitSystemService(name);
        PXR_System.BindSystemService();
    }

    private void OnDestory()
    {
        PXR_System.UnBindSystemService();
    }

    // Add 4 callback methods
    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;
    }

    // method for debugging
    public void toBServiceBind(string s) { Debug.Log("Bind success."); }

    public void SleepDelay()
    {
        PXR_Plugin.System.UPxr_PropertySetSleepDelay(SleepDelayTimeEnum.SIXTY);
    }

    public void ScreenOffDelay()
    {
        PXR_Plugin.System.UPxr_PropertySetScreenOffDelay(ScreenOffDelayTimeEnum.SIXTY, ScreenOffDelayCallback);
    }
 private void ScreenOffDelayCallback(int value)
    {
        Debug.Log("ScreenOffDelayCallback's value: " + value);
    }
...