Search code examples
javakotlinaugmented-realityarcoregyroscope

Virtual Gyroscope in Huawei P Smart 2019 phone?


I've got Huawei P Smart 2019 smartphone. A majority of websites with specs (including official Huawei website) say that there's no gyroscope in this model.

But I tested Huawei P Smart 2019 using Sensor Fusion app. This app detects Gyroscope sensor and shows how it works.

What's the issue? Why even manufacturer says there's no gyroscope sensor in Huawei P Smart 2019 although a sensor clearly exists there?

Maybe it's a virtual gyroscope?

package org.hitlabnz.sensor_fusion_demo;

public class SensorSelectionActivity extends FragmentActivity {
    SectionsPagerAdapter mSectionsPagerAdapter;
    ViewPager mViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sensor_selection);
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
        mViewPager = (ViewPager) findViewById(R.id.pager);
        mViewPager.setAdapter(mSectionsPagerAdapter);

        SensorChecker checker = new HardwareChecker((SensorManager) getSystemService(SENSOR_SERVICE));
        if(!checker.IsGyroscopeAvailable()) {
            displayHardwareMissingWarning();
        }
    }
    private void displayHardwareMissingWarning() {
        AlertDialog ad = new AlertDialog.Builder(this).create();  
        ad.setCancelable(false);   
        ad.setTitle(getResources().getString(R.string.gyroscope_missing)); 
        ad.setMessage(getResources().getString(R.string.gyroscope_missing_message));

        ad.setButton(DialogInterface.BUTTON_NEUTRAL, getResources().getString(R.string.OK), new DialogInterface.OnClickListener() {  
            @Override  
            public void onClick(DialogInterface dialog, int which) {   
                dialog.dismiss();                      
            }  
        });  
        ad.show();  
    }
}

Solution

  • A little explaination about how it's work : https://android.gadgethacks.com/how-to/use-google-cardboard-if-your-phone-doesnt-have-gyroscope-0172650/

    With the compass and acceleromater sensor on your smartphone, you can make a virtual gyroscope. You need to take the data from compass and acceleromater and make lot of work and sort on it, but you can handle gyroscope functionnality virtualy with that :-)