<commit_before>/*
 * Copyright (C) 2015 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.canelmas.let;

import android.content.pm.PackageManager;
import android.os.Build;
import android.support.v4.app.ActivityCompat;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by can on 31/08/15.
 */
@Aspect
public final class LetAspect {

    private LetAspect() {
    }

    @Around("execution(@com.canelmas.let.AskPermission * *(..)) && this(source)")
    public Object adviceForAskPermissionAnnotatedMethods(final ProceedingJoinPoint joinPoint, Object source) throws Throwable {

        //  proceed as it is for devices running prior to M
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
            return joinPoint.proceed();
        }

        return new RuntimePermissionRequest(joinPoint, source).proceed();

    }

    /**
     *
     * This advice is needed for distinguishing the 'Never Ask Again' and 'Thank you, but not now!'
     * states.
     *
     * State is 'Never Ask Agan' only if permission requests after an initial one, keep getting
     * denied and shouldShowRequestPermissionRationale returns false.
     *
     * @param joinPoint
     * @param source
     * @throws Throwable
     */
    @Around("execution(* *.onRequestPermissionsResult(..)) && this(source)")
    public void adviceForOnRequestPermissionsResult(final ProceedingJoinPoint joinPoint, Object source) throws Throwable {
<commit_msg>update onRequestPermissionsResult pointcut signature<commit_after>/*
 * Copyright (C) 2015 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.canelmas.let;

import android.content.pm.PackageManager;
import android.os.Build;
import android.support.v4.app.ActivityCompat;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by can on 31/08/15.
 */
@Aspect
public final class LetAspect {

    private LetAspect() {
    }

    @Around("execution(@com.canelmas.let.AskPermission * *(..)) && this(source)")
    public Object adviceForAskPermissionAnnotatedMethods(final ProceedingJoinPoint joinPoint, Object source) throws Throwable {

        //  proceed as it is for devices running prior to M
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
            return joinPoint.proceed();
        }

        return new RuntimePermissionRequest(joinPoint, source).proceed();

    }

    /**
     *
     * This advice is needed for distinguishing the 'Never Ask Again' and 'Thank you, but not now!'
     * states.
     *
     * State is 'Never Ask Agan' only if permission requests after an initial one, keep getting
     * denied and shouldShowRequestPermissionRationale returns false.
     *
     * int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults
     *
     * @param joinPoint
     * @param source
     * @throws Throwable
     */
    @Around("execution(void *.onRequestPermissionsResult(int, String[], int[])) && this(source)")
    public void adviceForOnRequestPermissionsResult(final ProceedingJoinPoint joinPoint, Object source) throws Throwable {

{'fraction_non_alphanumeric': 0.09304983996342021, 'fraction_numerical': 0.006858710562414266, 'mean_word_length': 3.547817047817048, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1788713', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1187, 'n_words': 409}