Gilberto Nobili
Jul 11, 2019
7:36 pm

Disable SENSORS with Customization SDK not working

I need to disable all the sensor on the phone and I was hopping to do that with the following code:

CustomDeviceManager cdm = CustomDeviceManager.getInstance();
SystemManager kcsm = cdm.getSystemManager();
try {
    int sensorElements = (CustomDeviceManager.SENSOR_ALL);
    kcsm.setSensorDisabled(true, sensorElements);
} catch(SecurityException e) {
    Log.w("KNOX", "SecurityException:" + e);
}

If I check with :

int elements = kcsm.getSensorDisabled();
Log.e("TAG","SENSOR_ACCELEROMETER: " + (((elements & CustomDeviceManager.SENSOR_ACCELEROMETER) != 0) ? "disabled" : "enabled"));
Log.e("TAG","SENSOR_GYROSCOPE: " + (((elements & CustomDeviceManager.SENSOR_GYROSCOPE) != 0) ? "disabled" : "enabled"));
Log.e("TAG","SENSOR_MAGNETIC: " + (((elements & CustomDeviceManager.SENSOR_MAGNETIC) != 0) ? "disabled" : "enabled"));
Log.e("TAG","SENSOR_PRESSURE: " + (((elements & CustomDeviceManager.SENSOR_PRESSURE) != 0) ? "disabled" : "enabled"));
Log.e("TAG","SENSOR_LIGHT: " + (((elements & CustomDeviceManager.SENSOR_LIGHT) != 0) ? "disabled" : "enabled"));

it's returning "disable" for all but any other application on the phone can read the sensor.

Others call to the SystemManager seams to work like:

try {
    kcsm.setStatusBarClockState(false);
} catch(SecurityException e) {
    Log.w(TAG, "SecurityException:" + e);
}

 

Can somebody help me?

Similar topics

No similar topics found.
Gilberto Nobili
Jul 14, 2019
6:55 am

Sorry... Was a problem on the Knox version.

The code above works well