Revise VVM enabled setting strategy
When a new SIM is inserted the system VVM client should be enabled by
default, unless the carrier's VVM app is installed.
If the carrier's VVM app is installed it should have higher priority
over the system VVM client. The system VVM client should disable itself
to let the carrier VVM app handle voicemails. The exception is if the
system VVM client was enabled explicitly by the user, it should not
transfer the responsibility of VVM handling.
In b/29254367 we found that when a new SIM is swapped in, the system VVM
client could be disabled by default, even though no carrier VVM app is
present. The root cause is fix in ag/1128444, but the original logic to
enable/disable system VVM client is convoluted and fragile so it is
rewritten.
The enabled settings could be flipped anywhere before this CL, which
will update the user set status stored in a preference. The full set of
conditions to enable/disable VVM is only observed in SimChangeReceiver,
which could change the enabled status while Other components just read
the status.
After this CL, only the VoicemailSettingsActivity is allowed to write
to the setting. When
VisualVoicemailSettingsUtil.isVisualVoicemailEnabled() is called, the
setting written by VoicemailSettingsActivity will be respected. If it is
not present, a full query will be done to
OmtpVvmCarrierConfigHelper.isEnabledByDefault(). Other conditions such
as R.bool.allow_visual_voicemail is also incorporated into
isVisualVoicemailEnabled().
When a new SIM is inserted, no preferences are set so isEnabledByDefault()
will be called. Since no carrier app is installed it will return true and
VVM will be enabled.
If a carrier VVM app is installed, the system client will be shut down
with VvmPackageInstallReceiver. Since isEnabledByDefault() will return
false from now on, there is no need to change the settings.
If a carrier VVM app is uninstalled, isEnabledByDefault() will return
true, and on the next boot the system client will be activated. The
system client should be activated upon uninstallation, but that is not a
regression and should be done in another CL.
If the setting is set by the user, then it will override the above logic.
Change-Id: I544b90d092765ae98c462897216d8a596244310f
Fixes: 29254367
6 files changed