Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from permissions-dispatcher:master #21

Merged
merged 1 commit into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;

import androidx.collection.SimpleArrayMap;
import androidx.core.app.ActivityCompat;
import androidx.core.content.PermissionChecker;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;

public final class PermissionUtils {
Expand Down Expand Up @@ -46,7 +47,7 @@ public static boolean verifyPermissions(int... grantResults) {
return false;
}
for (int result : grantResults) {
if (result != PermissionChecker.PERMISSION_GRANTED) {
if (result != PackageManager.PERMISSION_GRANTED) {
return false;
}
}
Expand Down Expand Up @@ -96,7 +97,7 @@ public static boolean hasSelfPermissions(Context context, String... permissions)
*/
private static boolean hasSelfPermission(Context context, String permission) {
try {
return PermissionChecker.checkSelfPermission(context, permission) == PermissionChecker.PERMISSION_GRANTED;
return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
} catch (RuntimeException t) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package permissions.dispatcher.test

import android.content.pm.PackageManager
import androidx.core.app.ActivityCompat
import androidx.core.content.PermissionChecker
import androidx.core.content.ContextCompat
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
Expand All @@ -15,7 +15,7 @@ import org.powermock.modules.junit4.PowerMockRunner

@Suppress("IllegalIdentifier")
@RunWith(PowerMockRunner::class)
@PrepareForTest(ActivityCompat::class, PermissionChecker::class)
@PrepareForTest(ActivityCompat::class, ContextCompat::class)
class ActivityOnlyNeedsPermissionPermissionsDispatcherTest {

private lateinit var activity: ActivityOnlyNeedsPermission
Expand All @@ -34,7 +34,7 @@ class ActivityOnlyNeedsPermissionPermissionsDispatcherTest {
fun setUp() {
activity = Mockito.mock(ActivityOnlyNeedsPermission::class.java)
PowerMockito.mockStatic(ActivityCompat::class.java)
PowerMockito.mockStatic(PermissionChecker::class.java)
PowerMockito.mockStatic(ContextCompat::class.java)
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package permissions.dispatcher.test

import android.content.pm.PackageManager
import androidx.core.app.ActivityCompat
import androidx.core.content.PermissionChecker
import androidx.core.content.ContextCompat
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
Expand All @@ -17,7 +17,7 @@ import permissions.dispatcher.PermissionRequest

@Suppress("IllegalIdentifier")
@RunWith(PowerMockRunner::class)
@PrepareForTest(ActivityCompat::class, PermissionChecker::class)
@PrepareForTest(ActivityCompat::class, ContextCompat::class)
class ActivityWithAllAnnotationsKtPermissionsDispatcherTest {

private lateinit var activity: ActivityWithAllAnnotationsKt
Expand All @@ -38,7 +38,7 @@ class ActivityWithAllAnnotationsKtPermissionsDispatcherTest {
fun setUp() {
activity = Mockito.mock(ActivityWithAllAnnotationsKt::class.java)
PowerMockito.mockStatic(ActivityCompat::class.java)
PowerMockito.mockStatic(PermissionChecker::class.java)
PowerMockito.mockStatic(ContextCompat::class.java)
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package permissions.dispatcher.test

import android.content.pm.PackageManager
import androidx.core.app.ActivityCompat
import androidx.core.content.PermissionChecker
import androidx.core.content.ContextCompat
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
Expand All @@ -17,7 +17,7 @@ import permissions.dispatcher.PermissionRequest

@Suppress("IllegalIdentifier")
@RunWith(PowerMockRunner::class)
@PrepareForTest(ActivityCompat::class, PermissionChecker::class)
@PrepareForTest(ActivityCompat::class, ContextCompat::class)
class ActivityWithAllAnnotationsPermissionsDispatcherTest {

private lateinit var activity: ActivityWithAllAnnotations
Expand All @@ -36,7 +36,7 @@ class ActivityWithAllAnnotationsPermissionsDispatcherTest {
fun setUp() {
activity = Mockito.mock(ActivityWithAllAnnotations::class.java)
PowerMockito.mockStatic(ActivityCompat::class.java)
PowerMockito.mockStatic(PermissionChecker::class.java)
PowerMockito.mockStatic(ContextCompat::class.java)
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package permissions.dispatcher.test

import android.content.pm.PackageManager
import androidx.core.app.ActivityCompat
import androidx.core.content.PermissionChecker
import androidx.core.content.ContextCompat
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
Expand All @@ -15,7 +15,7 @@ import org.powermock.modules.junit4.PowerMockRunner

@Suppress("IllegalIdentifier")
@RunWith(PowerMockRunner::class)
@PrepareForTest(ActivityCompat::class, PermissionChecker::class)
@PrepareForTest(ActivityCompat::class, ContextCompat::class)
class ActivityWithNoParameterArgumentKtPermissionsDispatcherTest {

private lateinit var activity: ActivityWithNoParameterArgumentKt
Expand All @@ -36,7 +36,7 @@ class ActivityWithNoParameterArgumentKtPermissionsDispatcherTest {
fun setUp() {
activity = Mockito.mock(ActivityWithNoParameterArgumentKt::class.java)
PowerMockito.mockStatic(ActivityCompat::class.java)
PowerMockito.mockStatic(PermissionChecker::class.java)
PowerMockito.mockStatic(ContextCompat::class.java)
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package permissions.dispatcher.test

import android.content.pm.PackageManager
import androidx.core.app.ActivityCompat
import androidx.core.content.PermissionChecker
import androidx.core.content.ContextCompat
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
Expand All @@ -15,7 +15,7 @@ import org.powermock.modules.junit4.PowerMockRunner

@Suppress("IllegalIdentifier")
@RunWith(PowerMockRunner::class)
@PrepareForTest(ActivityCompat::class, PermissionChecker::class)
@PrepareForTest(ActivityCompat::class, ContextCompat::class)
class ActivityWithOnNeverAskAgainPermissionsDispatcherTest {
private lateinit var activity: ActivityWithOnNeverAskAgain

Expand All @@ -33,7 +33,7 @@ class ActivityWithOnNeverAskAgainPermissionsDispatcherTest {
fun setUp() {
activity = Mockito.mock(ActivityWithOnNeverAskAgain::class.java)
PowerMockito.mockStatic(ActivityCompat::class.java)
PowerMockito.mockStatic(PermissionChecker::class.java)
PowerMockito.mockStatic(ContextCompat::class.java)
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package permissions.dispatcher.test

import android.content.pm.PackageManager
import androidx.core.app.ActivityCompat
import androidx.core.content.PermissionChecker
import androidx.core.content.ContextCompat
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
Expand All @@ -15,7 +15,7 @@ import org.powermock.modules.junit4.PowerMockRunner

@Suppress("IllegalIdentifier")
@RunWith(PowerMockRunner::class)
@PrepareForTest(ActivityCompat::class, PermissionChecker::class)
@PrepareForTest(ActivityCompat::class, ContextCompat::class)
class ActivityWithOnPermissionDeniedPermissionsDispatcherTest {
private lateinit var activity: ActivityWithOnPermissionDenied

Expand All @@ -33,7 +33,7 @@ class ActivityWithOnPermissionDeniedPermissionsDispatcherTest {
fun setUp() {
activity = Mockito.mock(ActivityWithOnPermissionDenied::class.java)
PowerMockito.mockStatic(ActivityCompat::class.java)
PowerMockito.mockStatic(PermissionChecker::class.java)
PowerMockito.mockStatic(ContextCompat::class.java)
}

@After
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package permissions.dispatcher.test

import androidx.core.app.ActivityCompat
import androidx.core.content.PermissionChecker
import androidx.core.content.ContextCompat
import org.junit.After
import org.junit.Before
import org.junit.Test
Expand All @@ -13,7 +13,7 @@ import org.powermock.modules.junit4.PowerMockRunner

@Suppress("IllegalIdentifier")
@RunWith(PowerMockRunner::class)
@PrepareForTest(ActivityCompat::class, PermissionChecker::class)
@PrepareForTest(ActivityCompat::class, ContextCompat::class)
class ActivityWithStringParameterKtPermissionsDispatcherTest {

private lateinit var activity: ActivityWithParametersKt
Expand All @@ -22,7 +22,7 @@ class ActivityWithStringParameterKtPermissionsDispatcherTest {
fun setUp() {
activity = Mockito.mock(ActivityWithParametersKt::class.java)
PowerMockito.mockStatic(ActivityCompat::class.java)
PowerMockito.mockStatic(PermissionChecker::class.java)
PowerMockito.mockStatic(ContextCompat::class.java)
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package permissions.dispatcher.test

import android.content.pm.PackageManager
import androidx.core.app.ActivityCompat
import androidx.core.content.PermissionChecker
import androidx.core.content.ContextCompat
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
Expand All @@ -17,7 +17,7 @@ import permissions.dispatcher.PermissionRequest

@Suppress("IllegalIdentifier")
@RunWith(PowerMockRunner::class)
@PrepareForTest(ActivityCompat::class, PermissionChecker::class)
@PrepareForTest(ActivityCompat::class, ContextCompat::class)
class ActivityWithShowRationalePermissionsDispatcherTest {

private lateinit var activity: ActivityWithShowRationale
Expand All @@ -36,7 +36,7 @@ class ActivityWithShowRationalePermissionsDispatcherTest {
fun setUp() {
activity = Mockito.mock(ActivityWithShowRationale::class.java)
PowerMockito.mockStatic(ActivityCompat::class.java)
PowerMockito.mockStatic(PermissionChecker::class.java)
PowerMockito.mockStatic(ContextCompat::class.java)
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.os.Build
import android.provider.Settings
import androidx.core.app.ActivityCompat
import androidx.core.app.AppOpsManagerCompat
import androidx.core.content.PermissionChecker
import androidx.core.content.ContextCompat
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
Expand All @@ -23,7 +23,7 @@ import permissions.dispatcher.test.ActivityWithSystemAlertWindowAllAnnotationsPe

@Suppress("IllegalIdentifier")
@RunWith(PowerMockRunner::class)
@PrepareForTest(ActivityCompat::class, PermissionChecker::class,
@PrepareForTest(ActivityCompat::class, ContextCompat::class,
AppOpsManagerCompat::class, Settings::class, Build.VERSION::class, Uri::class)
class ActivityWithSystemAlertWindowAllAnnotationsPermissionsDispatcherTest {
private lateinit var activity: ActivityWithSystemAlertWindowAllAnnotations
Expand All @@ -42,7 +42,7 @@ class ActivityWithSystemAlertWindowAllAnnotationsPermissionsDispatcherTest {
fun setUp() {
activity = Mockito.mock(ActivityWithSystemAlertWindowAllAnnotations::class.java)
PowerMockito.mockStatic(ActivityCompat::class.java)
PowerMockito.mockStatic(PermissionChecker::class.java)
PowerMockito.mockStatic(ContextCompat::class.java)
PowerMockito.mockStatic(Settings::class.java)
PowerMockito.mockStatic(Uri::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.net.Uri
import android.os.Build
import android.provider.Settings
import androidx.core.app.ActivityCompat
import androidx.core.content.PermissionChecker
import androidx.core.content.ContextCompat
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
Expand All @@ -20,7 +20,7 @@ import permissions.dispatcher.PermissionRequest

@Suppress("IllegalIdentifier")
@RunWith(PowerMockRunner::class)
@PrepareForTest(ActivityCompat::class, PermissionChecker::class, Settings::class, Build.VERSION::class, Uri::class)
@PrepareForTest(ActivityCompat::class, ContextCompat::class, Settings::class, Build.VERSION::class, Uri::class)
class ActivityWithSystemAlertWindowKtAllAnnotationsTest {

private lateinit var activity: ActivityWithSystemAlertWindowKtAllAnnotations
Expand All @@ -39,7 +39,7 @@ class ActivityWithSystemAlertWindowKtAllAnnotationsTest {
fun setUp() {
activity = Mockito.mock(ActivityWithSystemAlertWindowKtAllAnnotations::class.java)
PowerMockito.mockStatic(ActivityCompat::class.java)
PowerMockito.mockStatic(PermissionChecker::class.java)
PowerMockito.mockStatic(ContextCompat::class.java)
PowerMockito.mockStatic(Settings::class.java)
PowerMockito.mockStatic(Uri::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.net.Uri
import android.os.Build
import android.provider.Settings
import androidx.core.app.ActivityCompat
import androidx.core.content.PermissionChecker
import androidx.core.content.ContextCompat
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
Expand All @@ -19,7 +19,7 @@ import org.powermock.modules.junit4.PowerMockRunner

@Suppress("IllegalIdentifier")
@RunWith(PowerMockRunner::class)
@PrepareForTest(ActivityCompat::class, PermissionChecker::class, Settings::class, Build.VERSION::class, Uri::class)
@PrepareForTest(ActivityCompat::class, ContextCompat::class, Settings::class, Build.VERSION::class, Uri::class)
class ActivityWithSystemAlertWindowKtTest {
private lateinit var activity: ActivityWithSystemAlertWindowKt

Expand All @@ -37,7 +37,7 @@ class ActivityWithSystemAlertWindowKtTest {
fun setUp() {
activity = Mockito.mock(ActivityWithSystemAlertWindowKt::class.java)
PowerMockito.mockStatic(ActivityCompat::class.java)
PowerMockito.mockStatic(PermissionChecker::class.java)
PowerMockito.mockStatic(ContextCompat::class.java)
PowerMockito.mockStatic(Settings::class.java)
PowerMockito.mockStatic(Uri::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.net.Uri
import android.os.Build
import android.provider.Settings
import androidx.core.app.ActivityCompat
import androidx.core.content.PermissionChecker
import androidx.core.content.ContextCompat
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
Expand All @@ -19,7 +19,7 @@ import org.powermock.modules.junit4.PowerMockRunner

@Suppress("IllegalIdentifier")
@RunWith(PowerMockRunner::class)
@PrepareForTest(ActivityCompat::class, PermissionChecker::class, Settings::class, Build.VERSION::class, Uri::class)
@PrepareForTest(ActivityCompat::class, ContextCompat::class, Settings::class, Build.VERSION::class, Uri::class)
class ActivityWithSystemAlertWindowPermissionsDispatcherTest {
private lateinit var activity: ActivityWithSystemAlertWindow

Expand All @@ -37,7 +37,7 @@ class ActivityWithSystemAlertWindowPermissionsDispatcherTest {
fun setUp() {
activity = Mockito.mock(ActivityWithSystemAlertWindow::class.java)
PowerMockito.mockStatic(ActivityCompat::class.java)
PowerMockito.mockStatic(PermissionChecker::class.java)
PowerMockito.mockStatic(ContextCompat::class.java)
PowerMockito.mockStatic(Settings::class.java)
PowerMockito.mockStatic(Uri::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.net.Uri
import android.os.Build
import android.provider.Settings
import androidx.core.app.ActivityCompat
import androidx.core.content.PermissionChecker
import androidx.core.content.ContextCompat
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
Expand All @@ -21,7 +21,7 @@ import permissions.dispatcher.test.ActivityWithWriteSettingAllAnnotationsPermiss

@Suppress("IllegalIdentifier")
@RunWith(PowerMockRunner::class)
@PrepareForTest(ActivityCompat::class, PermissionChecker::class, Settings::class, Build.VERSION::class, Uri::class)
@PrepareForTest(ActivityCompat::class, ContextCompat::class, Settings::class, Build.VERSION::class, Uri::class)
class ActivityWithWriteSettingAllAnnotationsPermissionsDispatcherTest {
private lateinit var activity: ActivityWithWriteSettingAllAnnotations

Expand All @@ -39,7 +39,7 @@ class ActivityWithWriteSettingAllAnnotationsPermissionsDispatcherTest {
fun setUp() {
activity = Mockito.mock(ActivityWithWriteSettingAllAnnotations::class.java)
PowerMockito.mockStatic(ActivityCompat::class.java)
PowerMockito.mockStatic(PermissionChecker::class.java)
PowerMockito.mockStatic(ContextCompat::class.java)
PowerMockito.mockStatic(Settings.System::class.java)
PowerMockito.mockStatic(Uri::class.java)

Expand Down
Loading