Loading services/core/java/com/android/server/timezone/RulesManagerService.java +3 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.server.SystemService; import com.android.timezone.distro.DistroException; import com.android.timezone.distro.DistroVersion; import com.android.timezone.distro.TimeZoneDistro; import com.android.timezone.distro.StagedDistroOperation; import android.app.timezone.Callback; Loading Loading @@ -224,7 +225,8 @@ public final class RulesManagerService extends IRulesManager.Stub { try { byte[] distroBytes = RulesManagerService.this.mFileDescriptorHelper.readFully(mTimeZoneDistro); int installerResult = mInstaller.stageInstallWithErrorCode(distroBytes); TimeZoneDistro distro = new TimeZoneDistro(distroBytes); int installerResult = mInstaller.stageInstallWithErrorCode(distro); int resultCode = mapInstallerResultToApiCode(installerResult); sendFinishedStatus(mCallback, resultCode); Loading services/core/java/com/android/server/updates/TzDataInstallReceiver.java +4 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.updates; import com.android.timezone.distro.TimeZoneDistro; import android.util.Slog; import java.io.File; Loading Loading @@ -46,7 +48,8 @@ public class TzDataInstallReceiver extends ConfigUpdateInstallReceiver { @Override protected void install(byte[] content, int version) throws IOException { boolean valid = installer.install(content); TimeZoneDistro distro = new TimeZoneDistro(content); boolean valid = installer.install(distro); Slog.i(TAG, "Timezone data install valid for this device: " + valid); // Even if !valid, we call super.install(). Only in the event of an exception should we // not. If we didn't do this we could attempt to install repeatedly. Loading services/tests/servicestests/src/com/android/server/timezone/RulesManagerServiceTest.java +17 −10 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.timezone; import com.android.timezone.distro.DistroVersion; import com.android.timezone.distro.TimeZoneDistro; import com.android.timezone.distro.StagedDistroOperation; import org.junit.Before; Loading Loading @@ -403,14 +404,16 @@ public class RulesManagerServiceTest { verifyNoInstallerCallsMade(); verifyNoPackageTrackerCallsMade(); TimeZoneDistro expectedDistro = new TimeZoneDistro(expectedContent); // Set up the installer. configureStageInstallExpectation(expectedContent, TimeZoneDistroInstaller.INSTALL_SUCCESS); configureStageInstallExpectation(expectedDistro, TimeZoneDistroInstaller.INSTALL_SUCCESS); // Simulate the async execution. mFakeExecutor.simulateAsyncExecutionOfLastCommand(); // Verify the expected calls were made to other components. verifyStageInstallCalled(expectedContent); verifyStageInstallCalled(expectedDistro); verifyPackageTrackerCalled(token, true /* success */); // Check the callback was called. Loading @@ -436,14 +439,16 @@ public class RulesManagerServiceTest { verifyNoInstallerCallsMade(); callback.assertNoResultReceived(); TimeZoneDistro expectedDistro = new TimeZoneDistro(expectedContent); // Set up the installer. configureStageInstallExpectation(expectedContent, TimeZoneDistroInstaller.INSTALL_SUCCESS); configureStageInstallExpectation(expectedDistro, TimeZoneDistroInstaller.INSTALL_SUCCESS); // Simulate the async execution. mFakeExecutor.simulateAsyncExecutionOfLastCommand(); // Verify the expected calls were made to other components. verifyStageInstallCalled(expectedContent); verifyStageInstallCalled(expectedDistro); verifyPackageTrackerCalled(null /* expectedToken */, true /* success */); // Check the callback was received. Loading Loading @@ -471,15 +476,17 @@ public class RulesManagerServiceTest { verifyNoInstallerCallsMade(); callback.assertNoResultReceived(); TimeZoneDistro expectedDistro = new TimeZoneDistro(expectedContent); // Set up the installer. configureStageInstallExpectation( expectedContent, TimeZoneDistroInstaller.INSTALL_FAIL_VALIDATION_ERROR); expectedDistro, TimeZoneDistroInstaller.INSTALL_FAIL_VALIDATION_ERROR); // Simulate the async execution. mFakeExecutor.simulateAsyncExecutionOfLastCommand(); // Verify the expected calls were made to other components. verifyStageInstallCalled(expectedContent); verifyStageInstallCalled(expectedDistro); // Validation failure is treated like a successful check: repeating it won't improve things. boolean expectedSuccess = true; Loading Loading @@ -780,9 +787,9 @@ public class RulesManagerServiceTest { .thenThrow(new IOException("Simulated failure")); } private void configureStageInstallExpectation(byte[] expectedContent, int resultCode) private void configureStageInstallExpectation(TimeZoneDistro expected, int resultCode) throws Exception { when(mMockTimeZoneDistroInstaller.stageInstallWithErrorCode(eq(expectedContent))) when(mMockTimeZoneDistroInstaller.stageInstallWithErrorCode(eq(expected))) .thenReturn(resultCode); } Loading @@ -790,8 +797,8 @@ public class RulesManagerServiceTest { doReturn(success).when(mMockTimeZoneDistroInstaller).stageUninstall(); } private void verifyStageInstallCalled(byte[] expectedContent) throws Exception { verify(mMockTimeZoneDistroInstaller).stageInstallWithErrorCode(eq(expectedContent)); private void verifyStageInstallCalled(TimeZoneDistro expected) throws Exception { verify(mMockTimeZoneDistroInstaller).stageInstallWithErrorCode(eq(expected)); verifyNoMoreInteractions(mMockTimeZoneDistroInstaller); reset(mMockTimeZoneDistroInstaller); } Loading Loading
services/core/java/com/android/server/timezone/RulesManagerService.java +3 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.server.SystemService; import com.android.timezone.distro.DistroException; import com.android.timezone.distro.DistroVersion; import com.android.timezone.distro.TimeZoneDistro; import com.android.timezone.distro.StagedDistroOperation; import android.app.timezone.Callback; Loading Loading @@ -224,7 +225,8 @@ public final class RulesManagerService extends IRulesManager.Stub { try { byte[] distroBytes = RulesManagerService.this.mFileDescriptorHelper.readFully(mTimeZoneDistro); int installerResult = mInstaller.stageInstallWithErrorCode(distroBytes); TimeZoneDistro distro = new TimeZoneDistro(distroBytes); int installerResult = mInstaller.stageInstallWithErrorCode(distro); int resultCode = mapInstallerResultToApiCode(installerResult); sendFinishedStatus(mCallback, resultCode); Loading
services/core/java/com/android/server/updates/TzDataInstallReceiver.java +4 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.updates; import com.android.timezone.distro.TimeZoneDistro; import android.util.Slog; import java.io.File; Loading Loading @@ -46,7 +48,8 @@ public class TzDataInstallReceiver extends ConfigUpdateInstallReceiver { @Override protected void install(byte[] content, int version) throws IOException { boolean valid = installer.install(content); TimeZoneDistro distro = new TimeZoneDistro(content); boolean valid = installer.install(distro); Slog.i(TAG, "Timezone data install valid for this device: " + valid); // Even if !valid, we call super.install(). Only in the event of an exception should we // not. If we didn't do this we could attempt to install repeatedly. Loading
services/tests/servicestests/src/com/android/server/timezone/RulesManagerServiceTest.java +17 −10 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.timezone; import com.android.timezone.distro.DistroVersion; import com.android.timezone.distro.TimeZoneDistro; import com.android.timezone.distro.StagedDistroOperation; import org.junit.Before; Loading Loading @@ -403,14 +404,16 @@ public class RulesManagerServiceTest { verifyNoInstallerCallsMade(); verifyNoPackageTrackerCallsMade(); TimeZoneDistro expectedDistro = new TimeZoneDistro(expectedContent); // Set up the installer. configureStageInstallExpectation(expectedContent, TimeZoneDistroInstaller.INSTALL_SUCCESS); configureStageInstallExpectation(expectedDistro, TimeZoneDistroInstaller.INSTALL_SUCCESS); // Simulate the async execution. mFakeExecutor.simulateAsyncExecutionOfLastCommand(); // Verify the expected calls were made to other components. verifyStageInstallCalled(expectedContent); verifyStageInstallCalled(expectedDistro); verifyPackageTrackerCalled(token, true /* success */); // Check the callback was called. Loading @@ -436,14 +439,16 @@ public class RulesManagerServiceTest { verifyNoInstallerCallsMade(); callback.assertNoResultReceived(); TimeZoneDistro expectedDistro = new TimeZoneDistro(expectedContent); // Set up the installer. configureStageInstallExpectation(expectedContent, TimeZoneDistroInstaller.INSTALL_SUCCESS); configureStageInstallExpectation(expectedDistro, TimeZoneDistroInstaller.INSTALL_SUCCESS); // Simulate the async execution. mFakeExecutor.simulateAsyncExecutionOfLastCommand(); // Verify the expected calls were made to other components. verifyStageInstallCalled(expectedContent); verifyStageInstallCalled(expectedDistro); verifyPackageTrackerCalled(null /* expectedToken */, true /* success */); // Check the callback was received. Loading Loading @@ -471,15 +476,17 @@ public class RulesManagerServiceTest { verifyNoInstallerCallsMade(); callback.assertNoResultReceived(); TimeZoneDistro expectedDistro = new TimeZoneDistro(expectedContent); // Set up the installer. configureStageInstallExpectation( expectedContent, TimeZoneDistroInstaller.INSTALL_FAIL_VALIDATION_ERROR); expectedDistro, TimeZoneDistroInstaller.INSTALL_FAIL_VALIDATION_ERROR); // Simulate the async execution. mFakeExecutor.simulateAsyncExecutionOfLastCommand(); // Verify the expected calls were made to other components. verifyStageInstallCalled(expectedContent); verifyStageInstallCalled(expectedDistro); // Validation failure is treated like a successful check: repeating it won't improve things. boolean expectedSuccess = true; Loading Loading @@ -780,9 +787,9 @@ public class RulesManagerServiceTest { .thenThrow(new IOException("Simulated failure")); } private void configureStageInstallExpectation(byte[] expectedContent, int resultCode) private void configureStageInstallExpectation(TimeZoneDistro expected, int resultCode) throws Exception { when(mMockTimeZoneDistroInstaller.stageInstallWithErrorCode(eq(expectedContent))) when(mMockTimeZoneDistroInstaller.stageInstallWithErrorCode(eq(expected))) .thenReturn(resultCode); } Loading @@ -790,8 +797,8 @@ public class RulesManagerServiceTest { doReturn(success).when(mMockTimeZoneDistroInstaller).stageUninstall(); } private void verifyStageInstallCalled(byte[] expectedContent) throws Exception { verify(mMockTimeZoneDistroInstaller).stageInstallWithErrorCode(eq(expectedContent)); private void verifyStageInstallCalled(TimeZoneDistro expected) throws Exception { verify(mMockTimeZoneDistroInstaller).stageInstallWithErrorCode(eq(expected)); verifyNoMoreInteractions(mMockTimeZoneDistroInstaller); reset(mMockTimeZoneDistroInstaller); } Loading