summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2015-03-30 20:42:20 +0000
committerMakoto Onuki <omakoto@google.com>2015-03-30 20:42:20 +0000
commit4fd8d4ab2aafe8ed73080408223e8b20a953cfc4 (patch)
tree4a3e854457fce9735c78f1d94cb4855562c71cbc /core/java
parent75a0882b946df6de4775c9e54ca023ff54f3f678 (diff)
downloadframeworks_base-4fd8d4ab2aafe8ed73080408223e8b20a953cfc4.zip
frameworks_base-4fd8d4ab2aafe8ed73080408223e8b20a953cfc4.tar.gz
frameworks_base-4fd8d4ab2aafe8ed73080408223e8b20a953cfc4.tar.bz2
Revert "Enterprise quick contact 1/2"
This reverts commit 75a0882b946df6de4775c9e54ca023ff54f3f678. Change-Id: Ibe332885824b228bf1b1147d141c9395554ff67f
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java16
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl1
-rw-r--r--core/java/android/provider/ContactsContract.java83
-rw-r--r--core/java/android/provider/ContactsInternal.java112
4 files changed, 21 insertions, 191 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index cbb0f51..cf6619f 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -3165,22 +3165,6 @@ public class DevicePolicyManager {
}
/**
- * Start Quick Contact on the managed profile for the current user, if the policy allows.
- * @hide
- */
- public void startManagedQuickContact(String actualLookupKey, long actualContactId,
- Intent originalIntent) {
- if (mService != null) {
- try {
- mService.startManagedQuickContact(
- actualLookupKey, actualContactId, originalIntent);
- } catch (RemoteException e) {
- Log.w(TAG, "Failed talking with device policy service", e);
- }
- }
- }
-
- /**
* Called by the profile owner of a managed profile so that some intents sent in the managed
* profile can also be resolved in the parent, or vice versa.
* Only activity intents are supported.
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 73b0684..9ca52e5 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -189,7 +189,6 @@ interface IDevicePolicyManager {
void setCrossProfileCallerIdDisabled(in ComponentName who, boolean disabled);
boolean getCrossProfileCallerIdDisabled(in ComponentName who);
boolean getCrossProfileCallerIdDisabledForUser(int userId);
- void startManagedQuickContact(String lookupKey, long contactId, in Intent originalIntent);
void setTrustAgentConfiguration(in ComponentName admin, in ComponentName agent,
in PersistableBundle args);
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 6592295..e4a6f07 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -18,7 +18,6 @@ package android.provider;
import android.accounts.Account;
import android.app.Activity;
-import android.app.admin.DevicePolicyManager;
import android.content.ActivityNotFoundException;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
@@ -1629,6 +1628,7 @@ public final class ContactsContract {
*/
public static final String CONTENT_VCARD_TYPE = "text/x-vcard";
+
/**
* Mimimal ID for corp contacts returned from
* {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
@@ -1638,14 +1638,6 @@ public final class ContactsContract {
public static long ENTERPRISE_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30
/**
- * Prefix for corp contacts returned from
- * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
- *
- * @hide
- */
- public static String ENTERPRISE_CONTACT_LOOKUP_PREFIX = "c-";
-
- /**
* Return TRUE if a contact ID is from the contacts provider on the enterprise profile.
*
* {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact.
@@ -5040,16 +5032,9 @@ public final class ContactsContract {
* is from the corp profile, use
* {@link ContactsContract.Contacts#isEnterpriseContactId(long)}.
* </li>
- * <li>
- * Corp contacts will get artificial {@link #LOOKUP_KEY}s too.
- * </li>
* </ul>
* <p>
- * A contact lookup URL built by {@link Contacts#getLookupUri(long, String)}
- * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to
- * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the
- * corp profile.
- * </p>
+ * This URI does NOT support selection nor order-by.
*
* <pre>
* Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI,
@@ -6040,17 +6025,10 @@ public final class ContactsContract {
* a contact
* is from the corp profile, use
* {@link ContactsContract.Contacts#isEnterpriseContactId(long)}.
- * </li>
- * <li>
- * Corp contacts will get artificial {@link #LOOKUP_KEY}s too.
- * </li>
- * </ul>
- * <p>
- * A contact lookup URL built by {@link Contacts#getLookupUri(long, String)}
- * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to
- * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the
- * corp profile.
- * </p>
+ * </li>
+ * </ul>
+ * <p>
+ * This URI does NOT support selection nor order-by.
*
* <pre>
* Uri lookupUri = Uri.withAppendedPath(Email.ENTERPRISE_CONTENT_LOOKUP_URI,
@@ -8204,9 +8182,6 @@ public final class ContactsContract {
*/
public static final int MODE_LARGE = 3;
- /** @hide */
- public static final int MODE_DEFAULT = MODE_LARGE;
-
/**
* Constructs the QuickContacts intent with a view's rect.
* @hide
@@ -8249,7 +8224,6 @@ public final class ContactsContract {
// Launch pivot dialog through intent for now
final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags);
- // NOTE: This logic and rebuildManagedQuickContactsIntent() must be in sync.
intent.setData(lookupUri);
intent.setSourceBounds(target);
intent.putExtra(EXTRA_MODE, mode);
@@ -8258,30 +8232,6 @@ public final class ContactsContract {
}
/**
- * Constructs a QuickContacts intent based on an incoming intent for DevicePolicyManager
- * to strip off anything not necessary.
- *
- * @hide
- */
- public static Intent rebuildManagedQuickContactsIntent(String lookupKey, long contactId,
- Intent originalIntent) {
- final Intent intent = new Intent(ACTION_QUICK_CONTACT);
- // Rebuild the URI from a lookup key and a contact ID.
- intent.setData(Contacts.getLookupUri(contactId, lookupKey));
-
- // Copy flags and always set NEW_TASK because it won't have a parent activity.
- intent.setFlags(originalIntent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
-
- // Copy extras.
- intent.setSourceBounds(originalIntent.getSourceBounds());
- intent.putExtra(EXTRA_MODE, originalIntent.getIntExtra(EXTRA_MODE, MODE_DEFAULT));
- intent.putExtra(EXTRA_EXCLUDE_MIMES,
- originalIntent.getStringArrayExtra(EXTRA_EXCLUDE_MIMES));
- return intent;
- }
-
-
- /**
* Trigger a dialog that lists the various methods of interacting with
* the requested {@link Contacts} entry. This may be based on available
* {@link ContactsContract.Data} rows under that contact, and may also
@@ -8309,7 +8259,7 @@ public final class ContactsContract {
// Trigger with obtained rectangle
Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
excludeMimes);
- ContactsInternal.startQuickContactWithErrorToast(context, intent);
+ startActivityWithErrorToast(context, intent);
}
/**
@@ -8342,7 +8292,7 @@ public final class ContactsContract {
String[] excludeMimes) {
Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
excludeMimes);
- ContactsInternal.startQuickContactWithErrorToast(context, intent);
+ startActivityWithErrorToast(context, intent);
}
/**
@@ -8375,10 +8325,10 @@ public final class ContactsContract {
// Use MODE_LARGE instead of accepting mode as a parameter. The different mode
// values defined in ContactsContract only affect very old implementations
// of QuickContacts.
- Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT,
+ Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_LARGE,
excludeMimes);
intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType);
- ContactsInternal.startQuickContactWithErrorToast(context, intent);
+ startActivityWithErrorToast(context, intent);
}
/**
@@ -8413,10 +8363,19 @@ public final class ContactsContract {
// Use MODE_LARGE instead of accepting mode as a parameter. The different mode
// values defined in ContactsContract only affect very old implementations
// of QuickContacts.
- Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT,
+ Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_LARGE,
excludeMimes);
intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType);
- ContactsInternal.startQuickContactWithErrorToast(context, intent);
+ startActivityWithErrorToast(context, intent);
+ }
+
+ private static void startActivityWithErrorToast(Context context, Intent intent) {
+ try {
+ context.startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(context, com.android.internal.R.string.quick_contacts_not_available,
+ Toast.LENGTH_SHORT).show();
+ }
}
}
diff --git a/core/java/android/provider/ContactsInternal.java b/core/java/android/provider/ContactsInternal.java
deleted file mode 100644
index 059a603..0000000
--- a/core/java/android/provider/ContactsInternal.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2015 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 android.provider;
-
-import android.app.admin.DevicePolicyManager;
-import android.content.ActivityNotFoundException;
-import android.content.ContentUris;
-import android.content.Context;
-import android.content.Intent;
-import android.content.UriMatcher;
-import android.net.Uri;
-import android.os.Process;
-import android.os.UserHandle;
-import android.text.TextUtils;
-import android.widget.Toast;
-
-import java.util.List;
-
-/**
- * Contacts related internal methods.
- *
- * @hide
- */
-public class ContactsInternal {
- private ContactsInternal() {
- }
-
- /** URI matcher used to parse contact URIs. */
- private static final UriMatcher sContactsUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
-
- private static final int CONTACTS_URI_LOOKUP_ID = 1000;
-
- static {
- // Contacts URI matching table
- final UriMatcher matcher = sContactsUriMatcher;
- matcher.addURI(ContactsContract.AUTHORITY, "contacts/lookup/*/#", CONTACTS_URI_LOOKUP_ID);
- }
-
- /**
- * Called by {@link ContactsContract} to star Quick Contact, possibly on the managed profile.
- */
- public static void startQuickContactWithErrorToast(Context context, Intent intent) {
- final Uri uri = intent.getData();
-
- final int match = sContactsUriMatcher.match(uri);
- switch (match) {
- case CONTACTS_URI_LOOKUP_ID: {
- if (maybeStartManagedQuickContact(context, intent)) {
- return; // Request handled by DPM. Just return here.
- }
- break;
- }
- }
- // Launch on the current profile.
- startQuickContactWithErrorToastForUser(context, intent, Process.myUserHandle());
- }
-
- public static void startQuickContactWithErrorToastForUser(Context context, Intent intent,
- UserHandle user) {
- try {
- context.startActivityAsUser(intent, user);
- } catch (ActivityNotFoundException e) {
- Toast.makeText(context, com.android.internal.R.string.quick_contacts_not_available,
- Toast.LENGTH_SHORT).show();
- }
- }
-
- /**
- * If the URI in {@code intent} is of a corp contact, launch quick contact on the managed
- * profile.
- *
- * @return the URI in {@code intent} is of a corp contact thus launched on the managed profile.
- */
- private static boolean maybeStartManagedQuickContact(Context context, Intent originalIntent) {
- final Uri uri = originalIntent.getData();
-
- // Decompose into an ID and a lookup key.
- final List<String> pathSegments = uri.getPathSegments();
- final long contactId = ContentUris.parseId(uri);
- final String lookupKey = pathSegments.get(2);
-
- // See if it has a corp lookupkey.
- if (TextUtils.isEmpty(lookupKey)
- || !lookupKey.startsWith(
- ContactsContract.Contacts.ENTERPRISE_CONTACT_LOOKUP_PREFIX)) {
- return false; // It's not a corp lookup key.
- }
-
- // Launch Quick Contact on the managed profile, if the policy allows.
- final DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
- final String actualLookupKey = lookupKey.substring(
- ContactsContract.Contacts.ENTERPRISE_CONTACT_LOOKUP_PREFIX.length());
- final long actualContactId =
- (contactId - ContactsContract.Contacts.ENTERPRISE_CONTACT_ID_BASE);
-
- dpm.startManagedQuickContact(actualLookupKey, actualContactId, originalIntent);
- return true;
- }
-}