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

Commit f385fc04 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Prevent crash on invalid URIs, remove ACTION_OPEN"

parents 32f39a99 94634917
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -169,16 +169,6 @@ public class BluetoothOppLauncherActivity extends Activity {
                    return;
                }
            }
        } else if (action.equals(Constants.ACTION_OPEN)) {
            Uri uri = getIntent().getData();
            if (V) Log.v(TAG, "Get ACTION_OPEN intent: Uri = " + uri);

            Intent intent1 = new Intent();
            intent1.setAction(action);
            intent1.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
            intent1.setDataAndNormalize(uri);
            this.sendBroadcast(intent1);
            finish();
        } else {
            Log.w(TAG, "Unsupported action: " + action);
            finish();
+21 −22
Original line number Diff line number Diff line
@@ -118,27 +118,14 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
            in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            in.setDataAndNormalize(uri);
            context.startActivity(in);

            NotificationManager notMgr = (NotificationManager)context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            if (notMgr != null) {
                notMgr.cancel((int)ContentUris.parseId(intent.getData()));
                if (V) Log.v(TAG, "notMgr.cancel called");
            }
            cancelNotification(context, uri);
        } else if (action.equals(BluetoothShare.INCOMING_FILE_CONFIRMATION_REQUEST_ACTION)) {
            if (V) Log.v(TAG, "Receiver INCOMING_FILE_NOTIFICATION");

            Toast.makeText(context, context.getString(R.string.incoming_file_toast_msg),
                    Toast.LENGTH_SHORT).show();

        } else if (action.equals(Constants.ACTION_OPEN) || action.equals(Constants.ACTION_LIST)) {
            if (V) {
                if (action.equals(Constants.ACTION_OPEN)) {
                    Log.v(TAG, "Receiver open for " + intent.getData());
                } else {
        } else if (action.equals(Constants.ACTION_LIST)) {
            Log.v(TAG, "Receiver list for " + intent.getData());
                }
            }

            BluetoothOppTransferInfo transInfo = new BluetoothOppTransferInfo();
            Uri uri = intent.getData();
@@ -161,12 +148,7 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
                context.startActivity(in);
            }

            NotificationManager notMgr = (NotificationManager)context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            if (notMgr != null) {
                notMgr.cancel((int)ContentUris.parseId(intent.getData()));
                if (V) Log.v(TAG, "notMgr.cancel called");
                }
            cancelNotification(context, uri);
        } else if (action.equals(Constants.ACTION_OPEN_OUTBOUND_TRANSFER)) {
            if (V) Log.v(TAG, "Received ACTION_OPEN_OUTBOUND_TRANSFER.");

@@ -279,4 +261,21 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
            }
        }
    }

    private void cancelNotification(Context context, Uri uri) {
        NotificationManager notMgr = (NotificationManager)context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        if (notMgr == null) return;

        int id = -1;
        try {
          id = (int) ContentUris.parseId(uri);
        } catch (NumberFormatException ex) {
          Log.v(TAG, "Can't parse notification ID from Uri!");
          return;
        }

        notMgr.cancel(id);
        if (V) Log.v(TAG, "notMgr.cancel called");
    }
}
+0 −3
Original line number Diff line number Diff line
@@ -56,9 +56,6 @@ public class Constants {
     */
    public static final String ACTION_RETRY = "android.btopp.intent.action.RETRY";

    /** the intent that gets sent when clicking a successful transfer */
    public static final String ACTION_OPEN = "android.btopp.intent.action.OPEN";

    /** the intent that gets sent when clicking outbound transfer notification */
    public static final String ACTION_OPEN_OUTBOUND_TRANSFER = "android.btopp.intent.action.OPEN_OUTBOUND";