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

Commit bdf7b5dc authored by Neil Fuller's avatar Neil Fuller
Browse files

Fix permission issues for network update service

Fix permission issues for network update service command-line commands
used in tests.

Bug: 251726675
Test: atest android.os.cts.SystemClockSntpTest
Change-Id: I8a34c801d82c769fd8d06e5b0b3177ce92b5f072
parent 1b3db4d5
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) {