Adnan Begovic | d5fdee9 | 2015-11-13 15:28:21 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | import java.io.IOException; |
| 18 | import java.io.InputStream; |
| 19 | import java.io.OutputStream; |
| 20 | |
| 21 | /** |
| 22 | * Created by adnan on 11/13/15. |
| 23 | */ |
| 24 | public 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 Mortimer | 542742b | 2017-09-18 19:44:11 -0700 | [diff] [blame] | 52 | if (!LineageSettings.System.isLegacySetting(setting.getKey())) { |
Adnan Begovic | d5fdee9 | 2015-11-13 15:28:21 -0800 | [diff] [blame] | 53 | return true; |
| 54 | } |
| 55 | break; |
| 56 | case SettingsConstants.SECURE: |
| 57 | if (SettingsConstants.Ignorables.SECURE_SETTINGS.contains(setting.getKey())) { |
| 58 | return true; |
| 59 | } |
Sam Mortimer | 542742b | 2017-09-18 19:44:11 -0700 | [diff] [blame] | 60 | if (!LineageSettings.Secure.isLegacySetting(setting.getKey())) { |
Adnan Begovic | d5fdee9 | 2015-11-13 15:28:21 -0800 | [diff] [blame] | 61 | return true; |
| 62 | } |
| 63 | break; |
| 64 | case SettingsConstants.GLOBAL: |
Sam Mortimer | 542742b | 2017-09-18 19:44:11 -0700 | [diff] [blame] | 65 | if (!LineageSettings.Global.isLegacySetting(setting.getKey())) { |
Adnan Begovic | d5fdee9 | 2015-11-13 15:28:21 -0800 | [diff] [blame] | 66 | 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 | } |