Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d3e4d5b authored by Myles Watson's avatar Myles Watson
Browse files

OPP: Use a private notification

Add a private notification without accept and decline
buttons, so that files can not be accepted on an
unlocked phone.

Bug: 160691486
Test: Send a file to a locked phone, unlock and repeat
Tag: #security
Change-Id: I6b6258424373e3265b07184a9b4d9f0ee95fcb41
parent a9d777bc
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -569,7 +569,7 @@ class BluetoothOppNotification {
                    mContext.getText(R.string.incoming_file_confirm_ok),
                    PendingIntent.getBroadcast(mContext, 0,
                            new Intent(baseIntent).setAction(Constants.ACTION_ACCEPT), 0)).build();
            Notification n =
            Notification public_n =
                    new Notification.Builder(mContext, OPP_NOTIFICATION_CHANNEL).setOnlyAlertOnce(
                            true)
                            .setOngoing(true)
@@ -596,6 +596,33 @@ class BluetoothOppNotification {
                            .setSmallIcon(R.drawable.bt_incomming_file_notification)
                            .setLocalOnly(true)
                            .build();
            Notification n =
                    new Notification.Builder(mContext, OPP_NOTIFICATION_CHANNEL).setOnlyAlertOnce(
                            true)
                            .setOngoing(true)
                            .setWhen(info.mTimeStamp)
                            .setContentIntent(PendingIntent.getBroadcast(mContext, 0,
                                    new Intent(baseIntent).setAction(
                                            Constants.ACTION_INCOMING_FILE_CONFIRM), 0))
                            .setDeleteIntent(PendingIntent.getBroadcast(mContext, 0,
                                    new Intent(baseIntent).setAction(Constants.ACTION_HIDE), 0))
                            .setColor(mContext.getResources()
                                    .getColor(
                                            com.android.internal.R.color
                                                    .system_notification_accent_color,
                                            mContext.getTheme()))
                            .setContentTitle(mContext.getText(
                                    R.string.incoming_file_confirm_Notification_title))
                            .setContentText(info.mFileName)
                            .setStyle(new Notification.BigTextStyle().bigText(mContext.getString(
                                    R.string.incoming_file_confirm_Notification_content,
                                    info.mDeviceName, info.mFileName)))
                            .setSubText(Formatter.formatFileSize(mContext, info.mTotalBytes))
                            .setSmallIcon(R.drawable.bt_incomming_file_notification)
                            .setLocalOnly(true)
                            .setVisibility(Notification.VISIBILITY_PRIVATE)
                            .setPublicVersion(public_n)
                            .build();
            mNotificationMgr.notify(NOTIFICATION_ID_PROGRESS, n);
        }
        cursor.close();