Merge "Fix null running task info in SysUI tests" into pi-dev

This commit is contained in:
Mike Digman
2018-04-11 16:12:47 +00:00
committed by Android (Google) Code Review

View File

@@ -103,6 +103,7 @@ import java.io.FileDescriptor;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Optional;
/** /**
* Fragment containing the NavigationBarFragment. Contains logic for what happens * Fragment containing the NavigationBarFragment. Contains logic for what happens
@@ -1109,8 +1110,11 @@ public class NavigationBarFragment extends Fragment implements Callbacks {
public void onActivityRequestedOrientationChanged(int taskId, int requestedOrientation) { public void onActivityRequestedOrientationChanged(int taskId, int requestedOrientation) {
// Only hide the icon if the top task changes its requestedOrientation // Only hide the icon if the top task changes its requestedOrientation
// Launcher can alter its requestedOrientation while it's not on top, don't hide on this // Launcher can alter its requestedOrientation while it's not on top, don't hide on this
final boolean top = ActivityManagerWrapper.getInstance().getRunningTask().id == taskId; Optional.ofNullable(ActivityManagerWrapper.getInstance())
if (top) setRotateSuggestionButtonState(false); .map(ActivityManagerWrapper::getRunningTask)
.ifPresent(a -> {
if (a.id == taskId) setRotateSuggestionButtonState(false);
});
} }
} }