Stop checking OWNER user in calllog backup.

Only OWNER supports backup today so this check is unnecessary.  It also
happens to have been written backwards and was only running for
non-owners.

Also, calllog entries can have a null handle if manually entered through
the call log APIs. Add code to manage null-value smoothly when restoring
the call log from backup.

Bug: 22299502
Change-Id: I047a0282888fec03f904fbbfe39ac49f3d93886d
diff --git a/src/com/android/providers/calllogbackup/CallLogBackupAgent.java b/src/com/android/providers/calllogbackup/CallLogBackupAgent.java
index 24ab98e..a94c91c 100644
--- a/src/com/android/providers/calllogbackup/CallLogBackupAgent.java
+++ b/src/com/android/providers/calllogbackup/CallLogBackupAgent.java
@@ -114,10 +114,6 @@
     public void onBackup(ParcelFileDescriptor oldStateDescriptor, BackupDataOutput data,
             ParcelFileDescriptor newStateDescriptor) throws IOException {
 
-        if (UserManager.get(this).getUserHandle() == UserHandle.USER_OWNER) {
-            return;
-        }
-
         // Get the list of the previous calls IDs which were backed up.
         DataInputStream dataInput = new DataInputStream(
                 new FileInputStream(oldStateDescriptor.getFileDescriptor()));
@@ -145,10 +141,6 @@
     @Override
     public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState)
             throws IOException {
-        if (UserManager.get(this).getUserHandle() == UserHandle.USER_OWNER) {
-            return;
-        }
-
         if (isDebug()) {
             Log.d(TAG, "Performing Restore");
         }
@@ -227,8 +219,11 @@
     private void writeCallToProvider(Call call) {
         Long dataUsage = call.dataUsage == 0 ? null : call.dataUsage;
 
-        PhoneAccountHandle handle = new PhoneAccountHandle(
-                ComponentName.unflattenFromString(call.accountComponentName), call.accountId);
+        PhoneAccountHandle handle = null;
+        if (call.accountComponentName != null && call.accountId != null) {
+            handle = new PhoneAccountHandle(
+                    ComponentName.unflattenFromString(call.accountComponentName), call.accountId);
+        }
         Calls.addCall(null /* CallerInfo */, this, call.number, call.numberPresentation, call.type,
                 call.features, handle, call.date, (int) call.duration,
                 dataUsage, true /* addForAllUsers */);