blob: b704eb1d991cbdbb1af1e5541c43ff39c8329217 [file] [log] [blame]
Neil Fuller5a680f2e2015-03-13 14:27:34 +00001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server.updates;
18
19import android.util.Slog;
20
21import java.io.File;
22import java.io.IOException;
Neil Fuller01c003a2017-01-04 15:18:38 +000023import libcore.tzdata.update2.TimeZoneBundleInstaller;
Neil Fuller5a680f2e2015-03-13 14:27:34 +000024
25/**
26 * An install receiver responsible for installing timezone data updates.
27 */
28public class TzDataInstallReceiver extends ConfigUpdateInstallReceiver {
29
30 private static final String TAG = "TZDataInstallReceiver";
31
Neil Fuller01c003a2017-01-04 15:18:38 +000032 private static final File SYSTEM_TZ_DATA_FILE = new File("/system/usr/share/zoneinfo/tzdata");
Neil Fuller5a680f2e2015-03-13 14:27:34 +000033 private static final File TZ_DATA_DIR = new File("/data/misc/zoneinfo");
34 private static final String UPDATE_DIR_NAME = TZ_DATA_DIR.getPath() + "/updates/";
35 private static final String UPDATE_METADATA_DIR_NAME = "metadata/";
36 private static final String UPDATE_VERSION_FILE_NAME = "version";
37 private static final String UPDATE_CONTENT_FILE_NAME = "tzdata_bundle.zip";
38
Neil Fuller01c003a2017-01-04 15:18:38 +000039 private final TimeZoneBundleInstaller installer;
Neil Fuller5a680f2e2015-03-13 14:27:34 +000040
41 public TzDataInstallReceiver() {
42 super(UPDATE_DIR_NAME, UPDATE_CONTENT_FILE_NAME, UPDATE_METADATA_DIR_NAME,
43 UPDATE_VERSION_FILE_NAME);
Neil Fuller01c003a2017-01-04 15:18:38 +000044 installer = new TimeZoneBundleInstaller(TAG, SYSTEM_TZ_DATA_FILE, TZ_DATA_DIR);
Neil Fuller5a680f2e2015-03-13 14:27:34 +000045 }
46
47 @Override
48 protected void install(byte[] content, int version) throws IOException {
49 boolean valid = installer.install(content);
50 Slog.i(TAG, "Timezone data install valid for this device: " + valid);
51 // Even if !valid, we call super.install(). Only in the event of an exception should we
52 // not. If we didn't do this we could attempt to install repeatedly.
53 super.install(content, version);
54 }
55}