Commit c21be3f0 authored by jyx's avatar jyx

去除权限校验

parent 3fe5fc6c
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<uses-permission android:name="android.permission.SET_WALLPAPER" /> <uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" /> <!-- 蘑菇星球 --> <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" /> <!-- 蘑菇星球 -->
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" /> <uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name=".android.permission.PROCESS_OUTGOING_CALLS" /> <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<permission <permission
android:name="com.mints.flowbox.permission" android:name="com.mints.flowbox.permission"
...@@ -156,13 +156,16 @@ ...@@ -156,13 +156,16 @@
<activity <activity
android:name=".ui.activitys.Increasespeed2Activity" android:name=".ui.activitys.Increasespeed2Activity"
android:launchMode="singleTop"
android:excludeFromRecents="true" /> android:excludeFromRecents="true" />
<activity <activity
android:name=".ui.activitys.IncreasespeedActivity" android:name=".ui.activitys.IncreasespeedActivity"
android:launchMode="singleTop"
android:excludeFromRecents="true" /> android:excludeFromRecents="true" />
<activity <activity
android:name=".ui.activitys.CleanActivity" android:name=".ui.activitys.CleanActivity"
android:launchMode="singleTop"
android:excludeFromRecents="true" /> android:excludeFromRecents="true" />
<activity <activity
......
...@@ -15,7 +15,6 @@ import com.mints.flowbox.utils.ToolUtil ...@@ -15,7 +15,6 @@ import com.mints.flowbox.utils.ToolUtil
import com.mints.library.utils.nodoubleclick.AntiShake import com.mints.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_screen.* import kotlinx.android.synthetic.main.activity_screen.*
import kotlinx.android.synthetic.main.activity_screen.fl_ad import kotlinx.android.synthetic.main.activity_screen.fl_ad
import net.phone.PhoneBrandUtils
import java.util.* import java.util.*
class ScreenActivity : OutAppActivity(), View.OnClickListener { class ScreenActivity : OutAppActivity(), View.OnClickListener {
...@@ -78,7 +77,7 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener { ...@@ -78,7 +77,7 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener {
IncreasespeedActivity.INCREASE_TYPE, IncreasespeedActivity.INCREASE_TYPE,
IncreasespeedActivity.INCREASE_BOOST IncreasespeedActivity.INCREASE_BOOST
) )
readyGo(IncreasespeedActivity::class.java) readyGo(IncreasespeedActivity::class.java, bundle)
} }
R.id.tvClean -> { R.id.tvClean -> {
// 一键清理 // 一键清理
...@@ -87,7 +86,7 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener { ...@@ -87,7 +86,7 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener {
IncreasespeedActivity.INCREASE_TYPE, IncreasespeedActivity.INCREASE_TYPE,
IncreasespeedActivity.INCREASE_CLEAN IncreasespeedActivity.INCREASE_CLEAN
) )
readyGo(IncreasespeedActivity::class.java) readyGo(IncreasespeedActivity::class.java, bundle)
} }
R.id.tvSaveBattery -> { R.id.tvSaveBattery -> {
val bundle = Bundle() val bundle = Bundle()
......
...@@ -505,14 +505,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -505,14 +505,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
readyGo(IncreasespeedActivity::class.java, bundle) readyGo(IncreasespeedActivity::class.java, bundle)
} }
R.id.btn_signal -> { // 信号增强 R.id.btn_signal -> { // 信号增强
if (ActivityCompat.checkSelfPermission(
requireActivity(), checkPermission(object : Callback {
Manifest.permission.ACCESS_FINE_LOCATION override fun success() {
) != PackageManager.PERMISSION_GRANTED
) {
checkPermission()
return
}
// 未打开定位开关 // 未打开定位开关
if (!PermissionUtils.isOpenGps(mContext)) { if (!PermissionUtils.isOpenGps(mContext)) {
...@@ -529,6 +524,13 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -529,6 +524,13 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
// 预加载信息流 // 预加载信息流
ExpressManager.loadExpress(false) ExpressManager.loadExpress(false)
readyGo(SpeedFastActivity::class.java) readyGo(SpeedFastActivity::class.java)
}
override fun fail() {
}
})
} }
R.id.ivImg -> { // 点我赚钱 R.id.ivImg -> { // 点我赚钱
(requireActivity() as MainActivity).clickTab4Layout() (requireActivity() as MainActivity).clickTab4Layout()
...@@ -546,7 +548,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -546,7 +548,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
} }
/** 检测权限 */ /** 检测权限 */
private fun checkPermission() { private fun checkPermission(callback: Callback) {
val request: Observable<Boolean> = val request: Observable<Boolean> =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
if (PhoneBrandUtils.isXiaomi()) { if (PhoneBrandUtils.isXiaomi()) {
...@@ -571,15 +573,15 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -571,15 +573,15 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
} }
request.subscribe { granted: Boolean -> request.subscribe { granted: Boolean ->
if (granted) { if (granted) {
Handler(Looper.getMainLooper()).postDelayed({ callback.success()
loadWifiData()
}, 1000)
} else { } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
showMissingPermissionDialog("位置") showMissingPermissionDialog("位置")
} else { } else {
showMissingPermissionDialog("位置,存储 ") showMissingPermissionDialog("位置,存储 ")
} }
callback.fail()
} }
} }
} }
...@@ -610,30 +612,34 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener, ...@@ -610,30 +612,34 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
view?.let { view?.let {
if (it.id == R.id.btn) { if (it.id == R.id.btn) {
if (ActivityCompat.checkSelfPermission(
requireActivity(),
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED
) {
checkPermission()
return
}
checkPermission(object : Callback {
override fun success() {
// 未打开定位开关 // 未打开定位开关
if (!PermissionUtils.isOpenGps(mContext)) { if (!PermissionUtils.isOpenGps(mContext)) {
ToastUtils.show("GPS没有开启,申请打开GPS")
openGpsSettings() openGpsSettings()
return return
} }
// 校验是否已经打开wifi
if (!wifiUtils.isWifiConnected(mContext) || !wifiUtils.isWifiEnable) { if (!wifiUtils.isWifiConnected(mContext) || !wifiUtils.isWifiEnable) {
ToastUtils.show("wifi没有开启,申请打开wifi")
wifiUtils.openWifi() wifiUtils.openWifi()
startActivity(Intent(Settings.ACTION_WIFI_SETTINGS)) startActivity(Intent(Settings.ACTION_WIFI_SETTINGS))
return return
} }
} }
override fun fail() {
}
})
}
} }
if (mWifiList.isNotEmpty() && mWifiList[position].isConnected) return if (mWifiList.isEmpty() || mWifiList[position].isConnected) return
val wifiListBean = mWifiList[position] val wifiListBean = mWifiList[position]
if (wifiDialog == null) wifiDialog = if (wifiDialog == null) wifiDialog =
......
package com.mints.flowbox.utils
interface Callback {
fun success()
fun fail()
}
\ No newline at end of file
...@@ -13,6 +13,7 @@ import android.provider.Settings; ...@@ -13,6 +13,7 @@ import android.provider.Settings;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.content.PermissionChecker;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -199,4 +200,23 @@ public class PermissionUtils { ...@@ -199,4 +200,23 @@ public class PermissionUtils {
} }
} }
/**
* 权限是否开启校验
*
* @param permission
* @return
*/
public static boolean selfPermissionGranted(String permission, Context context) {
// For Android < Android M, self permissions are always granted.
boolean result = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// targetSdkVersion >= Android M, we can
// use Context#checkSelfPermission
result = context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED;
}
return result;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment