Force dialpad to hide on resume if it should be hidden

On M the framework does not retain the hidden state of a fragment properly when restoring it from a savedInstanceState. This appears to be fixed in N, but the exact cause and fix are unknown. This behavior will cause a fragment previously hidden coming back as visible when the device is rotated or going through any save/restore life cycle.

Previously whether to show the dialpad is stored in a separate flag, and the dialpad will be hidden when it is reattached. This was regresed in cl/169614750

In this CL, if the saved mIsDialpadShown indicate the dialpad should not be shown, but the dialpad is not hidden, it will be hidden on resume.

Bug: 66893723
Test: DialtactsActivityTest
PiperOrigin-RevId: 170124711
Change-Id: I6f8ed21fb970d6f688cb75f854442115a6803f3c
diff --git a/java/com/android/dialer/app/DialtactsActivity.java b/java/com/android/dialer/app/DialtactsActivity.java
index 00d28fe..04f1431 100644
--- a/java/com/android/dialer/app/DialtactsActivity.java
+++ b/java/com/android/dialer/app/DialtactsActivity.java
@@ -517,6 +517,14 @@
       PostCall.promptUserForMessageIfNecessary(this, mParentLayout);
     }
 
+    // On M the fragment manager does not restore the hidden state of a fragment from
+    // savedInstanceState so it must be hidden again.
+    if (!mIsDialpadShown && mDialpadFragment != null && !mDialpadFragment.isHidden()) {
+      LogUtil.i(
+          "DialtactsActivity.onResume", "mDialpadFragment attached but not hidden, forcing hide");
+      getFragmentManager().beginTransaction().hide(mDialpadFragment).commit();
+    }
+
     // If there was a voice query result returned in the {@link #onActivityResult} callback, it
     // will have been stashed in mVoiceSearchQuery since the search results fragment cannot be
     // shown until onResume has completed.  Active the search UI and set the search term now.