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

Migrate from IPostGenerateGradleAndroidProject->AndroidProjectFilesModifier #301

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

todi1856
Copy link
Member

@todi1856 todi1856 commented Dec 5, 2023

No description provided.

}
public class AndroidNotificationPostProcessor : AndroidProjectFilesModifier
{
private static readonly string NotificationProguardPath = "unityLibrary/proguard-unity-notifications.txt";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not we're creating new proguard for notifications, since we don't allow updating existing proguard-unity, since it's not incremental friendly way

var receiverkNotificationManager = new Receiver();
receiverkNotificationManager.Attributes.Name.Set("com.unity.androidnotifications.UnityNotificationManager");
receiverkNotificationManager.Attributes.Exported.Set(false);
manifest.Application.ReceiverList.AddElement(receiverkNotificationManager);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rytis can you comment on this one, is it's correct way to add receiver element ?

I was hoping for manifest.Application.ReceiverList.AddReceiver/Add(string name)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is correct. If you'd add a helper API, it should be added to the Application: manifest.Application.AddReceiver(). One concern would be that Receiver has a lot of fields. Do you think Name and Exported fields would be the most commonly used? Otherwise I don't think the helper method is very helpful

if ((settings.ExactAlarm & AndroidExactSchedulingOption.AddRequestIgnoreBatteryOptimizationsPermission) != 0)
{
// TODO: Missing AddUsesPermissionSdk23 function
var batterOptimizations = manifest.AddUsesPermission("android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rytis-buz would it makese sense to have AddUsesPermissionSdk23 function?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

{
// TODO: PropertyStringArray missing Add function?
var original = new List<string>(projectFiles.UnityLibraryBuildGradle.Android.DefaultConfig.ConsumerProguardFiles.Get());
original.Add(Path.GetFileName(NotificationProguardPath));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rytis-buz would it make sense to have projectFiles.UnityLibraryBuildGradle.Android.DefaultConfig.ConsumerProguardFiles.Add(string value) to append to array?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it can be added

var receiverkNotificationManager = new Receiver();
receiverkNotificationManager.Attributes.Name.Set("com.unity.androidnotifications.UnityNotificationManager");
receiverkNotificationManager.Attributes.Exported.Set(false);
manifest.Application.ReceiverList.AddElement(receiverkNotificationManager);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is correct. If you'd add a helper API, it should be added to the Application: manifest.Application.AddReceiver(). One concern would be that Receiver has a lot of fields. Do you think Name and Exported fields would be the most commonly used? Otherwise I don't think the helper method is very helpful

if ((settings.ExactAlarm & AndroidExactSchedulingOption.AddRequestIgnoreBatteryOptimizationsPermission) != 0)
{
// TODO: Missing AddUsesPermissionSdk23 function
var batterOptimizations = manifest.AddUsesPermission("android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

{
// TODO: PropertyStringArray missing Add function?
var original = new List<string>(projectFiles.UnityLibraryBuildGradle.Android.DefaultConfig.ConsumerProguardFiles.Get());
original.Add(Path.GetFileName(NotificationProguardPath));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it can be added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants