Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c751b74f authored by Nadav Bar's avatar Nadav Bar
Browse files

Add API for checking if call captioning is enabled on the device

Change-Id: I690072f912ab86d5cdf4275fa9fb11f5d2e78b64
Bug: 210923707, 136282740.
Test: Make, atest CtsAccessibilityTestCases: android.view.accessibility.cts.CaptioningManagerTest
parent a5ca4654
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -51937,6 +51937,7 @@ package android.view.accessibility {
    method public final float getFontScale();
    method @Nullable public final java.util.Locale getLocale();
    method @NonNull public android.view.accessibility.CaptioningManager.CaptionStyle getUserStyle();
    method public boolean isCallCaptioningEnabled();
    method public final boolean isEnabled();
    method public void removeCaptioningChangeListener(@NonNull android.view.accessibility.CaptioningManager.CaptioningChangeListener);
  }
+0 −1
Original line number Diff line number Diff line
@@ -363,7 +363,6 @@ package android {
    field public static final int config_showDefaultAssistant = 17891329; // 0x1110001
    field public static final int config_showDefaultEmergency = 17891330; // 0x1110002
    field public static final int config_showDefaultHome = 17891331; // 0x1110003
    field public static final int config_systemCaptionsServiceCallsEnabled;
  }
  public static final class R.color {
+12 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.SystemService;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.graphics.Color;
import android.graphics.Typeface;
@@ -30,6 +31,8 @@ import android.os.Handler;
import android.provider.Settings.Secure;
import android.text.TextUtils;

import com.android.internal.R;

import java.util.ArrayList;
import java.util.Locale;

@@ -51,6 +54,7 @@ public class CaptioningManager {
    private final ArrayList<CaptioningChangeListener> mListeners = new ArrayList<>();
    private final ContentResolver mContentResolver;
    private final ContentObserver mContentObserver;
    private final Resources mResources;

    /**
     * Creates a new captioning manager for the specified context.
@@ -62,6 +66,7 @@ public class CaptioningManager {

        final Handler handler = new Handler(context.getMainLooper());
        mContentObserver = new MyContentObserver(handler);
        mResources = context.getResources();
    }

    /**
@@ -181,6 +186,13 @@ public class CaptioningManager {
        }
    }

    /**
     * Returns true if system wide call captioning is enabled for this device.
     */
    public boolean isCallCaptioningEnabled() {
        return mResources.getBoolean(R.bool.config_systemCaptionsServiceCallsEnabled);
    }

    private void notifyEnabledChanged() {
        final boolean enabled = isEnabled();
        synchronized (mListeners) {
+0 −2
Original line number Diff line number Diff line
@@ -3311,8 +3311,6 @@
  </staging-public-group>

  <staging-public-group type="bool" first-id="0x01cf0000">
    <!-- @hide @SystemApi -->
    <public name="config_systemCaptionsServiceCallsEnabled" />
    <!-- @hide @TestApi -->
    <public name="config_preventImeStartupUnlessTextEditor" />
  </staging-public-group>
+2 −0
Original line number Diff line number Diff line
@@ -3650,6 +3650,8 @@
  <java-symbol type="string" name="config_retailDemoPackage" />
  <java-symbol type="string" name="config_retailDemoPackageSignature" />

  <java-symbol type="bool" name="config_systemCaptionsServiceCallsEnabled" />

  <java-symbol type="string" name="notification_channel_foreground_service" />
  <java-symbol type="string" name="foreground_service_app_in_background" />
  <java-symbol type="string" name="foreground_service_apps_in_background" />