@@ -39,12 +39,20 @@ protected void onCreate(Bundle savedInstanceState) {
3939 }
4040 }
4141
42- private boolean checkBTPermission () {
43- return Build .VERSION .SDK_INT >= Build .VERSION_CODES .S && !checkPermission (Manifest .permission .BLUETOOTH_CONNECT );
42+ /**
43+ * Boolean method that checks API level and check to see if we need to request BLUETOOTH_CONNECT permission
44+ * @return false if we need to request BLUETOOTH_CONNECT permission
45+ */
46+ private boolean hasBTPermission () {
47+ return Build .VERSION .SDK_INT >= Build .VERSION_CODES .S ? checkPermission (Manifest .permission .BLUETOOTH_CONNECT ) : true ;
4448 }
4549
46- private boolean checkPNPermission () {
47- return Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU && !checkPermission (Manifest .permission .POST_NOTIFICATIONS );
50+ /**
51+ * Boolean method that checks API level and check to see if we need to request POST_NOTIFICATIONS permission
52+ * @return false if we need to request POST_NOTIFICATIONS permission
53+ */
54+ private boolean hasPNPermission () {
55+ return Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU ? checkPermission (Manifest .permission .POST_NOTIFICATIONS ) : true ;
4856 }
4957
5058 private boolean checkPermission (String permission ) {
@@ -57,10 +65,10 @@ private void requestPermission(String[] permissions, int REQUEST_CODE) {
5765
5866 private @ NonNull String [] permissionsNeeded () {
5967 ArrayList <String > result = new ArrayList <>();
60- if (checkBTPermission ()) {
68+ if (! hasBTPermission ()) {
6169 result .add (Manifest .permission .BLUETOOTH_CONNECT );
6270 }
63- if (checkPNPermission ()) {
71+ if (! hasPNPermission ()) {
6472 result .add (Manifest .permission .POST_NOTIFICATIONS );
6573 }
6674 return (result .toArray (new String [result .size ()]));
0 commit comments