Commit c21be3f0 authored by jyx's avatar jyx

去除权限校验

parent 3fe5fc6c
......@@ -43,7 +43,7 @@
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" /> <!-- 蘑菇星球 -->
<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
android:name="com.mints.flowbox.permission"
......@@ -156,13 +156,16 @@
<activity
android:name=".ui.activitys.Increasespeed2Activity"
android:launchMode="singleTop"
android:excludeFromRecents="true" />
<activity
android:name=".ui.activitys.IncreasespeedActivity"
android:launchMode="singleTop"
android:excludeFromRecents="true" />
<activity
android:name=".ui.activitys.CleanActivity"
android:launchMode="singleTop"
android:excludeFromRecents="true" />
<activity
......
......@@ -15,7 +15,6 @@ import com.mints.flowbox.utils.ToolUtil
import com.mints.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_screen.*
import kotlinx.android.synthetic.main.activity_screen.fl_ad
import net.phone.PhoneBrandUtils
import java.util.*
class ScreenActivity : OutAppActivity(), View.OnClickListener {
......@@ -78,7 +77,7 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener {
IncreasespeedActivity.INCREASE_TYPE,
IncreasespeedActivity.INCREASE_BOOST
)
readyGo(IncreasespeedActivity::class.java)
readyGo(IncreasespeedActivity::class.java, bundle)
}
R.id.tvClean -> {
// 一键清理
......@@ -87,7 +86,7 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener {
IncreasespeedActivity.INCREASE_TYPE,
IncreasespeedActivity.INCREASE_CLEAN
)
readyGo(IncreasespeedActivity::class.java)
readyGo(IncreasespeedActivity::class.java, bundle)
}
R.id.tvSaveBattery -> {
val bundle = Bundle()
......
......@@ -505,14 +505,9 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
readyGo(IncreasespeedActivity::class.java, bundle)
}
R.id.btn_signal -> { // 信号增强
if (ActivityCompat.checkSelfPermission(
requireActivity(),
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED
) {
checkPermission()
return
}
checkPermission(object : Callback {
override fun success() {
// 未打开定位开关
if (!PermissionUtils.isOpenGps(mContext)) {
......@@ -529,6 +524,13 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
// 预加载信息流
ExpressManager.loadExpress(false)
readyGo(SpeedFastActivity::class.java)
}
override fun fail() {
}
})
}
R.id.ivImg -> { // 点我赚钱
(requireActivity() as MainActivity).clickTab4Layout()
......@@ -546,7 +548,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
/** 检测权限 */
private fun checkPermission() {
private fun checkPermission(callback: Callback) {
val request: Observable<Boolean> =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
if (PhoneBrandUtils.isXiaomi()) {
......@@ -571,15 +573,15 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
request.subscribe { granted: Boolean ->
if (granted) {
Handler(Looper.getMainLooper()).postDelayed({
loadWifiData()
}, 1000)
callback.success()
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
showMissingPermissionDialog("位置")
} else {
showMissingPermissionDialog("位置,存储 ")
}
callback.fail()
}
}
}
......@@ -610,30 +612,34 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
view?.let {
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)) {
ToastUtils.show("GPS没有开启,申请打开GPS")
openGpsSettings()
return
}
// 校验是否已经打开wifi
if (!wifiUtils.isWifiConnected(mContext) || !wifiUtils.isWifiEnable) {
ToastUtils.show("wifi没有开启,申请打开wifi")
wifiUtils.openWifi()
startActivity(Intent(Settings.ACTION_WIFI_SETTINGS))
return
}
}
override fun fail() {
}
})
}
}
if (mWifiList.isNotEmpty() && mWifiList[position].isConnected) return
if (mWifiList.isEmpty() || mWifiList[position].isConnected) return
val wifiListBean = mWifiList[position]
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;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat;
import androidx.core.content.PermissionChecker;
import java.lang.reflect.Method;
import java.util.ArrayList;
......@@ -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