1 /*
2  * Copyright (C) 2018 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.localtransport;
18 
19 import android.util.KeyValueSettingObserver;
20 import android.content.ContentResolver;
21 import android.os.Handler;
22 import android.provider.Settings;
23 import android.util.KeyValueListParser;
24 
25 public class LocalTransportParameters extends KeyValueSettingObserver {
26     private static final String TAG = "LocalTransportParams";
27     private static final String SETTING = Settings.Secure.BACKUP_LOCAL_TRANSPORT_PARAMETERS;
28     private static final String KEY_FAKE_ENCRYPTION_FLAG = "fake_encryption_flag";
29     private static final String KEY_NON_INCREMENTAL_ONLY = "non_incremental_only";
30     private static final String KEY_IS_DEVICE_TRANSFER = "is_device_transfer";
31     private static final String KEY_IS_ENCRYPTED = "is_encrypted";
32 
33     private boolean mFakeEncryptionFlag;
34     private boolean mIsNonIncrementalOnly;
35     private boolean mIsDeviceTransfer;
36     private boolean mIsEncrypted;
37 
LocalTransportParameters(Handler handler, ContentResolver resolver)38     public LocalTransportParameters(Handler handler, ContentResolver resolver) {
39         super(handler, resolver, Settings.Secure.getUriFor(SETTING));
40     }
41 
isFakeEncryptionFlag()42     boolean isFakeEncryptionFlag() {
43         return mFakeEncryptionFlag;
44     }
45 
isNonIncrementalOnly()46     boolean isNonIncrementalOnly() {
47         return mIsNonIncrementalOnly;
48     }
49 
isDeviceTransfer()50     boolean isDeviceTransfer() {
51         return mIsDeviceTransfer;
52     }
53 
isEncrypted()54     boolean isEncrypted() {
55         return mIsEncrypted;
56     }
57 
getSettingValue(ContentResolver resolver)58     public String getSettingValue(ContentResolver resolver) {
59         return Settings.Secure.getString(resolver, SETTING);
60     }
61 
update(KeyValueListParser parser)62     public void update(KeyValueListParser parser) {
63         mFakeEncryptionFlag = parser.getBoolean(KEY_FAKE_ENCRYPTION_FLAG, false);
64         mIsNonIncrementalOnly = parser.getBoolean(KEY_NON_INCREMENTAL_ONLY, false);
65         mIsDeviceTransfer = parser.getBoolean(KEY_IS_DEVICE_TRANSFER, false);
66         mIsEncrypted = parser.getBoolean(KEY_IS_ENCRYPTED, false);
67     }
68 }
69