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
This commit is contained in:
@@ -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");
|
||||||
|
|
||||||
mTime.clearCachedTimeResult();
|
final long token = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
mTime.clearCachedTimeResult();
|
||||||
|
|
||||||
mLocalLog.log("clearTimeForTests");
|
mLocalLog.log("clearTimeForTests");
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,15 +193,19 @@ 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");
|
||||||
|
|
||||||
boolean success = mTime.forceRefresh();
|
final long token = Binder.clearCallingIdentity();
|
||||||
mLocalLog.log("forceRefreshForTests: success=" + success);
|
try {
|
||||||
|
boolean success = mTime.forceRefresh();
|
||||||
|
mLocalLog.log("forceRefreshForTests: success=" + success);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
makeNetworkTimeSuggestion(mTime.getCachedTimeResult(),
|
makeNetworkTimeSuggestion(mTime.getCachedTimeResult(),
|
||||||
"Origin: NetworkTimeUpdateService: forceRefreshForTests");
|
"Origin: NetworkTimeUpdateService: forceRefreshForTests");
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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");
|
||||||
|
|
||||||
mLocalLog.log("Setting server config for tests: ntpConnectionInfo=" + ntpConfig);
|
final long token = Binder.clearCallingIdentity();
|
||||||
mTime.setServerConfigForTests(ntpConfig);
|
try {
|
||||||
|
mLocalLog.log("Setting server config for tests: ntpConnectionInfo=" + ntpConfig);
|
||||||
|
mTime.setServerConfigForTests(ntpConfig);
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPollNetworkTime(int event) {
|
private void onPollNetworkTime(int event) {
|
||||||
|
|||||||
Reference in New Issue
Block a user