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