Skip to content

Commit 9173891

Browse files
Merge pull request #757 from SUPLA/v25.09
V25.09
2 parents f94d28e + 16432ce commit 9173891

File tree

67 files changed

+2180
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2180
-478
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIGjzCCBHegAwIBAgIJAOsxcvgjq8qCMA0GCSqGSIb3DQEBCwUAMIGKMQswCQYD
3+
VQQGEwJQTDERMA8GA1UECBMIT3BvbHNraWUxEDAOBgNVBAcTB1BhY3prb3cxEjAQ
4+
BgNVBAoTCVNVUExBLk9SRzELMAkGA1UECxMCQ0ExFTATBgNVBAMTDFNVUExBLk9S
5+
RyBDQTEeMBwGCSqGSIb3DQEJARYPc3VwbGFAc3VwbGEub3JnMB4XDTIyMDgwNTEw
6+
MTY1OVoXDTQyMDczMTEwMTY1OVowgYoxCzAJBgNVBAYTAlBMMREwDwYDVQQIEwhP
7+
cG9sc2tpZTEQMA4GA1UEBxMHUGFjemtvdzESMBAGA1UEChMJU1VQTEEuT1JHMQsw
8+
CQYDVQQLEwJDQTEVMBMGA1UEAxMMU1VQTEEuT1JHIENBMR4wHAYJKoZIhvcNAQkB
9+
Fg9zdXBsYUBzdXBsYS5vcmcwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC
10+
AQCoxxfG6+zpowWGPO4BVDn4rIYSgiy44P16z+uX/lEvTkUbpm1IZox8in+9zROx
11+
xA3V7lHgjvfwaOjR1vmjJIIp6+EAT0BAvjSwIxe3DrYUD8ZiPTSgB67Zr1vjjhLB
12+
hmdys1xGCFEx5OvRxr4tVGpiWUPEFCjGl4+U59ulJr1UALmxMMCx5yarB9gwS+3Q
13+
4bWCmnpXnt4j2fFPSp9Z/aya2cYi0585fMx5CLftHEWJKv9q0eIRjbhT3zFfUyv/
14+
5yVZT8ZKQeGywV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680ZmcGiyWbXSkpeNM
30+
p19pXT+jyFNaNWc/WPtgwAozy5kNJs5MjbgJ59YzQ01bfO9++2NcFMDIBZ2pihIt
31+
yGMMyin5h3h9CFcM/l+Xy1E4ivYoTn30IaHLtxNv/3TFMwThRlNNBjjKNGukqMvz
32+
rv1bVcOEUckbkwTzCHFS5QYOR7Rqlk/n4EAkATOXBHEDVnfTEPGff1Kw3CESbYDQ
33+
98gF0VW5UUbDzGX5NXHStNSEmNLx2zzWNKEYsfPtL96U5Y8DOF959+aXsU1F/6vV
34+
h57g2Xm1Ye07CqHJFJsLmjdK7o3aatAogru7/T4+yliNEL0MHAvm24rjt5wt6j4w
35+
5ulkNTl5uHQtoFzQXZy+CAjD7t5/3OUYBsZ4BnELXtB5frk86tFfwFCGarUsG7Jg
36+
42OTSW9JSiLGTQ36FnZtHuWgCqe+DrmI/mnQWuayiNKIXqoRjqkr0n4bKD1JvLoB
37+
b+hI
38+
-----END CERTIFICATE-----

app/src/main/java/org/supla/android/core/infrastructure/CurrentWifiNetworkInfoProvider.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ class CurrentWifiNetworkInfoProvider @Inject constructor(
5959
Trace.i(CurrentWifiNetworkInfoProvider::class.simpleName, "onCapabilitiesChanged ${wifiInfo?.ssid}")
6060
wifiInfo?.let {
6161
networkInfo = NetworkInfo(
62-
it.ssid?.skipQuotation()?.skipUnknownSsid(),
63-
it.networkId
62+
ssid = it.ssid?.skipQuotation()?.skipUnknownSsid(),
63+
networkId = it.networkId,
64+
networkType = if (it.frequency < 2500) NetworkType.TYPE_2_4_GHZ else NetworkType.TYPE_5_GHZ
6465
)
6566
}
6667
}
@@ -84,15 +85,21 @@ class CurrentWifiNetworkInfoProvider @Inject constructor(
8485
wifiManager.connectionInfo?.let {
8586
NetworkInfo(
8687
ssid = it.ssid?.skipQuotation()?.skipUnknownSsid(),
87-
networkId = it.networkId
88+
networkId = it.networkId,
89+
networkType = if (it.frequency < 2500) NetworkType.TYPE_2_4_GHZ else NetworkType.TYPE_5_GHZ
8890
)
8991
}
9092
}
9193

9294
data class NetworkInfo(
9395
val ssid: String?,
94-
val networkId: Int
96+
val networkId: Int,
97+
val networkType: NetworkType
9598
)
99+
100+
enum class NetworkType {
101+
TYPE_2_4_GHZ, TYPE_5_GHZ
102+
}
96103
}
97104

98105
private fun String.skipUnknownSsid(): String? =

app/src/main/java/org/supla/android/core/shared/LocalizedStringIdExtensions.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ val LocalizedStringId.resourceId: Int
132132
LocalizedStringId.ADD_WIZARD_RESULT_CONNECTION_ERROR -> R.string.wizard_result_conn_error
133133
LocalizedStringId.ADD_WIZARD_RESULT_FAILED -> R.string.wizard_result_failed
134134
LocalizedStringId.ADD_WIZARD_RECONNECT_TIMEOUT -> R.string.wizard_reconnect_timeout
135+
LocalizedStringId.ADD_WIZARD_DEVICE_TEMPORARILY_LOCKED -> R.string.add_wizard_device_temporarily_locked
136+
LocalizedStringId.ADD_WIZARD_STATE_PREPARING -> R.string.wizard_state_preparing
137+
LocalizedStringId.ADD_WIZARD_STATE_CONNECTING -> R.string.wizard_state_connecting
138+
LocalizedStringId.ADD_WIZARD_STATE_CONFIGURING -> R.string.wizard_state_configuring
139+
LocalizedStringId.ADD_WIZARD_STATE_FINISHING -> R.string.wizard_state_finishing
135140

136141
LocalizedStringId.CHANNEL_STATE_UPTIME -> R.string.channel_state_uptime
137142
LocalizedStringId.LAST_CONNECTION_RESET_CAUSE_UNKNOWN -> R.string.lastconnectionresetcause_unknown

app/src/main/java/org/supla/android/data/model/electricitymeter/ElectricityMeterSettings.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ data class ElectricityMeterSettings(
5656
SuplaElectricityMeasurementType.FORWARD_ACTIVE_ENERGY,
5757
SuplaElectricityMeasurementType.REVERSE_ACTIVE_ENERGY,
5858
SuplaElectricityMeasurementType.POWER_ACTIVE,
59+
SuplaElectricityMeasurementType.POWER_ACTIVE_KW,
5960
SuplaElectricityMeasurementType.VOLTAGE
6061
)
6162

app/src/main/java/org/supla/android/data/source/ChannelRepository.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ public interface ChannelRepository {
6868

6969
void updateLocation(Location location);
7070

71-
Cursor getAllProfileChannels(Long profileId);
72-
73-
Cursor getAllProfileChannelGroups(Long profileId);
74-
7571
@NotNull
7672
List<Location> getAllLocations();
7773
}

app/src/main/java/org/supla/android/data/source/DefaultChannelRepository.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -231,23 +231,6 @@ public void updateLocation(@Nullable Location location) {
231231
locationDao.update(location);
232232
}
233233

234-
@Override
235-
public Cursor getAllProfileChannels(Long profileId) {
236-
return channelDao.getAllChannels(
237-
ChannelView.COLUMN_CHANNEL_FUNCTION
238-
+ " <> 0 "
239-
+ " AND (C."
240-
+ ChannelView.COLUMN_CHANNEL_PROFILE_ID
241-
+ " = "
242-
+ profileId
243-
+ ") ");
244-
}
245-
246-
@Override
247-
public Cursor getAllProfileChannelGroups(Long profileId) {
248-
return channelDao.getAllChannelGroupsForProfileId(profileId);
249-
}
250-
251234
@NonNull
252235
@Override
253236
public List<Location> getAllLocations() {

app/src/main/java/org/supla/android/data/source/local/ChannelDao.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -187,32 +187,6 @@ public Cursor getChannelListCursorWithDefaultOrder(String where) {
187187
return getChannelListCursor(orderBY, where);
188188
}
189189

190-
public Cursor getAllChannels(String where) {
191-
String orderBY =
192-
"L."
193-
+ LocationEntity.COLUMN_SORT_ORDER
194-
+ ", "
195-
+ "L."
196-
+ LocationEntity.COLUMN_CAPTION
197-
+ " COLLATE LOCALIZED, "
198-
+ "C."
199-
+ ChannelEntity.COLUMN_POSITION
200-
+ ", "
201-
+ "C."
202-
+ ChannelView.COLUMN_CHANNEL_FUNCTION
203-
+ " DESC, "
204-
+ "C."
205-
+ ChannelView.COLUMN_CHANNEL_CAPTION
206-
+ " COLLATE LOCALIZED";
207-
208-
return getChannelListCursor(orderBY, where);
209-
}
210-
211-
public Cursor getAllChannelGroupsForProfileId(Long profileId) {
212-
return getChannelGroupListCursor(
213-
"G." + ChannelGroupEntity.COLUMN_PROFILE_ID + " = " + profileId);
214-
}
215-
216190
public boolean isZWaveBridgeChannelAvailable() {
217191
String[] projection = {ChannelView.COLUMN_CHANNEL_ID};
218192

app/src/main/java/org/supla/android/data/source/local/SceneDao.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class SceneDao(dap: DatabaseAccessProvider) : BaseDao(dap) {
8585
selectionArgs = arrayOf(profileId.toString())
8686
}
8787
val order = SceneView.COLUMN_LOCATION_SORT_ORDER + ", " +
88-
SceneView.COLUMN_LOCATION_NAME + " COLLATE LOCALIZED, " +
88+
SceneView.COLUMN_LOCATION_NAME + " COLLATE UNICODE, " +
8989
SceneEntity.COLUMN_SORT_ORDER + ", " +
9090
SceneEntity.COLUMN_CAPTION + " COLLATE LOCALIZED, " +
9191
SceneEntity.COLUMN_REMOTE_ID

app/src/main/java/org/supla/android/data/source/local/dao/ChannelDao.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ interface ChannelDao {
389389
AND channel.$COLUMN_VISIBLE > 0
390390
ORDER BY
391391
location.${LocationEntity.COLUMN_SORT_ORDER},
392-
location.${LocationEntity.COLUMN_CAPTION} COLLATE LOCALIZED,
392+
location.${LocationEntity.COLUMN_CAPTION} COLLATE UNICODE,
393393
channel.${ChannelEntity.COLUMN_POSITION},
394394
channel.${ChannelEntity.COLUMN_FUNCTION} DESC,
395395
channel.$COLUMN_CAPTION COLLATE LOCALIZED
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package org.supla.android.data.source.remote.esp
2+
/*
3+
Copyright (C) AC SOFTWARE SP. Z O.O.
4+
5+
This program is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU General Public License
7+
as published by the Free Software Foundation; either version 2
8+
of the License, or (at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program; if not, write to the Free Software
17+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18+
*/
19+
20+
import okhttp3.Interceptor
21+
import okhttp3.Response
22+
import java.io.IOException
23+
import java.security.cert.X509Certificate
24+
import javax.inject.Inject
25+
import javax.inject.Singleton
26+
27+
@Singleton
28+
class EspCommonNameValidationInterceptor @Inject constructor(
29+
private val session: EspConfigurationSession
30+
) : Interceptor {
31+
override fun intercept(chain: Interceptor.Chain): Response =
32+
if (session.useSecureLayer) {
33+
val response = chain.proceed(chain.request())
34+
val commonNameHeader = response.headers["CN"]
35+
val commonNameCertificate = findCommonNameInCertificate(response)
36+
37+
if (commonNameHeader != null && commonNameCertificate != null && commonNameHeader == commonNameCertificate) {
38+
response
39+
} else {
40+
throw IOException("Different common names (certificate `$commonNameCertificate`, response `$commonNameHeader`)")
41+
}
42+
} else {
43+
chain.proceed(chain.request())
44+
}
45+
46+
private fun findCommonNameInCertificate(response: Response): String? {
47+
response.handshake?.let { handshake ->
48+
for (certificate in handshake.peerCertificates) {
49+
(certificate as? X509Certificate)?.let {
50+
return extractCnFromCertificate(it)
51+
}
52+
}
53+
}
54+
55+
return null
56+
}
57+
58+
fun extractCnFromCertificate(certificate: X509Certificate): String? {
59+
val subjectDn = certificate.subjectX500Principal.name
60+
val cnPattern = "CN=([^,]+)".toRegex()
61+
val matchResult = cnPattern.find(subjectDn)
62+
return matchResult?.groups?.get(1)?.value
63+
}
64+
}

0 commit comments

Comments
 (0)