//--------------------------------------
        // Public Methods
        //--------------------------------------

        public void Run(AN_AndroidBuildRequirements buildRequirements)
        {
            if (IsSettingsEnabled)
            {
                AppendBuildRequirements(buildRequirements);
            }
        }
示例#2
0
        private static void ResolveInternalLibs(AN_AndroidBuildRequirements requirements)
        {
            List <string> libsToAdd    = new List <string>();
            List <string> libsToRemove = new List <string>();


            List <string> internalLibs = SA_AssetDatabase.FindAssetsWithExtentions(AN_Settings.ANDROID_INTERNAL_FOLDER);

            foreach (var lib in internalLibs)
            {
                string libName = SA_AssetDatabase.GetFileName(lib);
                if (!requirements.HasInternalLib(libName))
                {
                    libsToRemove.Add(libName);
                }
            }

            foreach (var lib in requirements.InternalLibs)
            {
                string libPath = AN_Settings.ANDROID_INTERNAL_FOLDER + lib;
                if (!SA_AssetDatabase.IsFileExists(libPath))
                {
                    libsToAdd.Add(lib);
                }
            }

            SA_PluginsEditor.UninstallLibs(AN_Settings.ANDROID_INTERNAL_FOLDER, libsToRemove);
            SA_PluginsEditor.InstallLibs(AN_Settings.ANDROID_INTERNAL_FOLDER_DISABLED, AN_Settings.ANDROID_INTERNAL_FOLDER, libsToAdd);
        }
        public override void AppendBuildRequirements(AN_AndroidBuildRequirements buildRequirements)
        {
            buildRequirements.AddPermission(AMM_ManifestPermission.READ_EXTERNAL_STORAGE);
            buildRequirements.AddPermission(AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE);

            buildRequirements.AddInternalLib("an_gallery.aar");

            /*
             *
             * buildRequirements.AddBinaryDependency(AN_BinaryDependency.SupportV4CoreUtils);
             * var provider = new AMM_PropertyTemplate("provider");
             * provider.SetValue("android:name", "android.support.v4.content.FileProvider");
             * provider.SetValue("android:authorities", "com.stansassets.android.fileprovider");
             * provider.SetValue("android:exported", "false");
             * provider.SetValue("android:grantUriPermissions", "true");
             *
             * var meta = new AMM_PropertyTemplate("meta-data");
             * meta.SetValue("android:name", "android.support.FILE_PROVIDER_PATHS");
             * meta.SetValue("android:resource", "@xml/file_paths");
             *
             * provider.AddProperty(meta);
             *
             *
             * buildRequirements.AddApplicationProperty(provider);*/
        }
示例#4
0
        public override void AppendBuildRequirements(AN_AndroidBuildRequirements buildRequirements)
        {
            var AlarmNotificationService = new AMM_PropertyTemplate("service");

            AlarmNotificationService.SetValue("android:name", "com.stansassets.android.app.notifications.AN_AlarmNotificationService");
            AlarmNotificationService.SetValue("android:process", ":externalProcess");
            buildRequirements.AddApplicationProperty(AlarmNotificationService);


            var LocalNotificationReceiver = new AMM_PropertyTemplate("receiver");

            LocalNotificationReceiver.SetValue("android:name", "com.stansassets.android.app.notifications.AN_AlarmNotificationTriggerReceiver");
            LocalNotificationReceiver.SetValue("android:enabled", "true");
            LocalNotificationReceiver.SetValue("android:exported", "true");

            var ReceiverIntentFilter = LocalNotificationReceiver.GetOrCreateIntentFilterWithName("com.androidnative.local.intent.OPEN");

            ReceiverIntentFilter.GetOrCreatePropertyWithName("action", "android.intent.action.BOOT_COMPLETED");
            ReceiverIntentFilter.GetOrCreatePropertyWithName("category", "android.intent.category.DEFAULT");
            buildRequirements.AddApplicationProperty(LocalNotificationReceiver);


            var notificationLaunchActivity = new AMM_ActivityTemplate(false, "com.stansassets.android.app.notifications.AN_NotificationLaunchActivity");

            notificationLaunchActivity.SetValue("android:launchMode", "singleTask");
            //  notificationLaunchActivity.SetValue("android:label", "@string/app_name");
            notificationLaunchActivity.SetValue("android:configChanges", "fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen");
            notificationLaunchActivity.SetValue("android:theme", "@android:style/Theme.Translucent.NoTitleBar");
            buildRequirements.AddActivity(notificationLaunchActivity);



            buildRequirements.AddPermission(AMM_ManifestPermission.WAKE_LOCK);
            buildRequirements.AddBinaryDependency(AN_BinaryDependency.AndroidX);
        }
        public override void AppendBuildRequirements(AN_AndroidBuildRequirements buildRequirements)
        {
            if (AN_Settings.Instance.PreferredImagesStorage != AN_Settings.StorageType.ForceInternal)
            {
                buildRequirements.AddPermission(AMM_ManifestPermission.READ_EXTERNAL_STORAGE);
                buildRequirements.AddPermission(AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE);
            }

            buildRequirements.AddInternalLib("an_gallery.aar");
        }
        public override void AppendBuildRequirements(AN_AndroidBuildRequirements buildRequirements)
        {
            if (AN_Settings.Instance.PreferredImagesStorage != AN_Settings.StorageType.ForceInternal)
            {
                buildRequirements.AddPermission(AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE);
                buildRequirements.AddPermission(AMM_ManifestPermission.READ_EXTERNAL_STORAGE);
            }

            buildRequirements.AddBinaryDependency(AN_BinaryDependency.SupportV4CoreUtils);
        }
示例#7
0
        private static void ResolveBinaryLibs(AN_AndroidBuildRequirements requirements)
        {
            if (AN_Settings.Instance.UseUnityJarResolver)
            {
                AN_Dependencies.Resolve(requirements.BinaryDependencies);
                SA_AssetDatabase.DeleteAsset(AN_Settings.ANDROID_MAVEN_FOLDER);
            }
            else
            {
                AN_Dependencies.Resolve(new List <AN_BinaryDependency>());


                List <string> repositorysToAdd    = new List <string>();
                List <string> repositorysToRemove = new List <string>();

                List <string> mavenLibs = SA_AssetDatabase.FindAssetsWithExtentions(AN_Settings.ANDROID_MAVEN_FOLDER);
                foreach (var lib in mavenLibs)
                {
                    //we are only interested in folder, we also assume all folders are located inside a root folder
                    if (!SA_AssetDatabase.IsValidFolder(lib))
                    {
                        continue;
                    }

                    string libName = SA_AssetDatabase.GetFileName(lib);
                    if (!requirements.HasBinaryDependency(libName))
                    {
                        repositorysToRemove.Add(libName);
                    }
                }

                foreach (var dep in requirements.BinaryDependencies)
                {
                    string libPath = AN_Settings.ANDROID_MAVEN_FOLDER + dep.GetLocalRepositoryName();
                    if (!SA_AssetDatabase.IsDirectoryExists(libPath))
                    {
                        string localRepositoryName = dep.GetLocalRepositoryName();
                        if (!repositorysToAdd.Contains(localRepositoryName))
                        {
                            repositorysToAdd.Add(localRepositoryName);
                        }
                    }
                }

                SA_PluginsEditor.UninstallLibs(AN_Settings.ANDROID_MAVEN_FOLDER, repositorysToRemove);

                foreach (var lib in repositorysToAdd)
                {
                    string source      = AN_Settings.ANDROID_MAVEN_FOLDER_DISABLED + lib;
                    string destination = AN_Settings.ANDROID_MAVEN_FOLDER + lib;
                    SA_PluginsEditor.InstallLibFolder(source, destination);
                }
            }
        }
示例#8
0
        //--------------------------------------
        // Requirements Resolver
        //--------------------------------------


        private static void Resolve(AN_AndroidBuildRequirements requirements)
        {
            if (AN_Settings.Instance.ManifestManagement)
            {
                ResolveManifest(requirements);
            }

            ResolveInternalLibs(requirements);

            ResolveBinaryLibs(requirements);
        }
        public override void AppendBuildRequirements(AN_AndroidBuildRequirements buildRequirements)
        {
            buildRequirements.AddBinaryDependency(AN_BinaryDependency.BillingClient);
            buildRequirements.AddPermission(AMM_ManifestPermission.BILLING);

            if (AN_Settings.Instance.Licensing)
            {
                buildRequirements.AddPermission(AMM_ManifestPermission.CHECK_LICENSE);
            }


            buildRequirements.AddInternalLib("an_vending.aar");
        }
        //--------------------------------------
        // Static
        //--------------------------------------

        public static void Resolve()
        {
            var versionUpdated = AN_Settings.UpdateVersion(AN_Settings.FormattedVersion) && !SA_PluginTools.IsDevelopmentMode;
            var requirements   = new AN_AndroidBuildRequirements();

            if (versionUpdated)
            {
                SA_AssetDatabase.DeleteAsset(AN_Settings.ANDROID_INTERNAL_FOLDER);
                SA_AssetDatabase.DeleteAsset(AN_Settings.ANDROID_MAVEN_FOLDER);
            }

            foreach (var resolver in Resolvers)
            {
                resolver.Run(requirements);
            }
            Resolve(requirements);
        }
示例#11
0
        public override void AppendBuildRequirements(AN_AndroidBuildRequirements buildRequirements)
        {
            buildRequirements.AddBinaryDependency(AN_BinaryDependency.PlayServicesAuth);
            buildRequirements.AddBinaryDependency(AN_BinaryDependency.AndroidX);
            buildRequirements.AddInternalLib("an_gms.aar");

            var games_APP_ID = new AMM_PropertyTemplate("meta-data");

            games_APP_ID.SetValue("android:name", "com.google.android.gms.games.APP_ID");
            games_APP_ID.SetValue("android:value", "@string/app_id");
            buildRequirements.AddApplicationProperty(games_APP_ID);


            if (AN_Settings.Instance.GooglePlayGamesAPI)
            {
                buildRequirements.AddBinaryDependency(AN_BinaryDependency.PlayServicesGames);
            }
        }
示例#12
0
        public override void AppendBuildRequirements(AN_AndroidBuildRequirements buildRequirements)
        {
            var proxyActivity = new AMM_ActivityTemplate(false, AN_BILLING_PROXY_ACTIVITY_CLASS);

            proxyActivity.SetValue("android:launchMode", "singleTask");
            proxyActivity.SetValue("android:label", "@string/app_name");
            proxyActivity.SetValue("android:configChanges", "fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen");
            proxyActivity.SetValue("android:theme", "@android:style/Theme.Translucent.NoTitleBar");

            buildRequirements.AddActivity(proxyActivity);
            buildRequirements.AddPermission(AMM_ManifestPermission.BILLING);

            if (AN_Settings.Instance.Licensing)
            {
                buildRequirements.AddPermission(AMM_ManifestPermission.CHECK_LICENSE);
            }


            buildRequirements.AddInternalLib("an_vending.aar");
        }
示例#13
0
 public override void AppendBuildRequirements(AN_AndroidBuildRequirements buildRequirements)
 {
     buildRequirements.AddPermission(AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE);
     buildRequirements.AddPermission(AMM_ManifestPermission.READ_EXTERNAL_STORAGE);
     buildRequirements.AddBinaryDependency(AN_BinaryDependency.SupportV4CoreUtils);
 }
 public override void AppendBuildRequirements(AN_AndroidBuildRequirements buildRequirements)
 {
 }
 public abstract void AppendBuildRequirements(AN_AndroidBuildRequirements buildRequirements);
示例#16
0
        public override void AppendBuildRequirements(AN_AndroidBuildRequirements buildRequirements)
        {
            //Always required

            var proxyActivity = new AMM_ActivityTemplate(false, "com.stansassets.core.utility.AN_ProxyActivity");

            proxyActivity.SetValue("android:launchMode", "singleTask");
            proxyActivity.SetValue("android:configChanges", "fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen");
            proxyActivity.SetValue("android:theme", "@android:style/Theme.Translucent.NoTitleBar");

            buildRequirements.AddActivity(proxyActivity);

            var usesSdk = new AMM_PropertyTemplate("uses-sdk");

            usesSdk.SetValue("android:minSdkVersion", "4");
            buildRequirements.AddMenifestProperty(usesSdk);



            var permissionsProxyActivity = new AMM_ActivityTemplate(false, "com.stansassets.android.app.permissions.AN_PermissionsProxyActivity");

            permissionsProxyActivity.SetValue("android:launchMode", "singleTask");
            permissionsProxyActivity.SetValue("android:configChanges", "fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen");
            permissionsProxyActivity.SetValue("android:theme", "@android:style/Theme.Translucent.NoTitleBar");
            buildRequirements.AddActivity(permissionsProxyActivity);


            buildRequirements.AddBinaryDependency(AN_BinaryDependency.GSON);



            buildRequirements.AddBinaryDependency(AN_BinaryDependency.SupportV4CoreUtils);
            var provider = new AMM_PropertyTemplate("provider");

            provider.SetValue("android:name", "android.support.v4.content.FileProvider");
            provider.SetValue("android:authorities", Application.identifier + ".fileprovider");
            provider.SetValue("android:exported", "false");
            provider.SetValue("android:grantUriPermissions", "true");

            var meta = new AMM_PropertyTemplate("meta-data");

            meta.SetValue("android:name", "android.support.FILE_PROVIDER_PATHS");
            meta.SetValue("android:resource", "@xml/file_paths");

            provider.AddProperty(meta);


            buildRequirements.AddApplicationProperty(provider);


            //Optional
            if (AN_Settings.Instance.SkipPermissionsDialog)
            {
                //it was removed, and starting from 2018.3 permission dialog will never be asked on start up
                //so no point to use SkipPermissionsDialog meta

#if !UNITY_2018_3_OR_NEWER
                var SkipPermissionsDialog = new AMM_PropertyTemplate("meta-data");
                SkipPermissionsDialog.SetValue("android:name", "unityplayer.SkipPermissionsDialog");
                SkipPermissionsDialog.SetValue("android:value", "true");
                buildRequirements.AddApplicationProperty(SkipPermissionsDialog);
#endif
            }

            if (AN_Settings.Instance.MediaPlayer)
            {
                var videoPlayerActivity = new AMM_ActivityTemplate(false, "com.stansassets.android.media.AN_VideoPlayerActivity");
                videoPlayerActivity.SetValue("android:launchMode", "singleTask");
                videoPlayerActivity.SetValue("android:configChanges", "orientation|screenSize");
                videoPlayerActivity.SetValue("android:theme", "@android:style/Theme.NoTitleBar.Fullscreen");

                buildRequirements.AddActivity(videoPlayerActivity);
            }
        }
        public static void DrawRequirementsUI(AN_AndroidBuildRequirements buildRequirements)
        {
            if (buildRequirements.Activities.Count > 0)
            {
                using (new SA_H2WindowBlockWithSpace(new GUIContent("ACTIVITIES"))) {
                    foreach (var activity in buildRequirements.Activities)
                    {
                        string name = SA_PathUtil.GetExtension(activity.Name);
                        name = name.Substring(1, name.Length - 1);
                        var icon = AN_Skin.GetIcon("requirements_activity.png");
                        SA_EditorGUILayout.SelectableLabel(new GUIContent("activity: " + name, icon));
                    }
                }
            }


            if (buildRequirements.ApplicationProperties.Count > 0)
            {
                using (new SA_H2WindowBlockWithSpace(new GUIContent("APP PROPERTIES"))) {
                    foreach (var property in buildRequirements.ApplicationProperties)
                    {
                        var    icon = AN_Skin.GetIcon("requirements_activity.png");
                        string name = SA_PathUtil.GetExtension(property.Name);
                        name = name.Substring(1, name.Length - 1);

                        SA_EditorGUILayout.SelectableLabel(new GUIContent(property.Tag + ": " + name, icon));
                    }
                }
            }

            if (buildRequirements.ManifestProperties.Count > 0)
            {
                using (new SA_H2WindowBlockWithSpace(new GUIContent("MANIFEST PROPERTIES"))) {
                    foreach (var property in buildRequirements.ManifestProperties)
                    {
                        var icon = AN_Skin.GetIcon("requirements_activity.png");

                        string info = string.Empty;
                        foreach (var pair in property.Values)
                        {
                            info += " " + pair.Key + " : " + pair.Value;
                        }

                        SA_EditorGUILayout.SelectableLabel(new GUIContent(property.Tag + info, icon));
                    }
                }
            }


            if (buildRequirements.Permissions.Count > 0)
            {
                using (new SA_H2WindowBlockWithSpace(new GUIContent("PERMISSIONS"))) {
                    foreach (var permission in buildRequirements.Permissions)
                    {
                        var icon = AN_Skin.GetIcon("requirements_permission.png");
                        SA_EditorGUILayout.SelectableLabel(new GUIContent(permission.GetFullName(), icon));
                    }
                }
            }

            if (buildRequirements.BinaryDependencies.Count > 0)
            {
                using (new SA_H2WindowBlockWithSpace(new GUIContent("BINARY DEPENDENCIES"))) {
                    foreach (var dependency in buildRequirements.BinaryDependencies)
                    {
                        var icon = AN_Skin.GetIcon("requirements_lib.png");
                        SA_EditorGUILayout.SelectableLabel(new GUIContent(dependency.GetRemoteRepositoryName(), icon));
                    }
                }
            }
        }
示例#18
0
 public override void AppendBuildRequirements(AN_AndroidBuildRequirements buildRequirements)
 {
     buildRequirements.AddPermission(AMM_ManifestPermission.READ_CONTACTS);
 }
示例#19
0
        private static void ResolveManifest(AN_AndroidBuildRequirements requirements)
        {
            var androidManifest = new AMM_AndroidManifest(AN_Settings.ANDROID_MANIFEST_FILE_PATH);

            var manifest    = androidManifest.Template;
            var application = manifest.ApplicationTemplate;

            //Removing not used activities
            List <AMM_ActivityTemplate> unusedActivities = new List <AMM_ActivityTemplate>();

            foreach (var pair in application.Activities)
            {
                var act = pair.Value;
                if (!requirements.HasActivityWithName(act.Name))
                {
                    unusedActivities.Add(act);
                }
            }


            foreach (var act in unusedActivities)
            {
                application.RemoveActivity(act);
            }


            //Add required activities
            foreach (var activity in requirements.Activities)
            {
                var act = application.GetOrCreateActivityWithName(activity.Name);
                foreach (var pair in activity.Values)
                {
                    act.SetValue(pair.Key, pair.Value);
                }
            }

            //application properties
            ResolveProperties(manifest, requirements.ManifestProperties);
            ResolveProperties(application, requirements.ApplicationProperties);


            //Removing not used permissions
            List <string> unusedPermissions = new List <string>();

            foreach (var perm in manifest.Permissions)
            {
                if (!requirements.HasPermissionWithName(perm.Name))
                {
                    unusedPermissions.Add(perm.Name);
                }
            }

            foreach (var perm in unusedPermissions)
            {
                manifest.RemovePermission(perm);
            }

            //Add required permission
            foreach (var permission in requirements.Permissions)
            {
                manifest.AddPermission(permission);
                // tpl.SetValue("tools:remove", "android:maxSdkVersion");
            }

            //TODO only save if there is chnaged to save
            androidManifest.SaveManifest();
        }