Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
os
android_packages_apps_Updater
Commits
c8b1aafc
Commit
c8b1aafc
authored
Apr 02, 2021
by
Romain Hunault
Browse files
Merge branch 'update_source_fix_q' into 'v1-q'
Update source fix q See merge request
!34
parents
c28ac911
018e5018
Changes
2
Hide whitespace changes
Inline
Side-by-side
res/values/strings.xml
View file @
c8b1aafc
...
...
@@ -33,6 +33,7 @@
{incr} - Incremental version
-->
<string
name=
"updater_server_url"
translatable=
"false"
>
https://ota.ecloud.global/api/v1/{device}/{type}/{incr}
</string>
<string
name=
"ota_staging_server_url"
translatable=
"false"
>
https://test.ota.ecloud.global/api/v1/{device}/{type}/{incr}
</string>
<string
name=
"verification_failed_notification"
>
Verification failed
</string>
<string
name=
"verifying_download_notification"
>
Verifying update
</string>
...
...
src/org/lineageos/updater/misc/Utils.java
View file @
c8b1aafc
/*
* Copyright (C) 2017 The LineageOS Project
* Copyright (C) 2021 ECORP SAS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -22,8 +23,10 @@ import android.content.Context;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.content.pm.PackageManager
;
import
android.database.Cursor
;
import
android.net.ConnectivityManager
;
import
android.net.NetworkInfo
;
import
android.net.Uri
;
import
android.os.Environment
;
import
android.os.SystemProperties
;
import
android.os.storage.StorageManager
;
...
...
@@ -59,6 +62,7 @@ import java.util.regex.Pattern;
public
class
Utils
{
private
static
final
String
TAG
=
"Utils"
;
private
static
final
String
CONTENT_URI_PATH
=
"content://custom.setting.Provider.OTA_SERVER/cte"
;
private
Utils
()
{
}
...
...
@@ -184,16 +188,40 @@ public class Utils {
SystemProperties
.
get
(
Constants
.
PROP_DEVICE
));
String
type
=
SystemProperties
.
get
(
Constants
.
PROP_RELEASE_TYPE
).
toLowerCase
(
Locale
.
ROOT
);
String
serverUrl
=
SystemProperties
.
get
(
Constants
.
PROP_UPDATER_URI
);
String
serverUrl
=
""
;
if
(
retrieveStatus
(
context
)
!=
null
)
{
if
(
retrieveStatus
(
context
).
equals
(
"true"
))
{
serverUrl
=
context
.
getString
(
R
.
string
.
ota_staging_server_url
);
return
serverUrl
.
replace
(
"{device}"
,
device
)
.
replace
(
"{type}"
,
type
)
.
replace
(
"{incr}"
,
incrementalVersion
);
}
else
{
serverUrl
=
SystemProperties
.
get
(
Constants
.
PROP_UPDATER_URI
);
}
}
else
{
serverUrl
=
SystemProperties
.
get
(
Constants
.
PROP_UPDATER_URI
);
}
if
(
serverUrl
.
trim
().
isEmpty
())
{
serverUrl
=
context
.
getString
(
R
.
string
.
updater_server_url
);
}
return
serverUrl
.
replace
(
"{device}"
,
device
)
.
replace
(
"{type}"
,
type
)
.
replace
(
"{incr}"
,
incrementalVersion
);
}
/*get the status from database that ota option is on or off*/
public
static
String
retrieveStatus
(
Context
context
)
{
String
status
=
null
;
Cursor
cursor
=
context
.
getContentResolver
().
query
(
Uri
.
parse
(
CONTENT_URI_PATH
),
null
,
"id=?"
,
new
String
[]{
"1"
},
"Status"
);
if
(
cursor
.
moveToFirst
())
{
do
{
status
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
"Status"
));
}
while
(
cursor
.
moveToNext
());
}
return
status
;
}
public
static
String
getUpgradeBlockedURL
(
Context
context
)
{
String
device
=
SystemProperties
.
get
(
Constants
.
PROP_NEXT_DEVICE
,
SystemProperties
.
get
(
Constants
.
PROP_DEVICE
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment