ContextImpl和ContextWrapper都是繼承自Context,在ContextWrapper中依賴了ContextImpl對象(mBase)。這里使用了裝飾者模式,ContextWrapper是裝飾類,對ContextImpl進行包裝,通過使用ContextImpl實現功能。
Application、Service、ContextThemeWrapper繼承自ContextWrapper,它們也是通過ContextImpl實現功能,同時在ContextWrapper的基礎上添加了自己的功能。此外ContextThemeWrapper中包含了主題相關的方法,Activity繼承自ContextThemeWrapper。