Skip to content

Commit 800f760

Browse files
committed
remove REQUEST_INSTALL_PACKAGES permission, rely on website for installation
1 parent c3109a7 commit 800f760

File tree

4 files changed

+55
-11
lines changed

4 files changed

+55
-11
lines changed

app/src/flat/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
22

3-
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
3+
<!--<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />-->
44

55
<application>
66

app/src/main/java/io/agora/flat/common/android/ProtocolUrlManager.kt

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import io.agora.flat.data.AppEnv.Companion.ENV_SG_PROD
1111
object ProtocolUrlManager {
1212
private const val PRIVACY = "privacy"
1313
private const val SERVICE = "service"
14+
private const val WEBSITE = "website"
1415

1516
private lateinit var application: Context
1617

@@ -20,25 +21,45 @@ object ProtocolUrlManager {
2021
PRIVACY to mapOf(
2122
ENV_CN_PROD to mapOf(
2223
"en" to "https://www.flat.apprtc.cn/en/privacy.html", "zh" to "https://www.flat.apprtc.cn/privacy.html"
23-
), ENV_CN_DEV to mapOf(
24+
),
25+
ENV_CN_DEV to mapOf(
2426
"en" to "https://www.flat.apprtc.cn/en/privacy.html", "zh" to "https://www.flat.apprtc.cn/privacy.html"
25-
), ENV_SG_PROD to mapOf(
27+
),
28+
ENV_SG_PROD to mapOf(
2629
"en" to "https://flat.agora.io/privacy.html", "zh" to "https://flat.agora.io/zh/privacy.html"
27-
), ENV_SG_DEV to mapOf(
30+
),
31+
ENV_SG_DEV to mapOf(
2832
"en" to "https://flat.agora.io/privacy.html", "zh" to "https://flat.agora.io/zh/privacy.html"
29-
)
30-
),
31-
SERVICE to mapOf(
33+
),
34+
), SERVICE to mapOf(
3235
ENV_CN_PROD to mapOf(
3336
"en" to "https://www.flat.apprtc.cn/en/service.html", "zh" to "https://www.flat.apprtc.cn/service.html"
34-
), ENV_CN_DEV to mapOf(
37+
),
38+
ENV_CN_DEV to mapOf(
3539
"en" to "https://www.flat.apprtc.cn/en/service.html", "zh" to "https://www.flat.apprtc.cn/service.html"
36-
), ENV_SG_PROD to mapOf(
40+
),
41+
ENV_SG_PROD to mapOf(
3742
"en" to "https://flat.agora.io/en/service.html", "zh" to "https://flat.agora.io/zh/service.html"
38-
), ENV_SG_DEV to mapOf(
43+
),
44+
ENV_SG_DEV to mapOf(
3945
"en" to "https://flat.agora.io/en/service.html", "zh" to "https://flat.agora.io/zh/service.html"
40-
)
46+
),
4147
),
48+
49+
WEBSITE to mapOf(
50+
ENV_CN_PROD to mapOf(
51+
"en" to "https://www.flat.apprtc.cn/#download", "zh" to "https://www.flat.apprtc.cn/#download"
52+
),
53+
ENV_CN_DEV to mapOf(
54+
"en" to "https://www.flat.apprtc.cn/#download", "zh" to "https://www.flat.apprtc.cn/#download"
55+
),
56+
ENV_SG_PROD to mapOf(
57+
"en" to "https://flat.agora.io/#download", "zh" to "https://flat.agora.io/#download"
58+
),
59+
ENV_SG_DEV to mapOf(
60+
"en" to "https://flat.agora.io/#download", "zh" to "https://flat.agora.io/#download"
61+
),
62+
)
4263
)
4364

4465
fun init(app: Application) {
@@ -58,4 +79,11 @@ object ProtocolUrlManager {
5879
val lang = LanguageManager.currentLocale().language
5980
return urls[PRIVACY]!![env]?.get(lang) ?: "https://www.flat.apprtc.cn/privacy.html"
6081
}
82+
83+
val Website: String
84+
get() {
85+
val env = appEnv.getEnv()
86+
val lang = LanguageManager.currentLocale().language
87+
return urls[WEBSITE]!![env]?.get(lang) ?: "https://www.flat.apprtc.cn/#download"
88+
}
6189
}

app/src/main/java/io/agora/flat/ui/compose/UpdateDialog.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ import androidx.compose.ui.tooling.preview.Preview
2121
import androidx.compose.ui.unit.dp
2222
import androidx.compose.ui.window.Dialog
2323
import io.agora.flat.R
24+
import io.agora.flat.common.android.ProtocolUrlManager
2425
import io.agora.flat.common.version.VersionCheckResult
2526
import io.agora.flat.ui.theme.FlatTheme
2627
import io.agora.flat.ui.theme.Shapes
2728
import io.agora.flat.util.installApk
29+
import io.agora.flat.util.launchBrowser
2830
import kotlinx.coroutines.launch
2931

3032
@Composable
@@ -68,8 +70,14 @@ internal fun UpdateDialog(
6870
onGotoMarket()
6971
return@launch
7072
}
73+
// Open the website to download the app and install self
74+
if (true) {
75+
context.launchBrowser(ProtocolUrlManager.Website)
76+
return@launch
77+
}
7178
downloading = true
7279
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
80+
// Need to declare android.permission.REQUEST_INSTALL_PACKAGES to call this api
7381
val haveInstallPermission = context.packageManager.canRequestPackageInstalls()
7482
if (!haveInstallPermission) {
7583
showPermissionDialog = true

app/src/main/java/io/agora/flat/util/ContextExtensions.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,12 @@ fun Context.launchMarket() {
168168
)
169169
)
170170
}
171+
}
172+
173+
fun Context.launchBrowser(url: String) {
174+
try {
175+
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
176+
} catch (e: Exception) {
177+
// ignore
178+
}
171179
}

0 commit comments

Comments
 (0)