public static string GetFullName(this AMM_ManifestPermission permission)
        {
            string prefix = "android.permission.";

            switch (permission)
            {
            case AMM_ManifestPermission.SET_ALARM:
                prefix = "com.android.alarm.permission.";
                break;

            case AMM_ManifestPermission.INSTALL_SHORTCUT:
            case AMM_ManifestPermission.UNINSTALL_SHORTCUT:
                prefix = "com.android.launcher.permission.";
                break;

            case AMM_ManifestPermission.ADD_VOICEMAIL:
                prefix = "com.android.voicemail.permission.";
                break;

            case AMM_ManifestPermission.BILLING:
            case AMM_ManifestPermission.CHECK_LICENSE:
                prefix = "com.android.vending.";
                break;
            }

            return(prefix + permission.ToString());
        }
        //--------------------------------------
        // Public Methods
        //--------------------------------------

        /// <summary>
        /// Determine whether you have been granted a particular permission.
        /// </summary>
        /// <param name="permission">The name of the permission being checked.</param>
        public static AN_PackageManager.PermissionState CheckSelfPermission(AMM_ManifestPermission permission)
        {
            if (Application.isEditor || AN_Build.VERSION.SDK_INT < AN_Build.VERSION_CODES.M)
            {
                return(AN_PackageManager.PermissionState.Granted);
            }

            var val = AN_Java.Bridge.CallStatic <int>(ANDROID_CLASS, "CheckSelfPermission", permission.GetFullName());

            return((AN_PackageManager.PermissionState)val);
        }
        /// <summary>
        /// Gets whether you should show UI with rationale for requesting a permission.
        /// You should do this only if you do not have the permission and the context
        /// in which the permission is requested does not clearly communicate to the user what would be the benefit from granting this permission.
        ///
        /// For example, if you write a camera app,
        /// requesting the camera permission would be expected by the user and no rationale for why it is requested is needed.
        /// If however, the app needs location for tagging photos then a non-tech savvy user may wonder how location is related to taking photos.
        /// In this case you may choose to show UI with rationale of requesting this permission.
        /// </summary>
        /// <param name="permission">A permission your app wants to request.</param>
        public static bool ShouldShowRequestPermissionRationale(AMM_ManifestPermission permission)
        {
            if (Application.isEditor)
            {
                return(true);
            }

            if (AN_Build.VERSION.SDK_INT < AN_Build.VERSION_CODES.M)
            {
                return(false);
            }

            return(AN_Java.Bridge.CallStatic <bool>(ANDROID_CLASS, "ShouldShowRequestPermissionRationale", permission.GetFullName()));
        }
        public static bool IsNormalPermission(this AMM_ManifestPermission permission)
        {
            switch (permission)
            {
            case AMM_ManifestPermission.ACCESS_LOCATION_EXTRA_COMMANDS:
            case AMM_ManifestPermission.ACCESS_NETWORK_STATE:
            case AMM_ManifestPermission.ACCESS_NOTIFICATION_POLICY:
            case AMM_ManifestPermission.ACCESS_WIFI_STATE:
            case AMM_ManifestPermission.ACCESS_WIMAX_STATE:
            case AMM_ManifestPermission.BLUETOOTH:
            case AMM_ManifestPermission.BLUETOOTH_ADMIN:
            case AMM_ManifestPermission.BROADCAST_STICKY:
            case AMM_ManifestPermission.CHANGE_NETWORK_STATE:
            case AMM_ManifestPermission.CHANGE_WIFI_MULTICAST_STATE:
            case AMM_ManifestPermission.CHANGE_WIFI_STATE:
            case AMM_ManifestPermission.CHANGE_WIMAX_STATE:
            case AMM_ManifestPermission.DISABLE_KEYGUARD:
            case AMM_ManifestPermission.EXPAND_STATUS_BAR:
            case AMM_ManifestPermission.FLASHLIGHT:
            case AMM_ManifestPermission.GET_PACKAGE_SIZE:
            case AMM_ManifestPermission.INTERNET:
            case AMM_ManifestPermission.KILL_BACKGROUND_PROCESSES:
            case AMM_ManifestPermission.MODIFY_AUDIO_SETTINGS:
            case AMM_ManifestPermission.NFC:
            case AMM_ManifestPermission.READ_SYNC_SETTINGS:
            case AMM_ManifestPermission.READ_SYNC_STATS:
            case AMM_ManifestPermission.RECEIVE_BOOT_COMPLETED:
            case AMM_ManifestPermission.REORDER_TASKS:
            case AMM_ManifestPermission.REQUEST_INSTALL_PACKAGES:
            case AMM_ManifestPermission.SET_TIME_ZONE:
            case AMM_ManifestPermission.SET_WALLPAPER:
            case AMM_ManifestPermission.SET_WALLPAPER_HINTS:
            case AMM_ManifestPermission.SUBSCRIBED_FEEDS_READ:
            case AMM_ManifestPermission.TRANSMIT_IR:
            case AMM_ManifestPermission.USE_FINGERPRINT:
            case AMM_ManifestPermission.VIBRATE:
            case AMM_ManifestPermission.WAKE_LOCK:
            case AMM_ManifestPermission.WRITE_SYNC_SETTINGS:
            case AMM_ManifestPermission.SET_ALARM:
            case AMM_ManifestPermission.INSTALL_SHORTCUT:
            case AMM_ManifestPermission.UNINSTALL_SHORTCUT:
                return(true);

            default:
                return(false);
            }
        }
示例#5
0
 /// <summary>
 /// Tries to resolve specified permission.
 /// </summary>
 /// <param name="permission">Android permission.</param>
 /// <param name="callback">Flow callback with resolution result.</param>
 public static void TryToResolvePermission(AMM_ManifestPermission permission, Action <bool> callback)
 {
     TryToResolvePermission(new[] { permission }, callback);
 }
示例#6
0
 public void AddPermission(AMM_ManifestPermission permission)
 {
     m_permissions.Add(permission);
 }
示例#7
0
 public AMM_PropertyTemplate AddPermission(AMM_ManifestPermission permission)
 {
     return(AddPermission(permission.GetFullName()));
 }
示例#8
0
 public void RemovePermission(AMM_ManifestPermission permission)
 {
     RemovePermission(permission.GetFullName());
 }
 public AN_PermissionsRequestResponce(AMM_ManifestPermission permission, AN_PackageManager.PermissionState state)
 {
     m_permission  = permission.GetFullName();
     m_grantResult = (int)state;
 }
 /// <summary>
 /// Requests permissions to be granted to this application.
 /// These permissions must be requested in your manifest, they should not be granted to your app,
 /// and they should have protection level #PROTECTION_DANGEROUS dangerous, regardless whether they are declared by the platform or a third-party app.
 ///
 /// Requests permissions to be granted to this application.
 /// These permissions must be requested in your manifest, they should not be granted to your app,
 /// and they should have protection level #PROTECTION_DANGEROUS dangerous,
 /// regardless whether they are declared by the platform or a third-party app.
 ///
 /// If your app does not have the requested permissions the user will be presented with UI for accepting them.
 /// After the user has accepted or rejected the requested permissions you will receive a callback reporting whether the permissions were granted or not.
 ///
 /// Note that requesting a permission does not guarantee it will be granted and your app should be able to run without having this permission.
 /// </summary>
 /// <param name="permission">The requested permission. Must me non-null and not empty.</param>
 /// <param name="callback">Results of permission requests will be delivered vai this callback </param>
 public static void RequestPermission(AMM_ManifestPermission permission, Action <AN_PermissionsRequestResult> callback)
 {
     RequestPermissions(new[] { permission }, callback);
 }