-
Notifications
You must be signed in to change notification settings - Fork 533
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
[Xamarin.Android.Build.Tasks] emit exported="true" for MainLauncher activities #6212
[Xamarin.Android.Build.Tasks] emit exported="true" for MainLauncher activities #6212
Conversation
@jonathanpeppers wrote:
I don't think this is correct. There is no What you should be emitting is the Thus, you should be emitting: <activity android:exported="true" android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> This also matches the blog post you linked to:
|
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs
Outdated
Show resolved
Hide resolved
…ctivities Context: https://aster.cloud/2021/02/23/lets-be-explicit-about-our-intent-filters/ Fixes: dotnet#6196 > An important change is coming to Android 12 that improves both app > and platform security. This change affects all apps that target > Android 12. > > Activities, services, and broadcast receivers with declared > intent-filters now must explicitly declare whether they should be > exported or not. For example: <activity android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Should become: <activity android:exported="true" android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Update our `AndroidManifest.xml` generation & related code so that when `MainLauncher=true`, we also automatically set `exported=true`. I updated a test to verify the contents of the generated `AndroidManifest.xml`.
af31dc2
to
72f28b9
Compare
<activity android:exported="true" android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> Thanks, I don't know how I got confused about the wrong element before. Now I get: <activity android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="Library Activity" android:name="mono.samples.hello.LibraryActivity" /> |
@@ -798,6 +798,7 @@ void AddLauncherIntentElements (XElement activity) | |||
return; | |||
|
|||
var filter = new XElement ("intent-filter"); | |||
activity.Add (new XAttribute (androidNs + "exported", "true")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to add this for all Android versions or should we only be doing it for Android 12 + ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not appear that //activity/@android:exported
attribute has a minimum API level. Since this is a security feature, we're probably good to set this across the board?
Usually the way new attributes work in AndroidManifest.xml
, is that older Android versions just ignore the values they don't know about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh okay awesome then ! thank you
…6212) Fixes: #6196 Context: https://aster.cloud/2021/02/23/lets-be-explicit-about-our-intent-filters/ > An important change is coming to Android 12 that improves both app > and platform security. This change affects all apps that target > Android 12. > > Activities, services, and broadcast receivers with declared > intent-filters now must explicitly declare whether they should be > exported or not. For example: <activity android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Should become: <activity android:exported="true" android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Update our `AndroidManifest.xml` generation & related code so that when `MainLauncher=true`, we also automatically set `exported=true`. I updated a test to verify the contents of the generated `AndroidManifest.xml`.
…otnet#6212) Fixes: dotnet#6196 Context: https://aster.cloud/2021/02/23/lets-be-explicit-about-our-intent-filters/ > An important change is coming to Android 12 that improves both app > and platform security. This change affects all apps that target > Android 12. > > Activities, services, and broadcast receivers with declared > intent-filters now must explicitly declare whether they should be > exported or not. For example: <activity android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Should become: <activity android:exported="true" android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Update our `AndroidManifest.xml` generation & related code so that when `MainLauncher=true`, we also automatically set `exported=true`. I updated a test to verify the contents of the generated `AndroidManifest.xml`.
…6212) Fixes: #6196 Context: https://aster.cloud/2021/02/23/lets-be-explicit-about-our-intent-filters/ > An important change is coming to Android 12 that improves both app > and platform security. This change affects all apps that target > Android 12. > > Activities, services, and broadcast receivers with declared > intent-filters now must explicitly declare whether they should be > exported or not. For example: <activity android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Should become: <activity android:exported="true" android:icon="@mipmap/icon" android:label="HelloWorld" android:name="example.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> Update our `AndroidManifest.xml` generation & related code so that when `MainLauncher=true`, we also automatically set `exported=true`. I updated a test to verify the contents of the generated `AndroidManifest.xml`.
Context: https://aster.cloud/2021/02/23/lets-be-explicit-about-our-intent-filters/
Fixes: #6196
For example:
Should become:
Update our
AndroidManifest.xml
generation & related code so thatwhen
MainLauncher=true
, we also automatically setexported=true
.I updated a test to verify the contents of the generated
AndroidManifest.xml
.