Marek Degma
Nov 07, 2018
5:57 pm

DateTimePolicy.setNtpInfo has no effect whatsoever

I am building an internal Android application that is intended to run on a secured internal network with no access to the internet. Therefore, the app has to override NTP settings to point to internal NTP server. The application successfully performs the update as described here (https://seap.samsung.com/api-references/android-standard/reference/android/app/enterprise/DateTimePolicy.html#setNtpInfo(android.app.enterprise.NtpInfo)):

EnterpriseDeviceManager edm = (EnterpriseDeviceManager) getSystemService
        (EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE);
 DateTimePolicy dateTimePolicy = edm.getDateTimePolicy();
 try {
     boolean ntpInfoSet = true;
     NtpInfo ntpInfo = new NtpInfo(this.getApplicationContext());
     ntpInfo.setServer("us.pool.ntp.org");
     ntpInfo.setTimeout(10000); // 10 seconds
     ntpInfo.setMaxAttempts(5);
     ntpInfo.setPollingInterval(43200000); // 12 hours
     ntpInfo.setPollingIntervalShorter(30000); // 30 seconds
     ntpInfo.setTimeErrorThreshold(1000); // 1 second
     ntpInfoSet = dateTimePolicy.setNtpInfo(ntpInfo);
     if (ntpInfoSet) {
         // operation was successfull
     } else {
         // operation failed
     }
 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }

And indeed, the DateTimePolicy.NtpInfo reflects the updated values even upon application restart. However, /system/etc/gps.conf still looks like this:

NTP_SERVER=north-america.pool.ntp.org
XTRA_SERVER_1=http://gllto1.glpals.com/7day/v3/latest/lto2.dat
XTRA_SERVER_2=http://gllto2.glpals.com/7day/v3/latest/lto2.dat
SUPL_HOST=supl.google.com
SUPL_PORT=7275

What am I doing wrong?

Similar topics

No similar topics found.