forked from CyanogenDefy/RomUpdater
/
SharedData.java
177 lines (136 loc) · 4.07 KB
/
SharedData.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*
* This file is part of ROMUpdater.
* ROMUpdater is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* ROMUpdater is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with ROMUpdater. If not, see <http://www.gnu.org/licenses/>.
*/
package org.elegosproject.romupdater;
import java.io.InputStream;
import android.content.Context;
import android.content.res.Resources;
import android.os.SystemProperties;
import android.text.TextUtils;
public class SharedData {
static final Object mLock = new Object();
static SharedData mInstance;
public static final String LOCAL_MODEL = android.os.Build.MODEL;
public static final String LOCAL_VERSION = android.os.Build.VERSION.INCREMENTAL;
public static String LOCAL_ROMNAME = SystemProperties.get("ro.cm.version", SystemProperties.get("ro.modversion", android.os.Build.DISPLAY));
public static final String ABOUT_LICENCE = "Based on elegos version\nEnhanced for AOSP ROMs\n\nThis program comes with ABSOLUTELY NO WARRANTY\n\nThis is free software, and you are welcome to redistribute it under certain conditions";
private String repositoryModel;
private String repositoryROMName;
private String downloadVersion;
private String repositoryUrl;
private String downloadedFile;
private Boolean lockProcess; // synchronous operations
private Integer recoveryCounter;
private Integer recoveryOperations;
private String recoveryMessage;
private InputStream data;
private SharedData() {
setRepositoryROMName("");
setRespositoryModel("");
setDownloadVersion("");
setLockProcess(false);
setRecoveryCounter(0);
setRecoveryOperations(0);
setRecoveryMessage("");
}
//
// SETTERS
//
public static SharedData getInstance() {
synchronized (mLock) {
if (mInstance == null) {
mInstance = new SharedData();
}
return mInstance;
}
}
public void setRespositoryModel(String repository) {
repositoryModel = repository;
}
public void setRepositoryROMName(String name) {
repositoryROMName = name;
}
public void setDownloadVersion(String version) {
downloadVersion = version;
}
public void setRepositoryUrl(String url) {
if(!TextUtils.isEmpty(url)) {
if (!url.contains("://"))
url = "http://"+url;
if (!url.contains("?") && !url.contains("json") && !url.contains("php")) {
if (!url.endsWith("/")) url += "/";
}
}
repositoryUrl = url;
}
public void setDownloadedFile(String file) {
downloadedFile = file;
}
public void setLockProcess(Boolean b) {
lockProcess = b;
}
private void setRecoveryCounter(Integer i) {
recoveryCounter = i;
}
public void incrementRecoveryCounter() {
recoveryCounter++;
}
public void decrementRecoveryCounter() {
recoveryCounter--;
}
public void setRecoveryOperations(Integer i) {
recoveryOperations = i;
}
public void setRecoveryMessage(String s) {
recoveryMessage = s;
}
public void addRecoveryMessage(String s) {
recoveryMessage += s;
}
public void setInputStreamData(InputStream is) {
data = is;
}
//
// GETTERS
//
public String getRepositoryModel() {
return repositoryModel;
}
public String getRepositoryROMName() {
return repositoryROMName;
}
public String getDownloadVersion() {
return downloadVersion;
}
public String getRepositoryUrl() {
return repositoryUrl;
}
public String getDownloadedFile() {
return downloadedFile;
}
public Boolean getLockProcess() {
return lockProcess;
}
public Integer getRecoveryCounter() {
return recoveryCounter;
}
public Integer getRecoveryOperations() {
return recoveryOperations;
}
public String getRecoveryMessage() {
return recoveryMessage;
}
public InputStream getInputStreamData() {
return data;
}
}