blob: 60cd530e5f7cf14aad5fefd6fe1f317691680ef7 [file] [log] [blame]
Adnan Begovicd5fdee92015-11-13 15:28:21 -08001/*
2 * Copyright (C) 2015 The CyanogenMod 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
17import java.io.IOException;
18import java.io.InputStream;
19import java.io.OutputStream;
20
21/**
22 * Created by adnan on 11/13/15.
23 */
24public class Command implements Runnable {
25 private String authority;
26
27 /**
28 * Override for execution
29 */
30 @Override
31 public void run() {
32 }
33
34 /**
35 * Copies from one stream to another.
36 */
37 protected static void copy(InputStream in, OutputStream out) {
38 byte[] buffer = new byte[1024];
39 int read;
40 try {
41 while ((read = in.read(buffer)) > -1) {
42 out.write(buffer, 0, read);
43 }
44 } catch (IOException e) {
45 e.printStackTrace();
46 }
47 }
48
49 protected static boolean filter(String uri, Setting setting) {
50 switch (uri) {
51 case SettingsConstants.SYSTEM:
Sam Mortimer542742b2017-09-18 19:44:11 -070052 if (!LineageSettings.System.isLegacySetting(setting.getKey())) {
Adnan Begovicd5fdee92015-11-13 15:28:21 -080053 return true;
54 }
55 break;
56 case SettingsConstants.SECURE:
57 if (SettingsConstants.Ignorables.SECURE_SETTINGS.contains(setting.getKey())) {
58 return true;
59 }
Sam Mortimer542742b2017-09-18 19:44:11 -070060 if (!LineageSettings.Secure.isLegacySetting(setting.getKey())) {
Adnan Begovicd5fdee92015-11-13 15:28:21 -080061 return true;
62 }
63 break;
64 case SettingsConstants.GLOBAL:
Sam Mortimer542742b2017-09-18 19:44:11 -070065 if (!LineageSettings.Global.isLegacySetting(setting.getKey())) {
Adnan Begovicd5fdee92015-11-13 15:28:21 -080066 return true;
67 }
68 break;
69 }
70 return false;
71 }
72
73 public void prepend(String authority) {
74 this.authority = authority;
75 }
76
77 public String getAuthority() {
78 return authority;
79 }
80}