1 /*
2  * Copyright (C) 2020 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 
17 package com.android.providers.settings;
18 
19 import static com.android.providers.settings.SettingsProvider.SETTINGS_PROVIDER_JOBS_NS;
20 import static com.android.providers.settings.SettingsProvider.TABLE_CONFIG;
21 import static com.android.providers.settings.SettingsProvider.TABLE_GLOBAL;
22 import static com.android.providers.settings.SettingsProvider.TABLE_SECURE;
23 import static com.android.providers.settings.SettingsProvider.TABLE_SSAID;
24 import static com.android.providers.settings.SettingsProvider.TABLE_SYSTEM;
25 import static com.android.providers.settings.SettingsProvider.WRITE_FALLBACK_SETTINGS_FILES_JOB_ID;
26 
27 import android.app.job.JobParameters;
28 import android.app.job.JobService;
29 
30 import java.util.ArrayList;
31 import java.util.List;
32 
33 /**
34  * JobService to make a copy of a list of files, given their paths.
35  */
36 public class WriteFallbackSettingsFilesJobService extends JobService {
37     @Override
onStartJob(final JobParameters params)38     public boolean onStartJob(final JobParameters params) {
39         if (!SETTINGS_PROVIDER_JOBS_NS.equals(params.getJobNamespace())
40                 || params.getJobId() != WRITE_FALLBACK_SETTINGS_FILES_JOB_ID) {
41             return false;
42         }
43         final List<String> settingsFiles = new ArrayList<>();
44         settingsFiles.add(params.getExtras().getString(TABLE_GLOBAL, ""));
45         settingsFiles.add(params.getExtras().getString(TABLE_SYSTEM, ""));
46         settingsFiles.add(params.getExtras().getString(TABLE_SECURE, ""));
47         settingsFiles.add(params.getExtras().getString(TABLE_SSAID, ""));
48         settingsFiles.add(params.getExtras().getString(TABLE_CONFIG, ""));
49         SettingsProvider.writeFallBackSettingsFiles(settingsFiles);
50         return false;
51     }
52 
53     @Override
onStopJob(JobParameters params)54     public boolean onStopJob(JobParameters params) {
55         return false;
56     }
57 
58 }
59