Skip to content

Commit

Permalink
Fix SonarLint java:S5320, restrict broadcasts to app package
Browse files Browse the repository at this point in the history
  • Loading branch information
Stypox committed Jul 13, 2022
1 parent c03eac1 commit 4443c90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import com.google.android.exoplayer2.ui.CaptionStyleCompat;
import com.google.android.exoplayer2.video.VideoSize;

import org.schabi.newpipe.App;
import org.schabi.newpipe.R;
import org.schabi.newpipe.databinding.PlayerBinding;
import org.schabi.newpipe.extractor.MediaFormat;
Expand Down Expand Up @@ -1372,7 +1373,9 @@ public void onClick(final View v) {
} else if (v.getId() == binding.switchMute.getId()) {
player.toggleMute();
} else if (v.getId() == binding.playerCloseButton.getId()) {
context.sendBroadcast(new Intent(VideoDetailFragment.ACTION_HIDE_MAIN_PLAYER));
// set package to this app's package to prevent the intent from being seen outside
context.sendBroadcast(new Intent(VideoDetailFragment.ACTION_HIDE_MAIN_PLAYER)
.setPackage(App.PACKAGE_NAME));
} else if (v.getId() == binding.playbackSpeed.getId()) {
onPlaybackSpeedClicked();
} else if (v.getId() == binding.qualityTextView.getId()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;

import org.schabi.newpipe.App;
import org.schabi.newpipe.R;
import org.schabi.newpipe.databinding.ListRadioIconItemBinding;
import org.schabi.newpipe.databinding.SingleChoiceDialogViewBinding;
Expand Down Expand Up @@ -62,7 +63,9 @@ public void onBindViewHolder(@NonNull final PreferenceViewHolder holder) {
public void onDetached() {
super.onDetached();
saveChanges();
getContext().sendBroadcast(new Intent(ACTION_RECREATE_NOTIFICATION));
// set package to this app's package to prevent the intent from being seen outside
getContext().sendBroadcast(new Intent(ACTION_RECREATE_NOTIFICATION)
.setPackage(App.PACKAGE_NAME));
}


Expand Down

0 comments on commit 4443c90

Please sign in to comment.