blob: 203e439685a951bd1466c6bf6243021a2125b33b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package org.robolectric.shadows;
import static android.os.Build.VERSION_CODES.TIRAMISU;
import static org.robolectric.util.reflector.Reflector.reflector;
import android.content.ContentResolver;
import android.provider.Settings;
import android.view.accessibility.CaptioningManager;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.RealObject;
import org.robolectric.util.reflector.Accessor;
import org.robolectric.util.reflector.ForType;
/** Shadow of {@link android.view.accessibility.CaptioningManager}. */
@Implements(CaptioningManager.class)
public class ShadowCaptioningManager {
@RealObject private CaptioningManager realCaptioningManager;
@Implementation(minSdk = TIRAMISU)
protected void setSystemAudioCaptioningEnabled(boolean isEnabled) {
Settings.Secure.putInt(
getContentResolver(), Settings.Secure.ODI_CAPTIONS_ENABLED, isEnabled ? 1 : 0);
}
@Implementation(minSdk = TIRAMISU)
protected void setSystemAudioCaptioningUiEnabled(boolean isEnabled) {
Settings.Secure.putInt(
getContentResolver(), Settings.Secure.ODI_CAPTIONS_VOLUME_UI_ENABLED, isEnabled ? 1 : 0);
}
@Implementation(minSdk = TIRAMISU)
protected boolean isSystemAudioCaptioningUiEnabled() {
return Settings.Secure.getInt(
getContentResolver(), Settings.Secure.ODI_CAPTIONS_VOLUME_UI_ENABLED, 1)
== 1;
}
private ContentResolver getContentResolver() {
return reflector(CaptioningManagerReflector.class, realCaptioningManager).getContentResolver();
}
@ForType(CaptioningManager.class)
interface CaptioningManagerReflector {
@Accessor("mContentResolver")
ContentResolver getContentResolver();
}
}
|