From bafc8fd0c05802a1cbe6987993275221a6a2175b Mon Sep 17 00:00:00 2001 From: Rohit Yengisetty Date: Thu, 26 May 2016 15:41:52 -0700 Subject: Fix NPE in caller-info settings migration component Also, ensure that the component is disabled in the case where there aren't any settings to migrate. Change-Id: Icb7e7ab41abde90551091117be5d9606ee6c1f23 Issue-Id: CYNGNOS-2537 --- .../dialer/CallerInfoSettingsMigrationReceiver.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/dialer/CallerInfoSettingsMigrationReceiver.java b/src/com/android/dialer/CallerInfoSettingsMigrationReceiver.java index 2dd9eacbc..53893fc3d 100644 --- a/src/com/android/dialer/CallerInfoSettingsMigrationReceiver.java +++ b/src/com/android/dialer/CallerInfoSettingsMigrationReceiver.java @@ -30,13 +30,23 @@ import static com.cyanogen.ambient.callerinfo.util.SettingsConstants.PROVIDER_ST */ public class CallerInfoSettingsMigrationReceiver extends BroadcastReceiver { + private static void disableReceiver(Context context) { + ComponentName migrationReceiver = new ComponentName(context, + CallerInfoSettingsMigrationReceiver.class); + context.getPackageManager().setComponentEnabledSetting(migrationReceiver, + PackageManager.COMPONENT_ENABLED_STATE_DISABLED, + PackageManager.DONT_KILL_APP); + } + @Override public void onReceive(final Context context, Intent intent) { if (CyanogenAmbientUtil.isCyanogenAmbientAvailable(context) == CyanogenAmbientUtil.SUCCESS) { ComponentName provider = CallerInfoHelper.getActiveProviderPackage(context); - if (TextUtils.isEmpty(provider.flattenToString())) { + if (provider == null || TextUtils.isEmpty(provider.flattenToString())) { // there isn't an active provider to migrate to the new settings + // disable receiver + disableReceiver(context); return; } @@ -94,11 +104,7 @@ public class CallerInfoSettingsMigrationReceiver extends BroadcastReceiver { private void performCleanup() { // disable migration receiver - ComponentName migrationReceiver = new ComponentName(this, - CallerInfoSettingsMigrationReceiver.class); - getPackageManager().setComponentEnabledSetting(migrationReceiver, - PackageManager.COMPONENT_ENABLED_STATE_DISABLED, - PackageManager.DONT_KILL_APP); + CallerInfoSettingsMigrationReceiver.disableReceiver(this); // unbind from the caller-info plugin unbindService(this); -- cgit v1.2.3