4. A sphere is circumscribed around the tetrahedron $ABCD$, and another sphere with radius 1 is tangent to the plane $ABC$ and the two spheres are internally tangent at point $D$. Given $AD = 3, \cos \angle BAC = \frac{4}{5}, \cos \angle BAD = \cos \angle CAD = \frac{1}{\sqrt{2}}$. The volume of the tetrahedron $ABCD$ is ( ).
(A) $\frac{18}{5}$
(B) $\frac{27}{5}$
(C) 3
(D) 5
4. (A).

First, prove that the height $D H$ of tetrahedron $A B C D$ is a diameter of a certain sphere.
As shown in Figure 2, let $D E \perp A B, D F \perp A C$, with the feet of the perpendiculars being $E$ and $F$, respectively, then
$$
\begin{array}{l}
A E=A F \\
=A D \cos \angle B A D=\frac{3}{\sqrt{2}} . \\
\cos \angle H A E=\cos \angle H A F^{\circ} \\
=\sqrt{\frac{1+\cos \angle B A C}{2}}=-\frac{3}{10} .
\end{array}
$$

Thus, $A H=\frac{A E}{\cos \angle H A E}=\sqrt{5}$.
$$
D H=\sqrt{A D^{2}-A H^{2}}=2 .
$$

Therefore, the center of the circumscribed sphere of the tetrahedron lies on $D H$.
Hence, $A D=B D=C D$, then $A C=A B=2 A E=3 \sqrt{2}$.
Thus, $S_{2 u r:}=\frac{1}{2} A B \cdot A C \sin \angle B A C=\frac{27}{5}$.
$$
\therefore V_{D-4 B C}=\frac{1}{3} S_{i \triangle A B C} \cdot U H=\frac{18}{5} .
$$