summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRohit Yengisetty <rohit@cyngn.com>2016-05-26 15:41:52 -0700
committerRohit Yengisetty <rohit@cyngn.com>2016-05-26 15:41:52 -0700
commitbafc8fd0c05802a1cbe6987993275221a6a2175b (patch)
treeaa7d5d3742ff3f25925bc2ce9b871859c52cf926 /src
parent5b9db20b71bab5a9ca71e07ace633a8a8d5c9e56 (diff)
downloadandroid_packages_apps_Dialer-bafc8fd0c05802a1cbe6987993275221a6a2175b.tar.gz
android_packages_apps_Dialer-bafc8fd0c05802a1cbe6987993275221a6a2175b.tar.bz2
android_packages_apps_Dialer-bafc8fd0c05802a1cbe6987993275221a6a2175b.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/CallerInfoSettingsMigrationReceiver.java18
1 files changed, 12 insertions, 6 deletions
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);