Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1aed0289 authored by Neil Fuller's avatar Neil Fuller Committed by Gerrit Code Review
Browse files

Merge "Fix permission issues for network update service"

parents 1291b83a 605d4acd
Loading
Loading
Loading
Loading
+27 −13
Original line number Diff line number Diff line
@@ -165,9 +165,14 @@ public class NetworkTimeUpdateService extends Binder {
        mContext.enforceCallingPermission(
                android.Manifest.permission.SET_TIME, "clear latest network time");

        final long token = Binder.clearCallingIdentity();
        try {
            mTime.clearCachedTimeResult();

            mLocalLog.log("clearTimeForTests");
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    /**
@@ -181,6 +186,8 @@ public class NetworkTimeUpdateService extends Binder {
        mContext.enforceCallingPermission(
                android.Manifest.permission.SET_TIME, "force network time refresh");

        final long token = Binder.clearCallingIdentity();
        try {
            boolean success = mTime.forceRefresh();
            mLocalLog.log("forceRefreshForTests: success=" + success);

@@ -188,8 +195,10 @@ public class NetworkTimeUpdateService extends Binder {
                makeNetworkTimeSuggestion(mTime.getCachedTimeResult(),
                        "Origin: NetworkTimeUpdateService: forceRefreshForTests");
            }

            return success;
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    /**
@@ -201,10 +210,15 @@ public class NetworkTimeUpdateService extends Binder {
        mContext.enforceCallingPermission(
                android.Manifest.permission.SET_TIME, "set NTP server config for tests");

        final long token = Binder.clearCallingIdentity();
        try {
            mLocalLog.log("Setting server config for tests: hostname=" + hostname
                    + ", port=" + port
                    + ", timeout=" + timeout);
            mTime.setServerConfigForTests(hostname, port, timeout);
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    private void onPollNetworkTime(int event) {