summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java38
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl3
-rw-r--r--core/java/android/provider/ContactsContract.java23
-rw-r--r--core/jni/android/graphics/FontFamily.cpp29
-rw-r--r--core/jni/android/graphics/MinikinSkia.cpp2
-rw-r--r--core/jni/android/graphics/Typeface.cpp7
-rw-r--r--core/jni/android/graphics/TypefaceImpl.cpp64
-rw-r--r--core/jni/android/graphics/TypefaceImpl.h9
8 files changed, 126 insertions, 49 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 243e233..26c72a5 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -1885,7 +1885,7 @@ public class DevicePolicyManager {
* security exception will be thrown.
*
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
- * @param disabled Whether or not screen capture should be disabled.
+ * @param disabled Whether screen capture is disabled or not.
*/
public void setScreenCaptureDisabled(ComponentName admin, boolean disabled) {
if (mService != null) {
@@ -1920,6 +1920,42 @@ public class DevicePolicyManager {
}
/**
+ * Called by a device owner to set whether auto time is required. If auto time is
+ * required the user cannot set the date and time, but has to use network date and time.
+ *
+ * <p>Note: if auto time is required the user can still manually set the time zone.
+ *
+ * <p>The calling device admin must be a device owner. If it is not, a security exception will
+ * be thrown.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param required Whether auto time is set required or not.
+ */
+ public void setAutoTimeRequired(ComponentName admin, boolean required) {
+ if (mService != null) {
+ try {
+ mService.setAutoTimeRequired(admin, UserHandle.myUserId(), required);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed talking with device policy service", e);
+ }
+ }
+ }
+
+ /**
+ * @return true if auto time is required.
+ */
+ public boolean getAutoTimeRequired() {
+ if (mService != null) {
+ try {
+ return mService.getAutoTimeRequired();
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed talking with device policy service", e);
+ }
+ }
+ return false;
+ }
+
+ /**
* Called by an application that is administering the device to disable keyguard customizations,
* such as widgets. After setting this, keyguard features will be disabled according to the
* provided feature list.
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 1e17bb6..23f36fb 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -186,4 +186,7 @@ interface IDevicePolicyManager {
boolean addCrossProfileWidgetProvider(in ComponentName admin, String packageName);
boolean removeCrossProfileWidgetProvider(in ComponentName admin, String packageName);
List<String> getCrossProfileWidgetProviders(in ComponentName admin);
+
+ void setAutoTimeRequired(in ComponentName who, int userHandle, boolean required);
+ boolean getAutoTimeRequired();
}
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 513e47e..27473e3 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -36,7 +36,6 @@ import android.database.Cursor;
import android.database.DatabaseUtils;
import android.graphics.Rect;
import android.net.Uri;
-import android.net.Uri.Builder;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.DisplayMetrics;
@@ -1622,15 +1621,15 @@ public final class ContactsContract {
*
* @hide
*/
- public static long CORP_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30
+ public static long ENTERPRISE_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30
/**
- * Return TRUE if a contact ID is from the contacts provider on the corp profile.
+ * 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.
*/
- public static boolean isCorpContactId(long contactId) {
- return (contactId >= CORP_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID);
+ public static boolean isEnterpriseContactId(long contactId) {
+ return (contactId >= ENTERPRISE_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID);
}
/**
@@ -2229,6 +2228,11 @@ public final class ContactsContract {
* type. For applications that need to be aware of the data set, this can
* be used instead of account type to distinguish sets of data. This is
* never intended to be used for specifying accounts.
+ * <p>
+ * This column does *not* escape forward slashes in the account type or the data set.
+ * If this is an issue, consider using
+ * {@link ContactsContract.RawContacts#ACCOUNT_TYPE} and
+ * {@link ContactsContract.RawContacts#DATA_SET} directly.
*/
public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
@@ -5025,7 +5029,8 @@ public final class ContactsContract {
* </li>
* <li>
* Corp contacts will get artificial {@link #_ID}s. In order to tell whether a contact
- * is from the corp profile, use {@link ContactsContract.Contacts#isCorpContactId(long)}.
+ * is from the corp profile, use
+ * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}.
* </li>
* </ul>
* <p>
@@ -8114,19 +8119,19 @@ public final class ContactsContract {
* @hide
*/
@Deprecated
- public static final String EXTRA_TARGET_RECT = "target_rect";
+ public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT";
/**
* Extra used to specify size of pivot dialog.
* @hide
*/
- public static final String EXTRA_MODE = "mode";
+ public static final String EXTRA_MODE = "android.provider.extra.MODE";
/**
* Extra used to indicate a list of specific MIME-types to exclude and not display in the
* QuickContacts dialog. Stored as a {@link String} array.
*/
- public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
+ public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES";
/**
* Small QuickContact mode, usually presented with minimal actions.
diff --git a/core/jni/android/graphics/FontFamily.cpp b/core/jni/android/graphics/FontFamily.cpp
index 1d465b3..bfb30b7 100644
--- a/core/jni/android/graphics/FontFamily.cpp
+++ b/core/jni/android/graphics/FontFamily.cpp
@@ -62,10 +62,26 @@ static jboolean FontFamily_addFont(JNIEnv* env, jobject clazz, jlong familyPtr,
ALOGE("addFont failed to create font %s", str.c_str());
return false;
}
- FontFamily* fontFamily = (FontFamily*)familyPtr;
+ FontFamily* fontFamily = reinterpret_cast<FontFamily*>(familyPtr);
return addSkTypeface(fontFamily, face);
}
+static jboolean FontFamily_addFontWeightStyle(JNIEnv* env, jobject clazz, jlong familyPtr,
+ jstring path, jint weight, jboolean isItalic) {
+ NPE_CHECK_RETURN_ZERO(env, path);
+ ScopedUtfChars str(env, path);
+ SkTypeface* face = SkTypeface::CreateFromFile(str.c_str());
+ if (face == NULL) {
+ ALOGE("addFont failed to create font %s", str.c_str());
+ return false;
+ }
+ FontFamily* fontFamily = reinterpret_cast<FontFamily*>(familyPtr);
+ MinikinFont* minikinFont = new MinikinFontSkia(face);
+ fontFamily->addFont(minikinFont, FontStyle(weight / 100, isItalic));
+ minikinFont->Unref();
+ return true;
+}
+
static jboolean FontFamily_addFontFromAsset(JNIEnv* env, jobject, jlong familyPtr,
jobject jassetMgr, jstring jpath) {
NPE_CHECK_RETURN_ZERO(env, jassetMgr);
@@ -92,17 +108,18 @@ static jboolean FontFamily_addFontFromAsset(JNIEnv* env, jobject, jlong familyPt
ALOGE("addFontFromAsset failed to create font %s", str.c_str());
return false;
}
- FontFamily* fontFamily = (FontFamily*)familyPtr;
+ FontFamily* fontFamily = reinterpret_cast<FontFamily*>(familyPtr);
return addSkTypeface(fontFamily, face);
}
///////////////////////////////////////////////////////////////////////////////
static JNINativeMethod gFontFamilyMethods[] = {
- { "nCreateFamily", "(Ljava/lang/String;I)J", (void*)FontFamily_create },
- { "nUnrefFamily", "(J)V", (void*)FontFamily_unref },
- { "nAddFont", "(JLjava/lang/String;)Z", (void*)FontFamily_addFont },
- { "nAddFontFromAsset", "(JLandroid/content/res/AssetManager;Ljava/lang/String;)Z",
+ { "nCreateFamily", "(Ljava/lang/String;I)J", (void*)FontFamily_create },
+ { "nUnrefFamily", "(J)V", (void*)FontFamily_unref },
+ { "nAddFont", "(JLjava/lang/String;)Z", (void*)FontFamily_addFont },
+ { "nAddFontWeightStyle", "(JLjava/lang/String;IZ)Z", (void*)FontFamily_addFontWeightStyle },
+ { "nAddFontFromAsset", "(JLandroid/content/res/AssetManager;Ljava/lang/String;)Z",
(void*)FontFamily_addFontFromAsset },
};
diff --git a/core/jni/android/graphics/MinikinSkia.cpp b/core/jni/android/graphics/MinikinSkia.cpp
index ae29014..4649b07 100644
--- a/core/jni/android/graphics/MinikinSkia.cpp
+++ b/core/jni/android/graphics/MinikinSkia.cpp
@@ -39,7 +39,7 @@ bool MinikinFontSkia::GetGlyph(uint32_t codepoint, uint32_t *glyph) const {
uint16_t glyph16;
paint.textToGlyphs(&codepoint, sizeof(codepoint), &glyph16);
*glyph = glyph16;
- return !!glyph;
+ return !!glyph16;
}
static void MinikinFontSkia_SetSkiaPaint(const MinikinFont* font, SkPaint* skPaint, const MinikinPaint& paint) {
diff --git a/core/jni/android/graphics/Typeface.cpp b/core/jni/android/graphics/Typeface.cpp
index cf4e838..2029658 100644
--- a/core/jni/android/graphics/Typeface.cpp
+++ b/core/jni/android/graphics/Typeface.cpp
@@ -41,6 +41,12 @@ static jlong Typeface_createFromTypeface(JNIEnv* env, jobject, jlong familyHandl
return reinterpret_cast<jlong>(face);
}
+static jlong Typeface_createWeightAlias(JNIEnv* env, jobject, jlong familyHandle, jint weight) {
+ TypefaceImpl* family = reinterpret_cast<TypefaceImpl*>(familyHandle);
+ TypefaceImpl* face = TypefaceImpl_createWeightAlias(family, weight);
+ return reinterpret_cast<jlong>(face);
+}
+
static void Typeface_unref(JNIEnv* env, jobject obj, jlong faceHandle) {
TypefaceImpl* face = reinterpret_cast<TypefaceImpl*>(faceHandle);
TypefaceImpl_unref(face);
@@ -65,6 +71,7 @@ static void Typeface_setDefault(JNIEnv *env, jobject, jlong faceHandle) {
static JNINativeMethod gTypefaceMethods[] = {
{ "nativeCreateFromTypeface", "(JI)J", (void*)Typeface_createFromTypeface },
+ { "nativeCreateWeightAlias", "(JI)J", (void*)Typeface_createWeightAlias },
{ "nativeUnref", "(J)V", (void*)Typeface_unref },
{ "nativeGetStyle", "(J)I", (void*)Typeface_getStyle },
{ "nativeCreateFromArray", "([J)J",
diff --git a/core/jni/android/graphics/TypefaceImpl.cpp b/core/jni/android/graphics/TypefaceImpl.cpp
index 9ce6de1..7afbeb2 100644
--- a/core/jni/android/graphics/TypefaceImpl.cpp
+++ b/core/jni/android/graphics/TypefaceImpl.cpp
@@ -39,14 +39,17 @@
namespace android {
-// Any weight greater than or equal to this is considered "bold" for
-// legacy API.
-static const int kBoldThreshold = 6;
-
-static FontStyle styleFromSkiaStyle(SkTypeface::Style skiaStyle) {
- int weight = (skiaStyle & SkTypeface::kBold) != 0 ? 7 : 4;
- bool italic = (skiaStyle & SkTypeface::kItalic) != 0;
- return FontStyle(weight, italic);
+// Resolve the 1..9 weight based on base weight and bold flag
+static void resolveStyle(TypefaceImpl* typeface) {
+ int weight = typeface->fBaseWeight / 100;
+ if (typeface->fSkiaStyle & SkTypeface::kBold) {
+ weight += 3;
+ }
+ if (weight > 9) {
+ weight = 9;
+ }
+ bool italic = (typeface->fSkiaStyle & SkTypeface::kItalic) != 0;
+ typeface->fStyle = FontStyle(weight, italic);
}
TypefaceImpl* gDefaultTypeface = NULL;
@@ -90,7 +93,9 @@ static void getDefaultTypefaceOnce() {
// default so we can make progress before that happens.
gDefaultTypeface = new TypefaceImpl;
gDefaultTypeface->fFontCollection = makeFontCollection();
- gDefaultTypeface->fStyle = FontStyle();
+ gDefaultTypeface->fSkiaStyle = SkTypeface::kNormal;
+ gDefaultTypeface->fBaseWeight = 400;
+ resolveStyle(gDefaultTypeface);
}
}
@@ -109,25 +114,23 @@ TypefaceImpl* TypefaceImpl_createFromTypeface(TypefaceImpl* src, SkTypeface::Sty
if (result != 0) {
result->fFontCollection = resolvedFace->fFontCollection;
result->fFontCollection->Ref();
- result->fStyle = styleFromSkiaStyle(style);
+ result->fSkiaStyle = style;
+ result->fBaseWeight = resolvedFace->fBaseWeight;
+ resolveStyle(result);
}
return result;
}
-static TypefaceImpl* createFromSkTypeface(SkTypeface* typeface) {
- if (typeface == NULL) {
- return NULL;
- }
- MinikinFont* minikinFont = new MinikinFontSkia(typeface);
- std::vector<FontFamily *> typefaces;
- FontFamily* family = new FontFamily();
- family->addFont(minikinFont);
- minikinFont->Unref();
- typefaces.push_back(family);
+TypefaceImpl* TypefaceImpl_createWeightAlias(TypefaceImpl* src, int weight) {
+ TypefaceImpl* resolvedFace = TypefaceImpl_resolveDefault(src);
TypefaceImpl* result = new TypefaceImpl;
- result->fFontCollection = new FontCollection(typefaces);
- family->Unref();
- result->fStyle = FontStyle(); // TODO: improve
+ if (result != 0) {
+ result->fFontCollection = resolvedFace->fFontCollection;
+ result->fFontCollection->Ref();
+ result->fSkiaStyle = resolvedFace->fSkiaStyle;
+ result->fBaseWeight = weight;
+ resolveStyle(result);
+ }
return result;
}
@@ -141,7 +144,7 @@ TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size
result->fFontCollection = new FontCollection(familyVec);
if (size == 0) {
ALOGW("createFromFamilies creating empty collection");
- result->fStyle = FontStyle();
+ result->fSkiaStyle = SkTypeface::kNormal;
} else {
const FontStyle defaultStyle;
FontFamily* firstFamily = reinterpret_cast<FontFamily*>(families[0]);
@@ -150,11 +153,13 @@ TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size
SkTypeface* skTypeface = reinterpret_cast<MinikinFontSkia*>(mf)->GetSkTypeface();
// TODO: probably better to query more precise style from family, will be important
// when we open up API to access 100..900 weights
- result->fStyle = styleFromSkiaStyle(skTypeface->style());
+ result->fSkiaStyle = skTypeface->style();
} else {
- result->fStyle = defaultStyle;
+ result->fSkiaStyle = SkTypeface::kNormal;
}
}
+ result->fBaseWeight = 400;
+ resolveStyle(result);
return result;
}
@@ -166,12 +171,7 @@ void TypefaceImpl_unref(TypefaceImpl* face) {
}
int TypefaceImpl_getStyle(TypefaceImpl* face) {
- FontStyle style = face->fStyle;
- int result = style.getItalic() ? SkTypeface::kItalic : 0;
- if (style.getWeight() >= kBoldThreshold) {
- result |= SkTypeface::kBold;
- }
- return result;
+ return face->fSkiaStyle;
}
void TypefaceImpl_setDefault(TypefaceImpl* face) {
diff --git a/core/jni/android/graphics/TypefaceImpl.h b/core/jni/android/graphics/TypefaceImpl.h
index 12b3403..d129f62 100644
--- a/core/jni/android/graphics/TypefaceImpl.h
+++ b/core/jni/android/graphics/TypefaceImpl.h
@@ -28,6 +28,13 @@ namespace android {
struct TypefaceImpl {
FontCollection *fFontCollection;
+
+ // style used for constructing and querying Typeface objects
+ SkTypeface::Style fSkiaStyle;
+ // base weight in CSS-style units, 100..900
+ int fBaseWeight;
+
+ // resolved style actually used for rendering
FontStyle fStyle;
};
@@ -41,6 +48,8 @@ TypefaceImpl* TypefaceImpl_resolveDefault(TypefaceImpl* src);
TypefaceImpl* TypefaceImpl_createFromTypeface(TypefaceImpl* src, SkTypeface::Style style);
+TypefaceImpl* TypefaceImpl_createWeightAlias(TypefaceImpl* src, int baseweight);
+
// When we remove the USE_MINIKIN ifdef, probably a good idea to move the casting
// (from jlong to FontFamily*) to the caller in Typeface.cpp.
TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size);