Fix Live Caption does not follow caption size if caption is not enabled

Root cause: Changing captions style without turning on the preference WHILE Live Caption is running works when it shouldn't.
Solution: Turn on the show caption if users change caption size and style by UX suggestion.

Bug: 221051127
Test: Manual testing
  1. Turning on/off Live Caption and Caption Manager
  2. Changing styles when Caption Manager is off
Change-Id: Ie6cfb9e0b7325c2e469ac8b6a7d359b843cc173a
diff --git a/src/com/android/settings/accessibility/CaptionAppearanceFragment.java b/src/com/android/settings/accessibility/CaptionAppearanceFragment.java
index 13055be..53c1dd0 100644
--- a/src/com/android/settings/accessibility/CaptionAppearanceFragment.java
+++ b/src/com/android/settings/accessibility/CaptionAppearanceFragment.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.accessibility;
 
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
+
 import android.app.settings.SettingsEnums;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -400,6 +402,7 @@
         }
 
         refreshPreviewText();
+        enableCaptioningManager();
     }
 
     @Override
@@ -409,16 +412,26 @@
             Settings.Secure.putString(
                     cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_TYPEFACE, (String) value);
             refreshPreviewText();
+            enableCaptioningManager();
         } else if (mFontSize == preference) {
             Settings.Secure.putFloat(
                     cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE,
                     Float.parseFloat((String) value));
             refreshPreviewText();
+            enableCaptioningManager();
         }
 
         return true;
     }
 
+    private void enableCaptioningManager() {
+        if (mCaptioningManager.isEnabled()) {
+            return;
+        }
+        Settings.Secure.putInt(getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, ON);
+    }
+
     @Override
     public int getHelpResource() {
         return R.string.help_url_caption;