Merge "Fix permission issues for network update service"
This commit is contained in:
@@ -165,9 +165,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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -181,15 +186,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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -201,10 +210,15 @@ 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: hostname=" + hostname
|
final long token = Binder.clearCallingIdentity();
|
||||||
+ ", port=" + port
|
try {
|
||||||
+ ", timeout=" + timeout);
|
mLocalLog.log("Setting server config for tests: hostname=" + hostname
|
||||||
mTime.setServerConfigForTests(hostname, port, timeout);
|
+ ", port=" + port
|
||||||
|
+ ", timeout=" + timeout);
|
||||||
|
mTime.setServerConfigForTests(hostname, port, timeout);
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPollNetworkTime(int event) {
|
private void onPollNetworkTime(int event) {
|
||||||
|
|||||||
Reference in New Issue
Block a user