| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.wm.shell.compatui; |
| 18 |
|
| 19 |
import android.content.Context; |
| 20 |
import android.provider.DeviceConfig; |
| 21 |
|
| 22 |
import androidx.annotation.NonNull; |
| 23 |
|
| 24 |
import com.android.wm.shell.R; |
| 25 |
import com.android.wm.shell.common.ShellExecutor; |
| 26 |
import com.android.wm.shell.common.annotations.ShellMainThread; |
| 27 |
import com.android.wm.shell.dagger.WMSingleton; |
| 28 |
|
| 29 |
import javax.inject.Inject; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
@WMSingleton |
| 35 |
public class CompatUIConfiguration implements DeviceConfig.OnPropertiesChangedListener { |
| 36 |
|
| 37 |
static final String KEY_ENABLE_LETTERBOX_RESTART_DIALOG = "enable_letterbox_restart_dialog"; |
| 38 |
|
| 39 |
static final String KEY_ENABLE_LETTERBOX_REACHABILITY_EDUCATION = |
| 40 |
"enable_letterbox_reachability_education"; |
| 41 |
|
| 42 |
|
| 43 |
private boolean mIsRestartDialogEnabled; |
| 44 |
|
| 45 |
|
| 46 |
private boolean mIsReachabilityEducationEnabled; |
| 47 |
|
| 48 |
|
| 49 |
private boolean mIsRestartDialogOverrideEnabled; |
| 50 |
|
| 51 |
|
| 52 |
private boolean mIsReachabilityEducationOverrideEnabled; |
| 53 |
|
| 54 |
|
| 55 |
private boolean mIsLetterboxRestartDialogAllowed; |
| 56 |
|
| 57 |
|
| 58 |
private boolean mIsLetterboxReachabilityEducationAllowed; |
| 59 |
|
| 60 |
@Inject |
| 61 |
public CompatUIConfiguration(Context context, @ShellMainThread ShellExecutor mainExecutor) { |
| 62 |
mIsRestartDialogEnabled = context.getResources().getBoolean( |
| 63 |
R.bool.config_letterboxIsRestartDialogEnabled); |
| 64 |
mIsReachabilityEducationEnabled = context.getResources().getBoolean( |
| 65 |
R.bool.config_letterboxIsReachabilityEducationEnabled); |
| 66 |
mIsLetterboxRestartDialogAllowed = DeviceConfig.getBoolean( |
| 67 |
DeviceConfig.NAMESPACE_WINDOW_MANAGER, KEY_ENABLE_LETTERBOX_RESTART_DIALOG, false); |
| 68 |
mIsLetterboxReachabilityEducationAllowed = DeviceConfig.getBoolean( |
| 69 |
DeviceConfig.NAMESPACE_WINDOW_MANAGER, KEY_ENABLE_LETTERBOX_REACHABILITY_EDUCATION, |
| 70 |
false); |
| 71 |
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_APP_COMPAT, mainExecutor, |
| 72 |
this); |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
boolean isRestartDialogEnabled() { |
| 79 |
return mIsRestartDialogOverrideEnabled || (mIsRestartDialogEnabled |
| 80 |
&& mIsLetterboxRestartDialogAllowed); |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
void setIsRestartDialogOverrideEnabled(boolean enabled) { |
| 87 |
mIsRestartDialogOverrideEnabled = enabled; |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
boolean isReachabilityEducationEnabled() { |
| 94 |
return mIsReachabilityEducationOverrideEnabled || (mIsReachabilityEducationEnabled |
| 95 |
&& mIsLetterboxReachabilityEducationAllowed); |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
void setIsReachabilityEducationOverrideEnabled(boolean enabled) { |
| 102 |
mIsReachabilityEducationOverrideEnabled = enabled; |
| 103 |
} |
| 104 |
|
| 105 |
@Override |
| 106 |
public void onPropertiesChanged(@NonNull DeviceConfig.Properties properties) { |
| 107 |
|
| 108 |
if (properties.getKeyset().contains(KEY_ENABLE_LETTERBOX_RESTART_DIALOG)) { |
| 109 |
mIsLetterboxRestartDialogAllowed = DeviceConfig.getBoolean( |
| 110 |
DeviceConfig.NAMESPACE_WINDOW_MANAGER, KEY_ENABLE_LETTERBOX_RESTART_DIALOG, |
| 111 |
false); |
| 112 |
} |
| 113 |
if (properties.getKeyset().contains(KEY_ENABLE_LETTERBOX_REACHABILITY_EDUCATION)) { |
| 114 |
mIsLetterboxReachabilityEducationAllowed = DeviceConfig.getBoolean( |
| 115 |
DeviceConfig.NAMESPACE_WINDOW_MANAGER, |
| 116 |
KEY_ENABLE_LETTERBOX_REACHABILITY_EDUCATION, false); |
| 117 |
} |
| 118 |
} |
| 119 |
} |