Merge "Start service intent when contact is being displayed"
diff --git a/ndk/platforms/android-9/arch-x86/include/machine/_types.h b/ndk/platforms/android-9/arch-x86/include/machine/_types.h
index e9280a5..65892a1 100644
--- a/ndk/platforms/android-9/arch-x86/include/machine/_types.h
+++ b/ndk/platforms/android-9/arch-x86/include/machine/_types.h
@@ -38,7 +38,7 @@
 /* the kernel defines size_t as unsigned int, but g++ wants it to be unsigned long */
 #ifndef _SIZE_T_DEFINED_
 #  define _SIZE_T_DEFINED_
-#  ifdef ANDROID
+#  ifdef __ANDROID__
      typedef unsigned int  size_t;
 #  else
      typedef unsigned long  size_t;
@@ -51,7 +51,11 @@
 #endif
 #ifndef _PTRDIFF_T
 #define _PTRDIFF_T
-typedef long           ptrdiff_t;
+#  ifdef __ANDROID__
+     typedef int            ptrdiff_t;
+#  else
+     typedef long           ptrdiff_t;
+#  endif
 #endif
 
 #include <linux/types.h>
diff --git a/samples/ApiDemos/res/anim/hyperspace_out.xml b/samples/ApiDemos/res/anim/hyperspace_out.xml
index 83fef33..542fa05 100644
--- a/samples/ApiDemos/res/anim/hyperspace_out.xml
+++ b/samples/ApiDemos/res/anim/hyperspace_out.xml
@@ -16,39 +16,46 @@
 
 <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false">
 
-	<scale 
-		android:interpolator="@android:anim/accelerate_decelerate_interpolator"
-		android:fromXScale="1.0" 
-		android:toXScale="1.4" 
-		android:fromYScale="1.0" 
-		android:toYScale="0.6" 
-		android:pivotX="50%"
-		android:pivotY="50%"
-		android:fillAfter="false"
-		android:duration="700" />
+    <scale 
+        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
+        android:fromXScale="1.0" 
+        android:toXScale="1.4" 
+        android:fromYScale="1.0" 
+        android:toYScale="0.6" 
+        android:pivotX="50%"
+        android:pivotY="50%"
+        android:fillEnabled="true"
+        android:fillAfter="false"
+        android:duration="700" />
 
 
-	<set 
-		android:interpolator="@android:anim/accelerate_interpolator"
-                android:startOffset="700">
-		
-		<scale
-			android:fromXScale="1.4" 
-			android:toXScale="0.0"
-		        android:fromYScale="0.6"
-	 		android:toYScale="0.0" 
-	 		android:pivotX="50%" 
-	 		android:pivotY="50%" 
-	 		android:duration="400" />
- 		
-		<rotate 
-			android:fromDegrees="0" 
-			android:toDegrees="-45"
-	 		android:toYScale="0.0" 
-	 		android:pivotX="50%" 
-	 		android:pivotY="50%"
-	 		android:duration="400" />
-	</set>
+    <set android:interpolator="@android:anim/accelerate_interpolator">
+        
+        <scale
+            android:fromXScale="1.4" 
+            android:toXScale="0.0"
+            android:fromYScale="0.6"
+            android:toYScale="0.0"
+            android:pivotX="50%"
+            android:pivotY="50%"
+            android:fillEnabled="true"
+            android:fillBefore="false"
+            android:fillAfter="true"
+            android:startOffset="700"
+            android:duration="400" />
+         
+        <rotate 
+            android:fromDegrees="0" 
+            android:toDegrees="-45"
+            android:toYScale="0.0"
+            android:pivotX="50%"
+            android:pivotY="50%"
+            android:fillEnabled="true"
+            android:fillBefore="false"
+            android:fillAfter="true"
+            android:startOffset="700"
+            android:duration="400" />
+    </set>
 
 </set>
 
diff --git a/samples/VoicemailProviderDemo/AndroidManifest.xml b/samples/VoicemailProviderDemo/AndroidManifest.xml
index e1a3404..558dbf7 100644
--- a/samples/VoicemailProviderDemo/AndroidManifest.xml
+++ b/samples/VoicemailProviderDemo/AndroidManifest.xml
@@ -26,7 +26,7 @@
     <uses-sdk android:minSdkVersion="13"
               android:targetSdkVersion="13" />
 
-    <uses-permission android:name="com.android.voicemail.permission.READ_WRITE_OWN_VOICEMAIL" />
+    <uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL" />
     <uses-permission android:name="android.permission.RECORD_AUDIO" />
 
     <application android:icon="@drawable/icon" android:label="@string/app_name">
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/provider/VoicemailContract.java b/samples/VoicemailProviderDemo/src/com/example/android/provider/VoicemailContract.java
deleted file mode 100644
index 3fe6cc8..0000000
--- a/samples/VoicemailProviderDemo/src/com/example/android/provider/VoicemailContract.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-package com.example.android.provider;
-
-// This is a COPY of the voicemail provider contract file checked in at
-// framework/base/core/java/android/provider. The API is currently hidden so
-// it is not available through the SDK and hence is not available to the sample
-// code.
-// TODO: get rid of this copy once the voicemail provider API is opened ups.
-
-import android.content.Intent;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.provider.BaseColumns;
-import android.provider.CallLog.Calls;
-
-/**
- * The contract between the voicemail provider and applications. Contains
- * definitions for the supported URIs and columns.
- *
- * <P>Voicemails are inserted by what is called as a "voicemail source"
- * application, which is responsible for syncing voicemail data between a remote
- * server and the local voicemail content provider. "voicemail source"
- * application should use the source specific {@link #CONTENT_URI_SOURCE} URI
- * to insert and retrieve voicemails.
- *
- * <P>In addition to the {@link ContentObserver} notifications the voicemail
- * provider also generates broadcast intents to notify change for applications
- * that are not active and therefore cannot listen to ContentObserver
- * notifications. Broadcast intents with following actions are generated:
- * <ul>
- *   <li> {@link #ACTION_NEW_VOICEMAIL} is generated for each new voicemail
- *   inserted.
- *   </li>
- *   <li> {@link Intent#ACTION_PROVIDER_CHANGED} is generated for any change
- *    made into the database, including new voicemail.
- *   </li>
- * </ul>
- * @hide
- */
-// TODO: unhide when the API is approved by android-api-council
-public class VoicemailContract {
-    /** Not instantiable. */
-    private VoicemailContract() {
-    }
-
-    /** The authority used by the voicemail provider. */
-    public static final String AUTHORITY = "com.android.voicemail";
-    /**
-     * URI to insert/retrieve all voicemails.
-     * @deprecated
-     */
-    public static final Uri CONTENT_URI =
-            Uri.parse("content://" + AUTHORITY + "/voicemail");
-    /**
-     * URI to insert/retrieve voicemails by a given voicemail source.
-     * @deprecated
-     */
-    public static final Uri CONTENT_URI_SOURCE =
-            Uri.parse("content://" + AUTHORITY + "/voicemail/source/");
-    /**
-     * Parameter key used in the URI to specify the voicemail source package name.
-     * <p> This field must be set in all requests that originate from a voicemail source.
-     */
-    public static final String PARAM_KEY_SOURCE_PACKAGE = "source_package";
-
-    // TODO: Move ACTION_NEW_VOICEMAIL to the Intent class.
-    /** Broadcast intent when a new voicemail record is inserted. */
-    public static final String ACTION_NEW_VOICEMAIL = "android.intent.action.NEW_VOICEMAIL";
-    /**
-     * Extra included in {@value Intent#ACTION_PROVIDER_CHANGED} and
-     * {@value #ACTION_NEW_VOICEMAIL} broadcast intents to indicate if the receiving
-     * package made this change.
-     */
-    public static final String EXTRA_SELF_CHANGE = "com.android.voicemail.extra.SELF_CHANGE";
-
-    /**
-     * The mime type for a collection of voicemails.
-     * @deprecated */
-    public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemails";
-
-    /** Defines fields exposed through the /voicemail path of this content provider. */
-    public static final class Voicemails implements BaseColumns {
-        /** Not instantiable. */
-        private Voicemails() {
-        }
-
-        /** URI to insert/retrieve voicemails by a given voicemail source. */
-        public static final Uri CONTENT_URI =
-            Uri.parse("content://" + AUTHORITY + "/voicemail");
-        /** URI to insert/retrieve voicemails by a given voicemail source. */
-        public static final Uri CONTENT_URI_SOURCE =
-                Uri.parse("content://" + AUTHORITY + "/voicemail/source/");
-
-        /** The mime type for a collection of voicemails. */
-        public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemails";
-
-        /**
-         * Phone number of the voicemail sender.
-         * <P>Type: TEXT</P>
-         */
-        public static final String NUMBER = Calls.NUMBER;
-        /**
-         * The date the voicemail was sent, in milliseconds since the epoch
-         * <P>Type: INTEGER (long)</P>
-         */
-        public static final String DATE = Calls.DATE;
-        /**
-         * The duration of the voicemail in seconds.
-         * <P>Type: INTEGER (long)</P>
-         */
-        public static final String DURATION = Calls.DURATION;
-        /**
-         * Whether this is a new voicemail (i.e. has not been heard).
-         * <P>Type: INTEGER (boolean)</P>
-         */
-        public static final String NEW = Calls.NEW;
-        /**
-         * The mail box state of the voicemail.
-         * <P> Possible values: {@link #STATE_INBOX}, {@link #STATE_DELETED},
-         * {@link #STATE_UNDELETED}.
-         * <P>Type: INTEGER</P>
-         */
-        public static final String STATE = "state";
-        /** Value of {@link #STATE} when the voicemail is in inbox. */
-        public static int STATE_INBOX = 0;
-        /** Value of {@link #STATE} when the voicemail has been marked as deleted. */
-        public static int STATE_DELETED = 1;
-        /** Value of {@link #STATE} when the voicemail has marked as undeleted. */
-        public static int STATE_UNDELETED = 2;
-        /**
-         * Package name of the source application that inserted the voicemail.
-         * <P>Type: TEXT</P>
-         */
-        public static final String SOURCE_PACKAGE = "source_package";
-        /**
-         * Application-specific data available to the source application that
-         * inserted the voicemail. This is typically used to store the source
-         * specific message id to identify this voicemail on the remote
-         * voicemail server.
-         * <P>Type: TEXT</P>
-         * <P> Note that this is NOT the voicemail media content data.
-         */
-        public static final String SOURCE_DATA = "source_data";
-        /**
-         * Whether the media content for this voicemail is available for
-         * consumption.
-         * <P>Type: INTEGER (boolean)</P>
-         */
-        public static final String HAS_CONTENT = "has_content";
-        /**
-         * MIME type of the media content for the voicemail.
-         * <P>Type: TEXT</P>
-         */
-        public static final String MIME_TYPE = "mime_type";
-        /**
-         * Path to the media content file. Internal only field.
-         * @hide
-         */
-        public static final String _DATA = "_data";
-
-        /**
-         * A convenience method to build voicemail URI specific to a source package by appending
-         * {@link VoicemailContract#PARAM_KEY_SOURCE_PACKAGE} param to the base URI.
-         */
-        public static Uri buildSourceUri(String packageName) {
-            return Voicemails.CONTENT_URI.buildUpon()
-                    .appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName).build();
-        }
-    }
-
-    /** Defines fields exposed through the /status path of this content provider. */
-    public static final class Status implements BaseColumns {
-        /** URI to insert/retrieve status of voicemail source. */
-        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/status");
-        /** The mime type for a collection of voicemail source statuses. */
-        public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemail.source.status";
-        /** The mime type for a collection of voicemails. */
-        public static final String ITEM_TYPE = "vnd.android.cursor.item/voicemail.source.status";
-
-        /** Not instantiable. */
-        private Status() {
-        }
-        /**
-         * The package name of the voicemail source. There can only be a one entry per source.
-         * <P>Type: TEXT</P>
-         */
-        public static final String SOURCE_PACKAGE = "source_package";
-        /**
-         * The URI to call to invoke source specific voicemail settings screen. On a user request
-         * to setup voicemail an intent with action VIEW with this URI will be fired by the system.
-         * <P>Type: TEXT</P>
-         */
-        public static final String SETTINGS_URI = "settings_uri";
-        /**
-         * The URI to call when the user requests to directly access the voicemail from the remote
-         * server. In case of an IVR voicemail system this is typically set to the the voicemail
-         * number specified using a tel:/ URI.
-         * <P>Type: TEXT</P>
-         */
-        public static final String VOICEMAIL_ACCESS_URI = "voicemail_access_uri";
-        /**
-         * The configuration state of the voicemail source.
-         * <P> Possible values:
-         * {@link #CONFIGURATION_STATE_OK},
-         * {@link #CONFIGURATION_STATE_NOT_CONFIGURED},
-         * {@link #CONFIGURATION_STATE_CAN_BE_CONFIGURED}
-         * <P>Type: INTEGER</P>
-         */
-        public static final String CONFIGURATION_STATE = "configuration_state";
-        public static final int CONFIGURATION_STATE_OK = 0;
-        public static final int CONFIGURATION_STATE_NOT_CONFIGURED = 1;
-        /**
-         * This state must be used when the source has verified that the current user can be
-         * upgraded to visual voicemail and would like to show a set up invitation message.
-         */
-        public static final int CONFIGURATION_STATE_CAN_BE_CONFIGURED = 2;
-        /**
-         * The data channel state of the voicemail source. This the channel through which the source
-         * pulls voicemail data from a remote server.
-         * <P> Possible values:
-         * {@link #DATA_CHANNEL_STATE_OK},
-         * {@link #DATA_CHANNEL_STATE_NO_CONNECTION}
-         * </P>
-         * <P>Type: INTEGER</P>
-         */
-        public static final String DATA_CHANNEL_STATE = "data_channel_state";
-        public static final int DATA_CHANNEL_STATE_OK = 0;
-        public static final int DATA_CHANNEL_STATE_NO_CONNECTION = 1;
-        /**
-         * The notification channel state of the voicemail source. This is the channel through which
-         * the source gets notified of new voicemails on the remote server.
-         * <P> Possible values:
-         * {@link #NOTIFICATION_CHANNEL_STATE_OK},
-         * {@link #NOTIFICATION_CHANNEL_STATE_NO_CONNECTION},
-         * {@link #NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING}
-         * </P>
-         * <P>Type: INTEGER</P>
-         */
-        public static final String NOTIFICATION_CHANNEL_STATE = "notification_channel_state";
-        public static final int NOTIFICATION_CHANNEL_STATE_OK = 0;
-        public static final int NOTIFICATION_CHANNEL_STATE_NO_CONNECTION = 1;
-        /**
-         * Use this state when the notification can only tell that there are pending messages on
-         * the server but no details of the sender/time etc are known.
-         */
-        public static final int NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING = 2;
-
-        /**
-         * A convenience method to build status URI specific to a source package by appending
-         * {@link VoicemailContract#PARAM_KEY_SOURCE_PACKAGE} param to the base URI.
-         */
-        public static Uri buildSourceUri(String packageName) {
-            return Status.CONTENT_URI.buildUpon()
-                    .appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName).build();
-        }
-    }
-}
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java
index c2a34ae..121840a 100644
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java
+++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java
@@ -16,6 +16,16 @@
 
 package com.example.android.voicemail;
 
+import com.example.android.voicemail.common.core.Voicemail;
+import com.example.android.voicemail.common.core.VoicemailImpl;
+import com.example.android.voicemail.common.core.VoicemailProviderHelper;
+import com.example.android.voicemail.common.core.VoicemailProviderHelpers;
+import com.example.android.voicemail.common.inject.InjectView;
+import com.example.android.voicemail.common.inject.Injector;
+import com.example.android.voicemail.common.logging.Logger;
+import com.example.android.voicemail.common.ui.DialogHelperImpl;
+import com.example.android.voicemail.common.utils.CloseUtils;
+
 import android.app.Activity;
 import android.app.Dialog;
 import android.content.Intent;
@@ -28,16 +38,6 @@
 import android.widget.Button;
 import android.widget.TextView;
 
-import com.example.android.voicemail.common.core.Voicemail;
-import com.example.android.voicemail.common.core.VoicemailImpl;
-import com.example.android.voicemail.common.core.VoicemailProviderHelper;
-import com.example.android.voicemail.common.core.VoicemailProviderHelpers;
-import com.example.android.voicemail.common.inject.InjectView;
-import com.example.android.voicemail.common.inject.Injector;
-import com.example.android.voicemail.common.logging.Logger;
-import com.example.android.voicemail.common.ui.DialogHelperImpl;
-import com.example.android.voicemail.common.utils.CloseUtils;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -131,7 +131,6 @@
         return VoicemailImpl.createForInsertion(time, sender)
                 .setDuration(duration)
                 .setSourcePackage(sourcePackageName)
-                .setMailbox(Voicemail.Mailbox.INBOX)
                 .build();
     }
 
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java
index 17f03c7..dc451cb 100644
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java
+++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java
@@ -16,8 +16,6 @@
 
 package com.example.android.voicemail.common.core;
 
-import com.example.android.provider.VoicemailContract;
-
 import android.net.Uri;
 
 /**
@@ -27,41 +25,6 @@
  */
 public interface Voicemail {
     /**
-     * Which mailbox the message is sitting in.
-     * <p>
-     * Note that inbox and deleted are alone insufficient, because we may have a provider that is
-     * not able to undelete (re-upload) a message. Thus we need a state to represent the (common)
-     * case where the user has deleted a message (which results in the message being removed from
-     * the server) and then restored the message (where we are unable to re-upload the message to
-     * the server). That's what the undeleted state is for.
-     * <p>
-     * The presence of an undeleted mailbox prevents the voicemail source from having to keep a list
-     * of all such deleted-then-restored message ids, without which it would be unable to tell the
-     * difference between a message that has been deleted-then-restored by the user and a message
-     * which has been deleted on the server and should now be removed (for example one removed via
-     * an IVR).
-     */
-    public enum Mailbox {
-        /** After being fetched from the server, a message usually starts in the inbox. */
-        INBOX(VoicemailContract.Voicemails.STATE_INBOX),
-        /** Indicates that a message has been deleted. */
-        DELETED(VoicemailContract.Voicemails.STATE_DELETED),
-        /** Restored from having been deleted, distinct from being in the inbox. */
-        UNDELETED(VoicemailContract.Voicemails.STATE_UNDELETED);
-
-        private final int mValue;
-
-        private Mailbox(int value) {
-            mValue = value;
-        }
-
-        /** Returns the DB value of this mailbox state. */
-        public int getValue() {
-            return mValue;
-        }
-    }
-
-    /**
      * The identifier of the voicemail in the content provider.
      * <p>
      * This may be missing in the case of a new {@link Voicemail} that we plan to insert into the
@@ -116,11 +79,6 @@
 
     public boolean hasUri();
 
-    /** Tells us which mailbox the message is sitting in, returns null if this is not set. */
-    public Voicemail.Mailbox getMailbox();
-
-    public boolean hasMailbox();
-
     /**
      * Tells us if the voicemail message has been marked as read.
      * <p>
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java
index b3eab91..5f2e0cd 100644
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java
+++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java
@@ -20,9 +20,7 @@
 import static com.example.android.voicemail.common.utils.DbQueryUtils.concatenateClausesWithOr;
 import static com.example.android.voicemail.common.utils.DbQueryUtils.getEqualityClause;
 
-import com.example.android.voicemail.common.core.Voicemail.Mailbox;
-import com.example.android.provider.VoicemailContract.Voicemails;
-
+import android.provider.VoicemailContract.Voicemails;
 import android.text.TextUtils;
 
 import java.util.ArrayList;
@@ -31,8 +29,8 @@
 /**
  * Factory class to create {@link VoicemailFilter} objects for various filtering needs.
  * <p>
- * Factory methods like {@link #createWithMailbox(Mailbox)}, {@link #createWithReadStatus(boolean)}
- * and {@link #createWithMatchingFields(Voicemail)} can be used to create a voicemail filter that
+ * Factory methods like {@link #createWithReadStatus(boolean)} and
+ * {@link #createWithMatchingFields(Voicemail)} can be used to create a voicemail filter that
  * matches the value of the specific field.
  * <p>
  * It is possible to combine multiple filters with OR or AND operation using the methods
@@ -44,13 +42,6 @@
  * content provider database and is therefore less recommended.
  */
 public class VoicemailFilterFactory {
-    /** Predefined filter for inbox only messages. */
-    public static final VoicemailFilter INBOX_MESSAGES_FILTER = createWithOrOf(
-            createWithMailbox(Mailbox.INBOX), createWithMailbox(Mailbox.UNDELETED));
-    /** Predefined filter for trashed messages. */
-    public static final VoicemailFilter TRASHED_MESSAGES_FILTER =
-            createWithMailbox(Mailbox.DELETED);
-
     /**
      * Creates a voicemail filter with the specified where clause. Use this method only if you know
      * and want to directly use the column names of the content provider. For most of the usages
@@ -78,12 +69,6 @@
                 getWhereClauseForMatchingFields(fieldMatch));
     }
 
-    /** Creates a voicemail filter with the specified mailbox state. */
-    public static VoicemailFilter createWithMailbox(Mailbox mailbox) {
-        return createWithMatchingFields(
-                VoicemailImpl.createEmptyBuilder().setMailbox(mailbox).build());
-    }
-
     /** Creates a voicemail filter with the specified read status. */
     public static VoicemailFilter createWithReadStatus(boolean isRead) {
         return createWithMatchingFields(
@@ -111,11 +96,7 @@
     private static String getWhereClauseForMatchingFields(Voicemail fieldMatch) {
         List<String> clauses = new ArrayList<String>();
         if (fieldMatch.hasRead()) {
-            clauses.add(getEqualityClause(Voicemails.NEW, fieldMatch.isRead() ? "1" : "0"));
-        }
-        if (fieldMatch.hasMailbox()) {
-            clauses.add(getEqualityClause(Voicemails.STATE,
-                    Integer.toString(fieldMatch.getMailbox().getValue())));
+            clauses.add(getEqualityClause(Voicemails.IS_READ, fieldMatch.isRead() ? "1" : "0"));
         }
         if (fieldMatch.hasNumber()) {
             clauses.add(getEqualityClause(Voicemails.NUMBER, fieldMatch.getNumber()));
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailImpl.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailImpl.java
index 9e08b68..491302b 100644
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailImpl.java
+++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailImpl.java
@@ -29,7 +29,6 @@
     private final String mSource;
     private final String mProviderData;
     private final Uri mUri;
-    private final Voicemail.Mailbox mMailbox;
     private final Boolean mIsRead;
     private final boolean mHasContent;
 
@@ -44,7 +43,6 @@
             String source,
             String providerData,
             Uri uri,
-            Voicemail.Mailbox mailbox,
             Boolean isRead,
             boolean hasContent) {
         mId = id;
@@ -54,7 +52,6 @@
         mSource = source;
         mProviderData = providerData;
         mUri = uri;
-        mMailbox = mailbox;
         mIsRead = isRead;
         mHasContent = hasContent;
     }
@@ -100,7 +97,6 @@
         private String mBuilderSourcePackage;
         private String mBuilderSourceData;
         private Uri mBuilderUri;
-        private Voicemail.Mailbox mBuilderMailbox;
         private Boolean mBuilderIsRead;
         private boolean mBuilderHasContent;
 
@@ -143,11 +139,6 @@
             return this;
         }
 
-        public Builder setMailbox(Voicemail.Mailbox mailbox) {
-            mBuilderMailbox = mailbox;
-            return this;
-        }
-
         public Builder setIsRead(boolean isRead) {
             mBuilderIsRead = isRead;
             return this;
@@ -161,7 +152,7 @@
         public VoicemailImpl build() {
             return new VoicemailImpl(mBuilderTimestamp, mBuilderNumber, mBuilderId,
                     mBuilderDuration,
-                    mBuilderSourcePackage, mBuilderSourceData, mBuilderUri, mBuilderMailbox,
+                    mBuilderSourcePackage, mBuilderSourceData, mBuilderUri,
                     mBuilderIsRead,
                     mBuilderHasContent);
         }
@@ -238,16 +229,6 @@
     }
 
     @Override
-    public Mailbox getMailbox() {
-        return mMailbox;
-    }
-
-    @Override
-    public boolean hasMailbox() {
-        return mMailbox != null;
-    }
-
-    @Override
     public boolean isRead() {
         return hasRead() ? mIsRead : false;
     }
@@ -266,7 +247,7 @@
     public String toString() {
         return "VoicemailImpl [mTimestamp=" + mTimestamp + ", mNumber=" + mNumber + ", mId=" + mId
                 + ", mDuration=" + mDuration + ", mSource=" + mSource + ", mProviderData="
-                + mProviderData + ", mUri=" + mUri + ", mMailbox=" + mMailbox + ", mIsRead="
-                + mIsRead + ", mHasContent=" + mHasContent + "]";
+                + mProviderData + ", mUri=" + mUri + ", mIsRead=" + mIsRead + ", mHasContent="
+                + mHasContent + "]";
     }
 }
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelper.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelper.java
index d3ff514..9cb6a3b 100644
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelper.java
+++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelper.java
@@ -16,7 +16,7 @@
 
 package com.example.android.voicemail.common.core;
 
-import com.example.android.provider.VoicemailContract;
+import android.provider.VoicemailContract;
 
 import android.net.Uri;
 
diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelpers.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelpers.java
index 2d8d9bc..1840462 100644
--- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelpers.java
+++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelpers.java
@@ -16,7 +16,6 @@
 
 package com.example.android.voicemail.common.core;
 
-import com.example.android.provider.VoicemailContract.Voicemails;
 import com.example.android.voicemail.common.logging.Logger;
 import com.example.android.voicemail.common.utils.CloseUtils;
 import com.example.android.voicemail.common.utils.DbQueryUtils;
@@ -27,6 +26,8 @@
 import android.content.Context;
 import android.database.Cursor;
 import android.net.Uri;
+import android.provider.VoicemailContract;
+import android.provider.VoicemailContract.Voicemails;
 
 import java.io.IOException;
 import java.io.OutputStream;
@@ -48,8 +49,7 @@
             Voicemails.DATE,
             Voicemails.SOURCE_PACKAGE,
             Voicemails.SOURCE_DATA,
-            Voicemails.NEW,
-            Voicemails.STATE
+            Voicemails.IS_READ
     };
 
     private final ContentResolver mContentResolver;
@@ -98,6 +98,10 @@
         check(voicemail.hasNumber(), "Inserted voicemails must have a number", voicemail);
         logger.d(String.format("Inserting new voicemail: %s", voicemail));
         ContentValues contentValues = getContentValues(voicemail);
+        if (!voicemail.hasRead()) {
+            // If is_read is not set then set it to false as default value.
+            contentValues.put(Voicemails.IS_READ, 0);
+        }
         return mContentResolver.insert(mBaseUri, contentValues);
     }
 
@@ -250,9 +254,7 @@
                 .setUri(buildUriWithSourcePackage(id, sourcePackage))
                 .setHasContent(cursor.getInt(
                         cursor.getColumnIndexOrThrow(Voicemails.HAS_CONTENT)) == 1)
-                .setIsRead(cursor.getInt(cursor.getColumnIndexOrThrow(Voicemails.NEW)) == 1)
-                .setMailbox(mapValueToMailBoxEnum(cursor.getInt(
-                        cursor.getColumnIndexOrThrow(Voicemails.STATE))))
+                .setIsRead(cursor.getInt(cursor.getColumnIndexOrThrow(Voicemails.IS_READ)) == 1)
                 .build();
         return voicemail;
     }
@@ -261,15 +263,6 @@
         return ContentUris.withAppendedId(Voicemails.buildSourceUri(sourcePackage), id);
     }
 
-    private Voicemail.Mailbox mapValueToMailBoxEnum(int value) {
-        for (Voicemail.Mailbox mailbox : Voicemail.Mailbox.values()) {
-            if (mailbox.getValue() == value) {
-                return mailbox;
-            }
-        }
-        throw new IllegalArgumentException("Value: " + value + " not valid for Voicemail.Mailbox.");
-    }
-
     /**
      * Maps structured {@link Voicemail} to {@link ContentValues} understood by content provider.
      */
@@ -291,10 +284,7 @@
             contentValues.put(Voicemails.SOURCE_DATA, voicemail.getSourceData());
         }
         if (voicemail.hasRead()) {
-            contentValues.put(Voicemails.NEW, voicemail.isRead() ? 1 : 0);
-        }
-        if (voicemail.hasMailbox()) {
-            contentValues.put(Voicemails.STATE, voicemail.getMailbox().getValue());
+            contentValues.put(Voicemails.IS_READ, voicemail.isRead() ? 1 : 0);
         }
         return contentValues;
     }
diff --git a/tools/emulator/opengl/host/include/libOpenglRender/render_api.h b/tools/emulator/opengl/host/include/libOpenglRender/render_api.h
index fa56316..324ae1f 100644
--- a/tools/emulator/opengl/host/include/libOpenglRender/render_api.h
+++ b/tools/emulator/opengl/host/include/libOpenglRender/render_api.h
@@ -16,7 +16,10 @@
 #ifndef _OPENGL_RENDERER_RENDER_API_H
 #define _OPENGL_RENDERER_RENDER_API_H
 
-#include "IOStream.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "render_api_platform_types.h"
 
 //
@@ -41,14 +44,8 @@
 //
 bool stopOpenGLRenderer();
 
-//
-// createRenderThread - opens a new communication channel to the renderer
-//   process and creates new rendering thread.
-//   returns a pointer to IOStream through which command tokens are being sent
-//   to the render thread for execution. 'p_stream_buffer_size' is the internal
-//   stream buffer size.
-//   The thread is destroyed when deleting the IOStream object.
-//
-IOStream *createRenderThread(int p_stream_buffer_size);
+#ifdef __cplusplus
+}
+#endif
 
 #endif
diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/render_api.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/render_api.cpp
index a9237af..c471981 100644
--- a/tools/emulator/opengl/host/libs/libOpenglRender/render_api.cpp
+++ b/tools/emulator/opengl/host/libs/libOpenglRender/render_api.cpp
@@ -14,6 +14,7 @@
 * limitations under the License.
 */
 #include "libOpenglRender/render_api.h"
+#include "IOStream.h"
 #include "FrameBuffer.h"
 #include "RenderServer.h"
 #include "osProcess.h"
@@ -23,6 +24,8 @@
 static RenderServer *s_renderThread = NULL;
 static int s_renderPort = 0;
 
+static IOStream *createRenderThread(int p_stream_buffer_size);
+
 #ifdef __APPLE__
 #define  RENDER_API_USE_THREAD
 #endif