Merge "Move TransactionSafeActivity into Contacts common."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5e0e63f..baa14fc 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -15,8 +15,7 @@
 -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.android.dialer"
-    android:sharedUserId="android.uid.shared">
+    package="com.android.dialer">
 
     <uses-permission android:name="android.permission.CALL_PRIVILEGED" />
     <uses-permission android:name="android.permission.READ_CONTACTS" />
@@ -57,57 +56,6 @@
         android:hardwareAccelerated="true"
     >
 
-        <!-- Intercept Dialer Intents for devices without a phone.
-        This activity should have the same intent filters as the DialtactsActivity,
-        so that its capturing the same events. Omit android.intent.category.LAUNCHER, because we
-        don't want this to show up in the Launcher. The priorities of the intent-filters
-        are set lower, so that the user does not see a disambig dialog -->
-        <activity
-            android:name=".NonPhoneActivity"
-            android:theme="@style/NonPhoneActivityTheme"
-        >
-            <intent-filter android:priority="-1">
-                <action android:name="android.intent.action.DIAL" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.BROWSABLE" />
-                <data android:mimeType="vnd.android.cursor.item/phone" />
-                <data android:mimeType="vnd.android.cursor.item/person" />
-            </intent-filter>
-            <intent-filter android:priority="-1">
-                <action android:name="android.intent.action.DIAL" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.BROWSABLE" />
-                <data android:scheme="voicemail" />
-            </intent-filter>
-            <intent-filter android:priority="-1">
-                <action android:name="android.intent.action.DIAL" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-            <intent-filter android:priority="-1">
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.BROWSABLE" />
-            </intent-filter>
-            <intent-filter android:priority="-1">
-                <action android:name="android.intent.action.VIEW" />
-                <action android:name="android.intent.action.DIAL" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.BROWSABLE" />
-                <data android:scheme="tel" />
-            </intent-filter>
-            <intent-filter android:priority="-1">
-                <action android:name="android.intent.action.VIEW" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.BROWSABLE" />
-                <data android:mimeType="vnd.android.cursor.dir/calls" />
-            </intent-filter>
-            <intent-filter android:priority="-1">
-                <action android:name="android.intent.action.CALL_BUTTON" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.BROWSABLE" />
-            </intent-filter>
-        </activity>
-
         <!-- The entrance point for Phone UI.
              stateAlwaysHidden is set to suppress keyboard show up on
              dialpad screen. -->
@@ -234,16 +182,5 @@
             android:name=".calllog.CallLogNotificationsService"
             android:exported="false"
         />
-
-        <!-- Service that is exclusively for the Phone application that sends out a view
-             notification. This service might be removed in future versions of the app  -->
-        <service android:name=".ViewNotificationService"
-            android:permission="android.permission.WRITE_CONTACTS"
-            android:exported="true">
-            <intent-filter>
-                <action android:name="com.android.contacts.VIEW_NOTIFICATION" />
-                <data android:mimeType="vnd.android.cursor.item/contact" />
-            </intent-filter>
-        </service>
     </application>
 </manifest>
diff --git a/src/com/android/dialer/NonPhoneActivity.java b/src/com/android/dialer/NonPhoneActivity.java
deleted file mode 100644
index 78196a3..0000000
--- a/src/com/android/dialer/NonPhoneActivity.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2010 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.android.dialer;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.provider.ContactsContract.Contacts;
-import android.provider.ContactsContract.Intents.Insert;
-import android.text.TextUtils;
-
-import com.android.contacts.common.CallUtil;
-import com.android.contacts.ContactsActivity;
-
-/**
- * Activity that intercepts DIAL and VIEW intents for phone numbers for devices that can not
- * be used as a phone. This allows the user to see the phone number
- */
-public class NonPhoneActivity extends ContactsActivity {
-
-    private static final String PHONE_NUMBER_KEY = "PHONE_NUMBER";
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        final String phoneNumber = getPhoneNumber();
-        if (TextUtils.isEmpty(phoneNumber)) {
-            finish();
-            return;
-        }
-
-        final NonPhoneDialogFragment fragment = new NonPhoneDialogFragment();
-        Bundle bundle = new Bundle();
-        bundle.putString(PHONE_NUMBER_KEY, phoneNumber);
-        fragment.setArguments(bundle);
-        getFragmentManager().beginTransaction().add(fragment, "Fragment").commitAllowingStateLoss();
-    }
-
-    private String getPhoneNumber() {
-        if (getIntent() == null) return null;
-        final Uri data = getIntent().getData();
-        if (data == null) return null;
-        final String scheme = data.getScheme();
-        if (!CallUtil.SCHEME_TEL.equals(scheme)) return null;
-        return getIntent().getData().getSchemeSpecificPart();
-    }
-
-    public static final class NonPhoneDialogFragment extends DialogFragment
-            implements OnClickListener {
-        @Override
-        public Dialog onCreateDialog(Bundle savedInstanceState) {
-            final AlertDialog alertDialog;
-            alertDialog = new AlertDialog.Builder(getActivity(), R.style.NonPhoneDialogTheme)
-                    .create();
-            alertDialog.setTitle(R.string.non_phone_caption);
-            alertDialog.setMessage(getArgumentPhoneNumber());
-            alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,
-                    getActivity().getString(R.string.non_phone_add_to_contacts), this);
-            alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
-                    getActivity().getString(R.string.non_phone_close), this);
-            return alertDialog;
-        }
-
-        @Override
-        public void onClick(DialogInterface dialog, int which) {
-            if (which == DialogInterface.BUTTON_POSITIVE) {
-                final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
-                intent.setType(Contacts.CONTENT_ITEM_TYPE);
-                intent.putExtra(Insert.PHONE, getArgumentPhoneNumber());
-                startActivity(intent);
-            }
-            dismiss();
-        }
-
-        private String getArgumentPhoneNumber() {
-            return getArguments().getString(PHONE_NUMBER_KEY);
-        }
-
-        @Override
-        public void onDismiss(DialogInterface dialog) {
-            super.onDismiss(dialog);
-            // During screen rotation, getActivity returns null. In this case we do not
-            // want to close the Activity anyway
-            final Activity activity = getActivity();
-            if (activity != null) activity.finish();
-        }
-    }
-}
diff --git a/src/com/android/dialer/ViewNotificationService.java b/src/com/android/dialer/ViewNotificationService.java
deleted file mode 100644
index 4fdb815..0000000
--- a/src/com/android/dialer/ViewNotificationService.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2012 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.android.dialer;
-
-import android.app.Service;
-import android.content.Intent;
-import android.content.Loader;
-import android.content.Loader.OnLoadCompleteListener;
-import android.os.IBinder;
-import android.util.Log;
-
-import com.android.contacts.model.Contact;
-import com.android.contacts.model.ContactLoader;
-
-
-/**
- * Service that sends out a view notification for a contact. At the moment, this is only
- * supposed to be used by the Phone app
- */
-public class ViewNotificationService extends Service {
-    private static final String TAG = ViewNotificationService.class.getSimpleName();
-
-    private static final boolean DEBUG = false;
-
-    @Override
-    public int onStartCommand(Intent intent, int flags, final int startId) {
-        if (DEBUG) { Log.d(TAG, "onHandleIntent(). Intent: " + intent); }
-
-        // We simply need to start a Loader here. When its done, it will send out the
-        // View-Notification automatically.
-        final ContactLoader contactLoader = new ContactLoader(this, intent.getData(), true);
-        contactLoader.registerListener(0, new OnLoadCompleteListener<Contact>() {
-            @Override
-            public void onLoadComplete(Loader<Contact> loader, Contact data) {
-                try {
-                    loader.reset();
-                } catch (RuntimeException e) {
-                    Log.e(TAG, "Error reseting loader", e);
-                }
-                try {
-                    // This is not 100% accurate actually. If we get several calls quickly,
-                    // we might be stopping out-of-order, in which case the call with the last
-                    // startId will stop this service. In practice, this shouldn't be a problem,
-                    // as this service is supposed to be called by the Phone app which only sends
-                    // out the notification once per phonecall. And even if there is a problem,
-                    // the worst that should happen is a missing view notification
-                    stopSelfResult(startId);
-                } catch (RuntimeException e) {
-                    Log.e(TAG, "Error stopping service", e);
-                }
-            }
-        });
-        contactLoader.startLoading();
-        return START_REDELIVER_INTENT;
-    }
-
-    @Override
-    public IBinder onBind(Intent intent) {
-        return null;
-    }
-}