@@ -129,22 +129,32 @@ private static void RunPostProcessTasksAndroid()
129
129
// Let's open the app's AndroidManifest.xml file.
130
130
XmlDocument manifestFile = new XmlDocument ( ) ;
131
131
manifestFile . Load ( appManifestPath ) ;
132
+
133
+ bool manifestHasChanged = false ;
132
134
133
135
// Add needed permissions if they are missing.
134
- AddPermissions ( manifestFile ) ;
136
+ manifestHasChanged |= AddPermissions ( manifestFile ) ;
135
137
136
- // Save the changes.
137
- manifestFile . Save ( appManifestPath ) ;
138
+ if ( manifestHasChanged )
139
+ {
140
+ // Save the changes.
141
+ manifestFile . Save ( appManifestPath ) ;
138
142
139
- // Clean the manifest file.
140
- CleanManifestFile ( appManifestPath ) ;
143
+ // Clean the manifest file.
144
+ CleanManifestFile ( appManifestPath ) ;
141
145
142
- UnityEngine . Debug . Log ( "[AdjustImei]: App's AndroidManifest.xml file check and potential modification completed." ) ;
143
- UnityEngine . Debug . Log ( "[AdjustImei]: Please check if any error message was displayed during this process "
144
- + "and make sure to fix all issues in order to properly use the Adjust IMEI plugin in your app." ) ;
146
+ UnityEngine . Debug . Log ( "[AdjustImei]: App's AndroidManifest.xml file check and potential modification completed." ) ;
147
+ UnityEngine . Debug . Log ( "[AdjustImei]: Please check if any error message was displayed during this process "
148
+ + "and make sure to fix all issues in order to properly use the Adjust IMEI plugin in your app." ) ;
149
+ }
150
+ else
151
+ {
152
+ UnityEngine . Debug . Log ( "[AdjustImei]: App's AndroidManifest.xml file check completed." ) ;
153
+ UnityEngine . Debug . Log ( "[AdjustImei]: No modifications performed due to app's AndroidManifest.xml file compatibility." ) ;
154
+ }
145
155
}
146
156
147
- private static void AddPermissions ( XmlDocument manifest )
157
+ private static bool AddPermissions ( XmlDocument manifest )
148
158
{
149
159
// The Adjust IMEI plugin needs following permissions to be added to you app's manifest file:
150
160
// <uses-permission android:name="android.permission.READ_PHONE_STATE" />
@@ -169,19 +179,24 @@ private static void AddPermissions(XmlDocument manifest)
169
179
}
170
180
}
171
181
182
+ bool manifestHasChanged = false ;
183
+
172
184
// If android.permission.READ_PHONE_STATE permission is missing, add it.
173
185
if ( ! hasReadPhoneStatePermission )
174
186
{
175
187
XmlElement element = manifest . CreateElement ( "uses-permission" ) ;
176
188
element . SetAttribute ( "android__name" , "android.permission.READ_PHONE_STATE" ) ;
177
189
manifestRoot . AppendChild ( element ) ;
178
190
UnityEngine . Debug . Log ( "[AdjustImei]: android.permission.READ_PHONE_STATE permission successfully added to your app's AndroidManifest.xml file." ) ;
191
+ manifestHasChanged = true ;
179
192
}
180
193
else
181
194
{
182
195
UnityEngine . Debug . Log ( "[AdjustImei]: Your app's AndroidManifest.xml file already contains android.permission.READ_PHONE_STATE permission." ) ;
183
196
UnityEngine . Debug . Log ( "[AdjustImei]: All good." ) ;
184
197
}
198
+
199
+ return manifestHasChanged ;
185
200
}
186
201
187
202
private static void CleanManifestFile ( String manifestPath )
0 commit comments