Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.smartdevicelink.managers.lockscreen;

import android.content.Context;
import android.content.Intent;
import android.os.Looper;

import androidx.test.ext.junit.runners.AndroidJUnit4;

Expand Down Expand Up @@ -170,4 +172,34 @@ public void testLockScreenDismissibleWithEnableFalseAndDismissibilityTrue() {
assertTrue(lockScreenManager.isLockscreenDismissible);
}

@Test
public void testShowingLockscreenAfterDismissibleFalse() {
if (Looper.myLooper() == null) {
Looper.prepare();
}
lockScreenManager.enableDismissGesture = true;
lockScreenManager.displayMode = LockScreenConfig.DISPLAY_MODE_ALWAYS;

// Send first notification (DD=OFF, Dismissible=true)
OnDriverDistraction onDriverDistraction = new OnDriverDistraction();
onDriverDistraction.setLockscreenDismissibility(true);
onDriverDistraction.setState(DriverDistractionState.DD_OFF);
onDDListener.onNotified(onDriverDistraction);

// Dismiss lock screen activity
lockScreenManager.mLockscreenDismissedReceiver.onReceive(null, new Intent(SDLLockScreenActivity.KEY_LOCKSCREEN_DISMISSED, null));

// Lock screen should be set to auto dismiss in future
assertTrue(lockScreenManager.mLockScreenShouldBeAutoDismissed);

// Send second notification (DD=On, Dismissible=false)
onDriverDistraction = new OnDriverDistraction();
onDriverDistraction.setLockscreenDismissibility(false);
onDriverDistraction.setState(DriverDistractionState.DD_ON);
onDDListener.onNotified(onDriverDistraction);

// Lock screen should be set to NOT auto dismiss in future
assertFalse(lockScreenManager.mLockScreenShouldBeAutoDismissed);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ public class LockScreenManager extends BaseSubManager {
final int customView;
int displayMode;
Bitmap deviceLogo;
private boolean mLockScreenHasBeenDismissed, lockscreenDismissReceiverRegistered, receivedFirstDDNotification;
private boolean lockscreenDismissReceiverRegistered, receivedFirstDDNotification;
boolean mLockScreenShouldBeAutoDismissed;
private String mLockscreenWarningMsg;
private BroadcastReceiver mLockscreenDismissedReceiver;
BroadcastReceiver mLockscreenDismissedReceiver;
private final LockScreenDeviceIconManager mLockScreenDeviceIconManager;
private String lastIntentUsed;

Expand Down Expand Up @@ -220,6 +221,11 @@ public void onNotified(RPCNotification notification) {
// enable the dismissal. There is a delay added to allow time for the activity
// time to completely start and handle the new intent. There seems to be odd behavior
// in Android when startActivity is called multiple times too quickly.
if (previousDismissibleState) {
// If lockscreen was dismissible, got dismissed by the user, then became not dismissible, the lockscreen activity should be allowed to launch again
// https://github.com/smartdevicelink/sdl_java_suite/issues/1695
mLockScreenShouldBeAutoDismissed = false;
}
if (!receivedFirstDDNotification) {
new Handler().postDelayed(new Runnable() {
@Override
Expand Down Expand Up @@ -296,7 +302,7 @@ public void onMoveToBackground() {
@Override
public void onReceive(Context context, Intent intent) {
if (SDLLockScreenActivity.KEY_LOCKSCREEN_DISMISSED.equals(intent.getAction())) {
mLockScreenHasBeenDismissed = true;
mLockScreenShouldBeAutoDismissed = true;
lastIntentUsed = null;
}
}
Expand All @@ -318,7 +324,7 @@ public void onReceive(Context context, Intent intent) {
private void launchLockScreenActivity() {
synchronized (LOCKSCREEN_LAUNCH_LOCK) {
// If the user has dismissed the lockscreen for this run or has disabled it, do not show it
if (mLockScreenHasBeenDismissed || displayMode == LockScreenConfig.DISPLAY_MODE_NEVER) {
if (mLockScreenShouldBeAutoDismissed || displayMode == LockScreenConfig.DISPLAY_MODE_NEVER) {
return;
}
// intent to open SDLLockScreenActivity
Expand Down