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

upgrade to target sdk 34: mark OngoingNotificationsService as Use, register receivers as exported #2761

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/keepass2android-app/EntryActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,9 @@ protected override void OnCreate(Bundle savedInstanceState)
App.Kp2a.LastOpenedEntry = new PwEntryOutput(Entry, App.Kp2a.CurrentDb);

_pluginActionReceiver = new PluginActionReceiver(this);
RegisterReceiver(_pluginActionReceiver, new IntentFilter(Strings.ActionAddEntryAction));
RegisterReceiver(_pluginActionReceiver, new IntentFilter(Strings.ActionAddEntryAction), ReceiverFlags.Exported);
_pluginFieldReceiver = new PluginFieldReceiver(this);
RegisterReceiver(_pluginFieldReceiver, new IntentFilter(Strings.ActionSetEntryField));
RegisterReceiver(_pluginFieldReceiver, new IntentFilter(Strings.ActionSetEntryField), ReceiverFlags.Exported);

var notifyPluginsOnOpenThread = new Thread(NotifyPluginsOnOpen);
notifyPluginsOnOpenThread.Start();
Expand Down
2 changes: 1 addition & 1 deletion src/keepass2android-app/LockCloseActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected override void OnCreate(Bundle savedInstanceState)
IntentFilter filter = new IntentFilter();
filter.AddAction(Intents.DatabaseLocked);
filter.AddAction(Intent.ActionScreenOff);
RegisterReceiver(_intentReceiver, filter);
RegisterReceiver(_intentReceiver, filter, ReceiverFlags.Exported);
}

protected override void OnDestroy()
Expand Down
2 changes: 1 addition & 1 deletion src/keepass2android-app/LockCloseListActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected override void OnCreate(Bundle savedInstanceState)

filter.AddAction(Intents.DatabaseLocked);
filter.AddAction(Intent.ActionScreenOff);
RegisterReceiver(_intentReceiver, filter);
RegisterReceiver(_intentReceiver, filter, ReceiverFlags.Exported);

}

Expand Down
2 changes: 1 addition & 1 deletion src/keepass2android-app/LockingClosePreferenceActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected override void OnCreate(Bundle savedInstanceState)
_intentReceiver = new LockCloseActivityBroadcastReceiver(this);
IntentFilter filter = new IntentFilter();
filter.AddAction(Intents.DatabaseLocked);
RegisterReceiver(_intentReceiver, filter);
RegisterReceiver(_intentReceiver, filter, ReceiverFlags.Exported);
}

protected override void OnResume() {
Expand Down
3 changes: 2 additions & 1 deletion src/keepass2android-app/Manifests/AndroidManifest_debug.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</queries>


<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34" />
<permission android:description="@string/permission_desc2" android:icon="@drawable/ic_notify_locked" android:label="KP2A entry search" android:name="keepass2android.keepass2android_debug.permission.KP2aInternalSearch" android:protectionLevel="signature" />
<permission android:description="@string/permission_desc3" android:icon="@drawable/ic_launcher" android:label="KP2A choose autofill dataset" android:name="keepass2android.keepass2android_debug.permission.Kp2aChooseAutofill" android:protectionLevel="signature" />
<application
Expand Down Expand Up @@ -256,6 +256,7 @@ The scheme=file is still there for old OS devices. It's also queried by apps lik
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" android:maxSdkVersion="22" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" android:maxSdkVersion="22" />
<uses-permission android:name="keepass2android.keepass2android_debug.permission.KP2aInternalFileBrowsing" />
Expand Down
3 changes: 2 additions & 1 deletion src/keepass2android-app/Manifests/AndroidManifest_net.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<action android:name="android.intent.action.VIEW" />
</intent>
</queries>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34" />

<permission android:description="@string/permission_desc2" android:icon="@drawable/ic_launcher" android:label="KP2A entry search" android:name="keepass2android.keepass2android.permission.KP2aInternalSearch" android:protectionLevel="signature" />
<permission android:description="@string/permission_desc3" android:icon="@drawable/ic_launcher" android:label="KP2A choose autofill dataset" android:name="keepass2android.keepass2android.permission.Kp2aChooseAutofill" android:protectionLevel="signature" />
Expand Down Expand Up @@ -270,6 +270,7 @@ The scheme=file is still there for old OS devices. It's also queried by apps lik
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" android:maxSdkVersion="22" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" android:maxSdkVersion="22" />
<uses-permission android:name="keepass2android.keepass2android.permission.KP2aInternalFileBrowsing" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</intent>
</queries>

<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34" />
<permission android:description="@string/permission_desc2" android:icon="@drawable/ic_launcher_offline" android:label="KP2A entry search" android:name="keepass2android.keepass2android_nonet.permission.KP2aInternalSearch" android:protectionLevel="signature" />
<permission android:description="@string/permission_desc3" android:icon="@drawable/ic_launcher_offline" android:label="KP2A choose autofill dataset" android:name="keepass2android.keepass2android_nonet.permission.Kp2aChooseAutofill" android:protectionLevel="signature" />
<application
Expand Down
2 changes: 1 addition & 1 deletion src/keepass2android-app/PasswordActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ protected override void OnCreate(Bundle savedInstanceState)
_intentReceiver = new PasswordActivityBroadcastReceiver(this);
IntentFilter filter = new IntentFilter();
filter.AddAction(Intent.ActionScreenOff);
RegisterReceiver(_intentReceiver, filter);
RegisterReceiver(_intentReceiver, filter, ReceiverFlags.Exported);


//use FlagSecure to make sure the last (revealed) character of the master password is not visible in recent apps
Expand Down
4 changes: 1 addition & 3 deletions src/keepass2android-app/QuickUnlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected override void OnCreate(Bundle bundle)
_intentReceiver = new QuickUnlockBroadcastReceiver(this);
IntentFilter filter = new IntentFilter();
filter.AddAction(Intents.DatabaseLocked);
RegisterReceiver(_intentReceiver, filter);
RegisterReceiver(_intentReceiver, filter, ReceiverFlags.Exported);

Util.SetNoPersonalizedLearning(FindViewById<EditText>(Resource.Id.QuickUnlock_password));

Expand Down Expand Up @@ -503,8 +503,6 @@ public override void OnReceive(Context context, Intent intent)
}
}
}


}
}

2 changes: 1 addition & 1 deletion src/keepass2android-app/SelectCurrentDbActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ protected override void OnStart()
IntentFilter filter = new IntentFilter();
filter.AddAction(Intents.DatabaseLocked);
filter.AddAction(Intent.ActionScreenOff);
RegisterReceiver(_intentReceiver, filter);
RegisterReceiver(_intentReceiver, filter, ReceiverFlags.Exported);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/keepass2android-app/app/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ public override void OnCreate()
intentFilter.AddAction(Intents.LockDatabase);
intentFilter.AddAction(Intents.LockDatabaseByTimeout);
intentFilter.AddAction(Intents.CloseDatabase);
Context.RegisterReceiver(broadcastReceiver, intentFilter);
Context.RegisterReceiver(broadcastReceiver, intentFilter, ReceiverFlags.Exported);

//ZXing.Net.Mobile.Forms.Android.Platform.Init();
}
Expand Down
4 changes: 2 additions & 2 deletions src/keepass2android-app/services/CopyToClipboardService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public override StartCommandResult OnStartCommand(Intent intent, StartCommandFla
_stopOnLockBroadcastReceiver = new StopOnLockBroadcastReceiver(this);
IntentFilter filter = new IntentFilter();
filter.AddAction(Intents.DatabaseLocked);
RegisterReceiver(_stopOnLockBroadcastReceiver, filter);
RegisterReceiver(_stopOnLockBroadcastReceiver, filter, ReceiverFlags.Exported);
}

if ((intent.Action == Intents.ShowNotification) || (intent.Action == Intents.UpdateKeyboard))
Expand Down Expand Up @@ -529,7 +529,7 @@ public void DisplayAccessNotifications(PwEntryOutput entry, bool activateKeyboar
_notificationDeletedBroadcastReceiver = new NotificationDeletedBroadcastReceiver(this);
IntentFilter deletefilter = new IntentFilter();
deletefilter.AddAction(ActionNotificationCancelled);
RegisterReceiver(_notificationDeletedBroadcastReceiver, deletefilter);
RegisterReceiver(_notificationDeletedBroadcastReceiver, deletefilter, ReceiverFlags.Exported);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
using System;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Graphics;
using Android.OS;
using Android.Preferences;
Expand All @@ -37,7 +38,9 @@ namespace keepass2android
/// used by the user. This ensures the database is kept in memory (until Android kills it due to low memory).
/// It is important to also have a foreground service also for the "unlocked" state because it's really
/// irritating if the db is closed while switching between apps.
[Service]
[Service(ForegroundServiceType = ForegroundService.TypeSpecialUse )]
[MetaData("android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE", Value = " This service is running as foreground service to keep the app alive even when it's not currently used by the user. This ensures the database is kept in memory (until Android kills it due to low memory). It is important to also have a foreground service also for the \"unlocked\" state because it's really irritating if the db is closed while switching between apps.")]

public class OngoingNotificationsService : Service
{
protected override void AttachBaseContext(Context baseContext)
Expand All @@ -57,7 +60,7 @@ public override void OnCreate()
_screenOffReceiver = new ScreenOffReceiver();
IntentFilter filter = new IntentFilter();
filter.AddAction(Intent.ActionScreenOff);
RegisterReceiver(_screenOffReceiver, filter);
RegisterReceiver(_screenOffReceiver, filter, ReceiverFlags.Exported);
}


Expand Down
Loading