This commit is contained in:
Mygod
2018-06-10 21:35:27 +08:00
parent d68932f72b
commit 3fbca0abef
4 changed files with 11 additions and 8 deletions

View File

@@ -7,6 +7,8 @@ import android.content.ComponentName
import android.content.Intent import android.content.Intent
import android.content.ServiceConnection import android.content.ServiceConnection
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.location.LocationManager
import android.os.Build
import android.os.IBinder import android.os.IBinder
import android.provider.Settings import android.provider.Settings
import android.support.v7.widget.RecyclerView import android.support.v7.widget.RecyclerView
@@ -46,8 +48,10 @@ class LocalOnlyHotspotManager(private val parent: TetheringFragment) : Manager()
* https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/53e0284/service/java/com/android/server/wifi/WifiServiceImpl.java#1204 * https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/53e0284/service/java/com/android/server/wifi/WifiServiceImpl.java#1204
* https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/53e0284/service/java/com/android/server/wifi/WifiSettingsStore.java#228 * https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/53e0284/service/java/com/android/server/wifi/WifiSettingsStore.java#228
*/ */
if (Settings.Secure.getInt(view.context.contentResolver, Settings.Secure.LOCATION_MODE, if (if (Build.VERSION.SDK_INT < 28) @Suppress("DEPRECATION") {
Settings.Secure.LOCATION_MODE_OFF) == Settings.Secure.LOCATION_MODE_OFF) { Settings.Secure.getInt(view.context.contentResolver, Settings.Secure.LOCATION_MODE,
Settings.Secure.LOCATION_MODE_OFF) == Settings.Secure.LOCATION_MODE_OFF
} else !context.getSystemService(LocationManager::class.java).isLocationEnabled) {
Toast.makeText(view.context, R.string.tethering_temp_hotspot_location, Toast.LENGTH_LONG).show() Toast.makeText(view.context, R.string.tethering_temp_hotspot_location, Toast.LENGTH_LONG).show()
try { try {
view.context.startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)) view.context.startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))

View File

@@ -142,13 +142,11 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic
(viewHolder as ViewHolder).binding.data = data (viewHolder as ViewHolder).binding.data = data
} }
fun update() = data.notifyChange()
override fun onServiceConnected(name: ComponentName?, service: IBinder?) { override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
binder = service as RepeaterService.Binder binder = service as RepeaterService.Binder
service.statusChanged[this] = data::onStatusChanged service.statusChanged[this] = data::onStatusChanged
service.groupChanged[this] = data::onGroupChanged service.groupChanged[this] = data::onGroupChanged
update() data.notifyChange()
} }
override fun onServiceDisconnected(name: ComponentName?) { override fun onServiceDisconnected(name: ComponentName?) {

View File

@@ -127,7 +127,8 @@ object TetheringManager {
} }
fun getTetheredIfaces(extras: Bundle) = extras.getStringArrayList( fun getTetheredIfaces(extras: Bundle) = extras.getStringArrayList(
if (Build.VERSION.SDK_INT >= 26) EXTRA_ACTIVE_TETHER else EXTRA_ACTIVE_TETHER_LEGACY) if (Build.VERSION.SDK_INT >= 26) EXTRA_ACTIVE_TETHER else EXTRA_ACTIVE_TETHER_LEGACY)!!
fun getLocalOnlyTetheredIfaces(extras: Bundle) = fun getLocalOnlyTetheredIfaces(extras: Bundle) =
if (Build.VERSION.SDK_INT >= 26) extras.getStringArrayList(EXTRA_ACTIVE_LOCAL_ONLY) else emptyList<String>() if (Build.VERSION.SDK_INT >= 26) extras.getStringArrayList(EXTRA_ACTIVE_LOCAL_ONLY)!!
else emptyList<String>()
} }

View File

@@ -37,7 +37,7 @@ open class AlwaysAutoCompleteEditTextPreferenceDialogFragmentCompat : Preference
override fun needInputMethod(): Boolean = true override fun needInputMethod(): Boolean = true
protected fun onAddEditTextToDialogView(dialogView: View, editText: EditText) { protected open fun onAddEditTextToDialogView(dialogView: View, editText: EditText) {
val oldEditText = dialogView.findViewById<View>(android.R.id.edit) val oldEditText = dialogView.findViewById<View>(android.R.id.edit)
if (oldEditText != null) { if (oldEditText != null) {
val container = oldEditText.parent as? ViewGroup? val container = oldEditText.parent as? ViewGroup?