diff options
author | twyen <twyen@google.com> | 2018-01-31 16:10:06 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-31 20:28:39 -0800 |
commit | ef5b8668e881cb29b8b386e5d1ea93527e3a9a52 (patch) | |
tree | 93eea395ec3c84dd7445922df88c569ea57c51ed /java | |
parent | cd496f819fb3c6aa67fab6295b7612edf202f79d (diff) |
Fullly disable VVM if carrier VVM app is installed.
Previously it is only disabled when the user has not changed the VVM settings, and the user can still re-enable it.
After this CL, VVM will always be disabled, and the settings will be hidden.
Bug: 72668279
Test: Unit tests
PiperOrigin-RevId: 184063245
Change-Id: I42c12f3fd2f3e397158e08b26875a7e99a766d33
Diffstat (limited to 'java')
4 files changed, 10 insertions, 43 deletions
diff --git a/java/com/android/voicemail/impl/CarrierVvmPackageInstalledReceiver.java b/java/com/android/voicemail/impl/CarrierVvmPackageInstalledReceiver.java index 1b5391da8..c9c09b322 100644 --- a/java/com/android/voicemail/impl/CarrierVvmPackageInstalledReceiver.java +++ b/java/com/android/voicemail/impl/CarrierVvmPackageInstalledReceiver.java @@ -31,6 +31,6 @@ public class CarrierVvmPackageInstalledReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { String packageName = intent.getStringExtra(Intent.EXTRA_PACKAGE_NAME); VvmLog.i("CarrierVvmPackageInstalledReceiver.onReceive", "package installed: " + packageName); - VvmPackageInstallHandler.handlePackageInstalled(context, packageName); + VvmPackageInstallHandler.handlePackageInstalled(context); } } diff --git a/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java b/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java index d5cde72bd..ef62d2a75 100644 --- a/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java +++ b/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java @@ -178,9 +178,6 @@ public class OmtpVvmCarrierConfigHelper { if (protocol == null) { return false; } - if (isCarrierAppPreloaded()) { - return false; - } return true; } @@ -248,20 +245,7 @@ public class OmtpVvmCarrierConfigHelper { if (!isValid()) { return false; } - - Set<String> carrierPackages = getCarrierVvmPackageNames(); - if (carrierPackages == null) { - return true; - } - for (String packageName : carrierPackages) { - try { - context.getPackageManager().getPackageInfo(packageName, 0); - return false; - } catch (NameNotFoundException e) { - // Do nothing. - } - } - return true; + return !isCarrierAppInstalled(); } public boolean isCellularDataRequired() { @@ -511,7 +495,8 @@ public class OmtpVvmCarrierConfigHelper { overrideConfigForTest = config; } - private boolean isCarrierAppPreloaded() { + /** Checks if the carrier VVM app is installed. */ + public boolean isCarrierAppInstalled() { Set<String> carrierPackages = getCarrierVvmPackageNamesWithoutValidation(); if (carrierPackages == null) { return false; @@ -522,12 +507,7 @@ public class OmtpVvmCarrierConfigHelper { if (!info.enabled) { continue; } - if ((info.flags & ApplicationInfo.FLAG_SYSTEM) != 0 - || (info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) { - VvmLog.i(TAG, packageName + " preloaded, force disabling dialer vvm"); - return true; - } - + return true; } catch (NameNotFoundException e) { continue; } diff --git a/java/com/android/voicemail/impl/VoicemailClientImpl.java b/java/com/android/voicemail/impl/VoicemailClientImpl.java index 75d6dfc66..993594eb3 100644 --- a/java/com/android/voicemail/impl/VoicemailClientImpl.java +++ b/java/com/android/voicemail/impl/VoicemailClientImpl.java @@ -78,7 +78,8 @@ public class VoicemailClientImpl implements VoicemailClient { @Override public boolean hasCarrierSupport(Context context, PhoneAccountHandle phoneAccountHandle) { - return new OmtpVvmCarrierConfigHelper(context, phoneAccountHandle).isValid(); + OmtpVvmCarrierConfigHelper config = new OmtpVvmCarrierConfigHelper(context, phoneAccountHandle); + return config.isValid() && !config.isCarrierAppInstalled(); } @Override diff --git a/java/com/android/voicemail/impl/VvmPackageInstallHandler.java b/java/com/android/voicemail/impl/VvmPackageInstallHandler.java index 07900c26f..276b7889a 100644 --- a/java/com/android/voicemail/impl/VvmPackageInstallHandler.java +++ b/java/com/android/voicemail/impl/VvmPackageInstallHandler.java @@ -42,7 +42,7 @@ public final class VvmPackageInstallHandler { * Iterates through all phone account and disable VVM on a account if {@code packageName} is * listed as a carrier VVM package. */ - public static void handlePackageInstalled(Context context, String packageName) { + public static void handlePackageInstalled(Context context) { // This get called every time an app is installed and will be noisy. Don't log until the app // is identified as a carrier VVM app. for (PhoneAccountHandle phoneAccount : @@ -52,25 +52,11 @@ public final class VvmPackageInstallHandler { if (!carrierConfigHelper.isValid()) { continue; } - if (carrierConfigHelper.getCarrierVvmPackageNames() == null) { - continue; - } - if (!carrierConfigHelper.getCarrierVvmPackageNames().contains(packageName)) { - continue; - } - - VvmLog.i("VvmPackageInstallHandler.handlePackageInstalled", "Carrier app installed"); - if (VisualVoicemailSettingsUtil.isEnabledUserSet(context, phoneAccount)) { - // Skip the check if this voicemail source's setting is overridden by the user. - VvmLog.i( - "VvmPackageInstallHandler.handlePackageInstalled", - "VVM enabled by user, not disabling"); + if (!carrierConfigHelper.isCarrierAppInstalled()) { continue; } - // Force deactivate the client. The user can re-enable it in the settings. - // There is no need to update the settings for deactivation. At this point, if the - // default value is used it should be false because a carrier package is present. + // Force deactivate the client. VvmLog.i( "VvmPackageInstallHandler.handlePackageInstalled", "Carrier VVM package installed, disabling system VVM client"); |