Merge branch 'master' into s

This commit is contained in:
Mygod
2021-07-10 19:26:22 -04:00
10 changed files with 41 additions and 31 deletions

View File

@@ -72,9 +72,9 @@ dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("androidx.appcompat:appcompat:1.3.0") // https://issuetracker.google.com/issues/151603528
implementation("androidx.browser:browser:1.3.0")
implementation("androidx.core:core-ktx:1.6.0-beta02")
implementation("androidx.core:core-ktx:1.6.0")
implementation("androidx.emoji:emoji:1.1.0")
implementation("androidx.fragment:fragment-ktx:1.3.4")
implementation("androidx.fragment:fragment-ktx:1.3.5")
implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion")
@@ -83,18 +83,18 @@ dependencies {
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("com.android.billingclient:billing-ktx:4.0.0")
implementation("com.google.android.gms:play-services-oss-licenses:17.0.0")
implementation("com.google.android.material:material:1.4.0-rc01")
implementation("com.google.android.material:material:1.4.0")
implementation("com.google.firebase:firebase-analytics-ktx:19.0.0")
implementation("com.google.firebase:firebase-crashlytics:18.0.1")
implementation("com.google.firebase:firebase-crashlytics:18.1.0")
implementation("com.google.zxing:core:3.4.1")
implementation("com.jakewharton.timber:timber:4.7.1")
implementation("com.linkedin.dexmaker:dexmaker:2.28.1")
implementation("com.takisoft.preferencex:preferencex-simplemenu:1.1.0")
implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.room:room-testing:$roomVersion")
androidTestImplementation("androidx.test:runner:1.3.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.3.0")
androidTestImplementation("androidx.test.ext:junit-ktx:1.1.2")
androidTestImplementation("androidx.test:runner:1.4.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
androidTestImplementation("androidx.test.ext:junit-ktx:1.1.3")
}

View File

@@ -479,17 +479,19 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene
private fun showNotification(group: WifiP2pGroup? = null) = ServiceNotification.startForeground(this,
if (group == null) emptyMap() else mapOf(Pair(group.`interface`, group.clientList?.size ?: 0)))
private fun removeGroup() = p2pManager.removeGroup(channel, object : WifiP2pManager.ActionListener {
override fun onSuccess() {
launch { cleanLocked() }
}
override fun onFailure(reason: Int) {
if (reason != WifiP2pManager.BUSY) {
SmartSnackbar.make(formatReason(R.string.repeater_remove_group_failure, reason)).show()
} // else assuming it's already gone
onSuccess()
}
})
private fun removeGroup() {
p2pManager.removeGroup(channel ?: return, object : WifiP2pManager.ActionListener {
override fun onSuccess() {
launch { cleanLocked() }
}
override fun onFailure(reason: Int) {
if (reason != WifiP2pManager.BUSY) {
SmartSnackbar.make(formatReason(R.string.repeater_remove_group_failure, reason)).show()
} // else assuming it's already gone
onSuccess()
}
})
}
private fun cleanLocked() {
if (receiverRegistered) {
ensureReceiverUnregistered(receiver)

View File

@@ -389,7 +389,7 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
}
}
true
} catch (e: IllegalArgumentException) {
} catch (e: RuntimeException) {
SmartSnackbar.make(e).show()
false
}

View File

@@ -326,6 +326,10 @@ object WifiApManager {
private val cancelLocalOnlyHotspotRequest by lazy {
WifiManager::class.java.getDeclaredMethod("cancelLocalOnlyHotspotRequest")
}
/**
* This is the only way to unregister requests besides app exiting.
* Therefore, we are happy with crashing the app if reflection fails.
*/
@RequiresApi(26)
fun cancelLocalOnlyHotspotRequest() = cancelLocalOnlyHotspotRequest(Services.wifi)

View File

@@ -213,8 +213,8 @@ data class SettingsGlobalPut(val name: String, val value: String) : RootCommandN
override suspend fun execute() = withContext(Dispatchers.IO) {
val process = ProcessBuilder("settings", "put", "global", name, value).fixPath(true).start()
val error = process.inputStream.bufferedReader().readText()
check(process.waitFor() == 0)
if (error.isNotEmpty()) throw RemoteException(error)
val exit = process.waitFor()
if (exit != 0 || error.isNotEmpty()) throw RemoteException("Process exited with $exit: $error")
null
}
}

View File

@@ -213,10 +213,14 @@ private val newLookup by lazy @TargetApi(26) {
* See also: https://stackoverflow.com/a/49532463/2245107
*/
fun InvocationHandler.callSuper(interfaceClass: Class<*>, proxy: Any, method: Method, args: Array<out Any?>?) = when {
Build.VERSION.SDK_INT >= 26 && method.isDefault -> newLookup.newInstance(interfaceClass, 0xf) // ALL_MODES
.`in`(interfaceClass).unreflectSpecial(method, interfaceClass).bindTo(proxy).run {
if (args == null) invokeWithArguments() else invokeWithArguments(*args)
}
Build.VERSION.SDK_INT >= 26 && method.isDefault -> try {
newLookup.newInstance(interfaceClass, 0xf) // ALL_MODES
} catch (e: ReflectiveOperationException) {
Timber.w(e)
MethodHandles.lookup().`in`(interfaceClass)
}.unreflectSpecial(method, interfaceClass).bindTo(proxy).run {
if (args == null) invokeWithArguments() else invokeWithArguments(*args)
}
// otherwise, we just redispatch it to InvocationHandler
method.declaringClass.isAssignableFrom(javaClass) -> when {
method.declaringClass == Object::class.java -> when (method.name) {