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

Commit b5a16024 authored by Neil Fuller's avatar Neil Fuller Committed by Android (Google) Code Review
Browse files

Merge "Fix permission issues for network update service"

parents 30c0052e bdf7b5dc
Loading
Loading
Loading
Loading
+25 −11
Original line number Original line Diff line number Diff line
@@ -172,9 +172,14 @@ public class NetworkTimeUpdateService extends Binder {
        mContext.enforceCallingPermission(
        mContext.enforceCallingPermission(
                android.Manifest.permission.SET_TIME, "clear latest network time");
                android.Manifest.permission.SET_TIME, "clear latest network time");


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


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


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


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


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

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


    /**
    /**
@@ -207,8 +216,13 @@ public class NetworkTimeUpdateService extends Binder {
        mContext.enforceCallingPermission(
        mContext.enforceCallingPermission(
                android.Manifest.permission.SET_TIME, "set NTP server config for tests");
                android.Manifest.permission.SET_TIME, "set NTP server config for tests");


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


    private void onPollNetworkTime(int event) {
    private void onPollNetworkTime(int event) {