Skip to content

Commit 3727e30

Browse files
committed
Rename PendingIntent to pendingIntentToStartService and cachedIntent to startSdlServiceIntent, remove unused import in SdlReceiver
1 parent 762ffc9 commit 3727e30

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
import com.smartdevicelink.util.AndroidTools;
1616
import com.smartdevicelink.util.DebugTool;
1717

18-
import java.lang.ref.WeakReference;
1918

2019
public class SdlReceiver extends SdlBroadcastReceiver {
2120
private static final String TAG = "SdlBroadcastReceiver";
2221

2322
private static final String ACTION_USB_PERMISSION = "com.android.example.USB_PERMISSION";
24-
private PendingIntent pendingIntent;
25-
private Intent cachedIntent;
23+
private PendingIntent pendingIntentToStartService;
24+
private Intent startSdlServiceIntent;
2625

2726
@Override
2827
public void onSdlEnabled(Context context, Intent intent) {
@@ -38,8 +37,8 @@ public void onSdlEnabled(Context context, Intent intent) {
3837
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
3938
if (!AndroidTools.hasForegroundServiceTypePermission(context)) {
4039
requestUsbAccessory(context);
41-
cachedIntent = intent;
42-
this.pendingIntent = pendingIntent;
40+
startSdlServiceIntent = intent;
41+
this.pendingIntentToStartService = pendingIntent;
4342
DebugTool.logInfo(TAG, "Permission missing for ForegroundServiceType connected device." + context);
4443
return;
4544
}
@@ -81,10 +80,10 @@ public String getSdlServiceName() {
8180

8281
public void onReceive(Context context, Intent intent) {
8382
String action = intent.getAction();
84-
if (ACTION_USB_PERMISSION.equals(action) && context != null && cachedIntent != null && pendingIntent != null) {
83+
if (ACTION_USB_PERMISSION.equals(action) && context != null && startSdlServiceIntent != null && pendingIntentToStartService != null) {
8584
if (AndroidTools.hasForegroundServiceTypePermission(context)) {
8685
try {
87-
pendingIntent.send(context, 0, cachedIntent);
86+
pendingIntentToStartService.send(context, 0, startSdlServiceIntent);
8887
} catch (PendingIntent.CanceledException e) {
8988
e.printStackTrace();
9089
}

0 commit comments

Comments
 (0)