diff options
Diffstat (limited to 'core')
35 files changed, 462 insertions, 153 deletions
diff --git a/core/java/android/app/ActionBar.java b/core/java/android/app/ActionBar.java index b74c824..014a7af 100644 --- a/core/java/android/app/ActionBar.java +++ b/core/java/android/app/ActionBar.java @@ -1061,6 +1061,10 @@ public abstract class ActionBar { return false; } + /** @hide */ + public void setWindowTitle(CharSequence title) { + } + /** * Listener interface for ActionBar navigation events. * diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 2387553..c80eeb9 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -5038,9 +5038,9 @@ public class Activity extends ContextThemeWrapper win.setTitleColor(color); } } - } - if (mActionBar != null) { - mActionBar.setTitle(title); + if (mActionBar != null) { + mActionBar.setWindowTitle(title); + } } } diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index da7c790..ffb9c95 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -67,6 +67,8 @@ public class ActivityManager { private static String TAG = "ActivityManager"; private static boolean localLOGV = false; + private static int gMaxRecentTasks = -1; + private final Context mContext; private final Handler mHandler; @@ -442,7 +444,7 @@ public class ActivityManager { // Really brain dead right now -- just take this from the configured // vm heap size, and assume it is in megabytes and thus ends with "m". String vmHeapSize = SystemProperties.get("dalvik.vm.heapsize", "16m"); - return Integer.parseInt(vmHeapSize.substring(0, vmHeapSize.length()-1)); + return Integer.parseInt(vmHeapSize.substring(0, vmHeapSize.length() - 1)); } /** @@ -473,6 +475,33 @@ public class ActivityManager { } /** + * Return the maximum number of recents entries that we will maintain and show. + * @hide + */ + static public int getMaxRecentTasksStatic() { + if (gMaxRecentTasks < 0) { + return gMaxRecentTasks = isLowRamDeviceStatic() ? 50 : 100; + } + return gMaxRecentTasks; + } + + /** + * Return the default limit on the number of recents that an app can make. + * @hide + */ + static public int getDefaultAppRecentsLimitStatic() { + return getMaxRecentTasksStatic() / 6; + } + + /** + * Return the maximum limit on the number of recents that an app can make. + * @hide + */ + static public int getMaxAppRecentsLimitStatic() { + return getMaxRecentTasksStatic() / 2; + } + + /** * Information you can set and retrieve about the current activity within the recent task list. */ public static class TaskDescription implements Parcelable { @@ -1184,13 +1213,13 @@ public class ActivityManager { public void writeToParcel(Parcel dest, int flags) { if (mainThumbnail != null) { dest.writeInt(1); - mainThumbnail.writeToParcel(dest, 0); + mainThumbnail.writeToParcel(dest, flags); } else { dest.writeInt(0); } if (thumbnailFileDescriptor != null) { dest.writeInt(1); - thumbnailFileDescriptor.writeToParcel(dest, 0); + thumbnailFileDescriptor.writeToParcel(dest, flags); } else { dest.writeInt(0); } diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index 16d091a..1f7e450 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -1392,8 +1392,9 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM data.enforceInterface(IActivityManager.descriptor); IBinder app = data.readStrongBinder(); String tag = data.readString(); + boolean system = data.readInt() != 0; ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data); - boolean res = handleApplicationWtf(app, tag, ci); + boolean res = handleApplicationWtf(app, tag, system, ci); reply.writeNoException(); reply.writeInt(res ? 1 : 0); return true; @@ -4069,7 +4070,7 @@ class ActivityManagerProxy implements IActivityManager data.recycle(); } - public boolean handleApplicationWtf(IBinder app, String tag, + public boolean handleApplicationWtf(IBinder app, String tag, boolean system, ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException { Parcel data = Parcel.obtain(); @@ -4077,6 +4078,7 @@ class ActivityManagerProxy implements IActivityManager data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(app); data.writeString(tag); + data.writeInt(system ? 1 : 0); crashInfo.writeToParcel(data, 0); mRemote.transact(HANDLE_APPLICATION_WTF_TRANSACTION, data, reply, 0); reply.readException(); diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index 71bdf8c..99428e8 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -266,7 +266,7 @@ public interface IActivityManager extends IInterface { // Special low-level communication with activity manager. public void handleApplicationCrash(IBinder app, ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException; - public boolean handleApplicationWtf(IBinder app, String tag, + public boolean handleApplicationWtf(IBinder app, String tag, boolean system, ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException; // A StrictMode violation to be handled. The violationMask is a diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index b17309f..26c72a5 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -1374,7 +1374,7 @@ public class DevicePolicyManager { * @param admin The name of the admin component to check, or null to aggregate * all admins. * @return time in milliseconds for the given admin or the minimum value (strictest) of - * all admins if admin is null. + * all admins if admin is null. Returns 0 if there are no restrictions. */ public long getMaximumTimeToLock(ComponentName admin) { return getMaximumTimeToLock(admin, UserHandle.myUserId()); @@ -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. @@ -3157,6 +3193,20 @@ public class DevicePolicyManager { /** * Called by device owners to update {@link Settings.Global} settings. Validation that the value * of the setting is in the correct form for the setting type should be performed by the caller. + * <p>The settings that can be updated with this method are: + * <ul> + * <li>{@link Settings.Global#ADB_ENABLED}</li> + * <li>{@link Settings.Global#AUTO_TIME}</li> + * <li>{@link Settings.Global#AUTO_TIME_ZONE}</li> + * <li>{@link Settings.Global#BLUETOOTH_ON}</li> + * <li>{@link Settings.Global#DATA_ROAMING}</li> + * <li>{@link Settings.Global#DEVELOPMENT_SETTINGS_ENABLED}</li> + * <li>{@link Settings.Global#MODE_RINGER}</li> + * <li>{@link Settings.Global#NETWORK_PREFERENCE}</li> + * <li>{@link Settings.Global#USB_MASS_STORAGE_ENABLED}</li> + * <li>{@link Settings.Global#WIFI_ON}</li> + * <li>{@link Settings.Global#WIFI_SLEEP_POLICY}</li> + * </ul> * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param setting The name of the setting to update. @@ -3176,7 +3226,11 @@ public class DevicePolicyManager { * Called by profile or device owners to update {@link Settings.Secure} settings. Validation * that the value of the setting is in the correct form for the setting type should be performed * by the caller. - * + * <p>The settings that can be updated with this method are: + * <ul> + * <li>{@link Settings.Secure#DEFAULT_INPUT_METHOD}</li> + * <li>{@link Settings.Secure#SKIP_FIRST_USE_HINTS}</li> + * </ul> * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param setting The name of the setting to update. * @param value The value to update the setting to. 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/app/backup/WallpaperBackupHelper.java b/core/java/android/app/backup/WallpaperBackupHelper.java index 9e8ab2c..0567500 100644 --- a/core/java/android/app/backup/WallpaperBackupHelper.java +++ b/core/java/android/app/backup/WallpaperBackupHelper.java @@ -141,13 +141,13 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu if (widthRatio > 0 && widthRatio < 1.33 && heightRatio > 0 && heightRatio < 1.33) { // sufficiently close to our resolution; go ahead and use it - if (DEBUG) Slog.d(TAG, "wallpaper dimension match; using"); + Slog.d(TAG, "Applying restored wallpaper image."); f.renameTo(new File(WALLPAPER_IMAGE)); // TODO: spin a service to copy the restored image to sd/usb storage, // since it does not exist anywhere other than the private wallpaper // file. } else { - if (DEBUG) Slog.d(TAG, "dimensions too far off: wr=" + widthRatio + Slog.i(TAG, "Dimensions too far off; using default wallpaper. wr=" + widthRatio + " hr=" + heightRatio); f.delete(); } diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index b09d3ac..6d40dcf 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -25,6 +25,7 @@ import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_NOT_APK; import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES; import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION; +import android.app.ActivityManager; import android.content.ComponentName; import android.content.Intent; import android.content.IntentFilter; @@ -3077,7 +3078,7 @@ public class PackageParser { ActivityInfo.DOCUMENT_LAUNCH_NONE); a.info.maxRecents = sa.getInt( com.android.internal.R.styleable.AndroidManifestActivity_maxRecents, - 15); + ActivityManager.getDefaultAppRecentsLimitStatic()); a.info.screenOrientation = sa.getInt( com.android.internal.R.styleable.AndroidManifestActivity_screenOrientation, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); diff --git a/core/java/android/database/ContentObserver.java b/core/java/android/database/ContentObserver.java index e4fbc28..5f01e30 100644 --- a/core/java/android/database/ContentObserver.java +++ b/core/java/android/database/ContentObserver.java @@ -18,6 +18,7 @@ package android.database; import android.net.Uri; import android.os.Handler; +import android.os.UserHandle; /** * Receives call backs for changes to content. @@ -130,6 +131,21 @@ public abstract class ContentObserver { } /** + * Dispatches a change notification to the observer. Includes the changed + * content Uri when available and also the user whose content changed. + * + * @param selfChange True if this is a self-change notification. + * @param uri The Uri of the changed content, or null if unknown. + * @param userId The user whose content changed. Can be either a specific + * user or {@link UserHandle#USER_ALL}. + * + * @hide + */ + public void onChange(boolean selfChange, Uri uri, int userId) { + onChange(selfChange, uri); + } + + /** * Dispatches a change notification to the observer. * <p> * If a {@link Handler} was supplied to the {@link ContentObserver} constructor, @@ -159,25 +175,45 @@ public abstract class ContentObserver { * @param uri The Uri of the changed content, or null if unknown. */ public final void dispatchChange(boolean selfChange, Uri uri) { + dispatchChange(selfChange, uri, UserHandle.getCallingUserId()); + } + + /** + * Dispatches a change notification to the observer. Includes the changed + * content Uri when available and also the user whose content changed. + * <p> + * If a {@link Handler} was supplied to the {@link ContentObserver} constructor, + * then a call to the {@link #onChange} method is posted to the handler's message queue. + * Otherwise, the {@link #onChange} method is invoked immediately on this thread. + * </p> + * + * @param selfChange True if this is a self-change notification. + * @param uri The Uri of the changed content, or null if unknown. + * @param userId The user whose content changed. + */ + private void dispatchChange(boolean selfChange, Uri uri, int userId) { if (mHandler == null) { - onChange(selfChange, uri); + onChange(selfChange, uri, userId); } else { - mHandler.post(new NotificationRunnable(selfChange, uri)); + mHandler.post(new NotificationRunnable(selfChange, uri, userId)); } } + private final class NotificationRunnable implements Runnable { private final boolean mSelfChange; private final Uri mUri; + private final int mUserId; - public NotificationRunnable(boolean selfChange, Uri uri) { + public NotificationRunnable(boolean selfChange, Uri uri, int userId) { mSelfChange = selfChange; mUri = uri; + mUserId = userId; } @Override public void run() { - ContentObserver.this.onChange(mSelfChange, mUri); + ContentObserver.this.onChange(mSelfChange, mUri, mUserId); } } @@ -189,10 +225,10 @@ public abstract class ContentObserver { } @Override - public void onChange(boolean selfChange, Uri uri) { + public void onChange(boolean selfChange, Uri uri, int userId) { ContentObserver contentObserver = mContentObserver; if (contentObserver != null) { - contentObserver.dispatchChange(selfChange, uri); + contentObserver.dispatchChange(selfChange, uri, userId); } } diff --git a/core/java/android/database/CursorToBulkCursorAdaptor.java b/core/java/android/database/CursorToBulkCursorAdaptor.java index 7dcfae2..02eddf2 100644 --- a/core/java/android/database/CursorToBulkCursorAdaptor.java +++ b/core/java/android/database/CursorToBulkCursorAdaptor.java @@ -17,9 +17,7 @@ package android.database; import android.net.Uri; -import android.os.Bundle; -import android.os.IBinder; -import android.os.RemoteException; +import android.os.*; /** @@ -33,7 +31,7 @@ import android.os.RemoteException; * * {@hide} */ -public final class CursorToBulkCursorAdaptor extends BulkCursorNative +public final class CursorToBulkCursorAdaptor extends BulkCursorNative implements IBinder.DeathRecipient { private static final String TAG = "Cursor"; @@ -66,7 +64,7 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative // Do nothing, the far side is dead } } - + public boolean unlinkToDeath(DeathRecipient recipient) { return mRemote.asBinder().unlinkToDeath(recipient, 0); } @@ -80,7 +78,7 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative @Override public void onChange(boolean selfChange, Uri uri) { try { - mRemote.onChange(selfChange, uri); + mRemote.onChange(selfChange, uri, android.os.Process.myUid()); } catch (RemoteException ex) { // Do nothing, the far side is dead } diff --git a/core/java/android/database/IContentObserver.aidl b/core/java/android/database/IContentObserver.aidl index 13aff05..22dc9fe 100644 --- a/core/java/android/database/IContentObserver.aidl +++ b/core/java/android/database/IContentObserver.aidl @@ -2,16 +2,16 @@ ** ** Copyright 2007, 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 +** 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 +** 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 +** 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. */ @@ -29,5 +29,5 @@ interface IContentObserver * observed. selfUpdate is true if the update was caused by a call to * commit on the cursor that is being observed. */ - oneway void onChange(boolean selfUpdate, in Uri uri); + oneway void onChange(boolean selfUpdate, in Uri uri, int userId); } diff --git a/core/java/android/hardware/camera2/ICameraDeviceCallbacks.aidl b/core/java/android/hardware/camera2/ICameraDeviceCallbacks.aidl index caabed3..ca0935c 100644 --- a/core/java/android/hardware/camera2/ICameraDeviceCallbacks.aidl +++ b/core/java/android/hardware/camera2/ICameraDeviceCallbacks.aidl @@ -26,8 +26,8 @@ interface ICameraDeviceCallbacks * Keep up-to-date with frameworks/av/include/camera/camera2/ICameraDeviceCallbacks.h */ - oneway void onCameraError(int errorCode, in CaptureResultExtras resultExtras); - oneway void onCameraIdle(); + oneway void onDeviceError(int errorCode, in CaptureResultExtras resultExtras); + oneway void onDeviceIdle(); oneway void onCaptureStarted(in CaptureResultExtras resultExtras, long timestamp); oneway void onResultReceived(in CameraMetadataNative result, in CaptureResultExtras resultExtras); diff --git a/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java b/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java index 621968b..9ca1fba 100644 --- a/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java +++ b/core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java @@ -74,7 +74,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession { private boolean mSkipUnconfigure = false; /** Is the session in the process of aborting? Pay attention to BUSY->IDLE transitions. */ - private boolean mAborting; + private volatile boolean mAborting; /** * Create a new CameraCaptureSession. @@ -346,6 +346,20 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession { } /** + * Whether currently in mid-abort. + * + * <p>This is used by the implementation to set the capture failure + * reason, in lieu of more accurate error codes from the camera service. + * Unsynchronized to avoid deadlocks between simultaneous session->device, + * device->session calls.</p> + * + * <p>Package-private.</p> + */ + boolean isAborting() { + return mAborting; + } + + /** * Post calls into a CameraCaptureSession.StateListener to the user-specified {@code handler}. */ private StateListener createUserStateListenerProxy(Handler handler, StateListener listener) { @@ -502,8 +516,8 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession { // TODO: Queue captures during abort instead of failing them // since the app won't be able to distinguish the two actives + // Don't signal the application since there's no clean mapping here Log.w(TAG, "Device is now busy; do not submit new captures (TODO: allow this)"); - mStateListener.onActive(session); } @Override diff --git a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java index 79ce9df..513d222 100644 --- a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java +++ b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java @@ -384,7 +384,7 @@ public class CameraDeviceImpl extends CameraDevice { catch (IllegalArgumentException e) { // OK. camera service can reject stream config if it's not supported by HAL // This is only the result of a programmer misusing the camera2 api. - Log.e(TAG, "Stream configuration failed", e); + Log.w(TAG, "Stream configuration failed"); return false; } @@ -1097,31 +1097,51 @@ public class CameraDeviceImpl extends CameraDevice { */ static final int ERROR_CAMERA_SERVICE = 2; + /** + * Camera has encountered an error processing a single request. + */ + static final int ERROR_CAMERA_REQUEST = 3; + + /** + * Camera has encountered an error producing metadata for a single capture + */ + static final int ERROR_CAMERA_RESULT = 4; + + /** + * Camera has encountered an error producing an image buffer for a single capture + */ + static final int ERROR_CAMERA_BUFFER = 5; + @Override public IBinder asBinder() { return this; } @Override - public void onCameraError(final int errorCode, CaptureResultExtras resultExtras) { - Runnable r = null; + public void onDeviceError(final int errorCode, CaptureResultExtras resultExtras) { + if (DEBUG) { + Log.d(TAG, String.format( + "Device error received, code %d, frame number %d, request ID %d, subseq ID %d", + errorCode, resultExtras.getFrameNumber(), resultExtras.getRequestId(), + resultExtras.getSubsequenceId())); + } synchronized(mInterfaceLock) { if (mRemoteDevice == null) { return; // Camera already closed } - mInError = true; switch (errorCode) { case ERROR_CAMERA_DISCONNECTED: - r = mCallOnDisconnected; + CameraDeviceImpl.this.mDeviceHandler.post(mCallOnDisconnected); break; default: Log.e(TAG, "Unknown error from camera device: " + errorCode); // no break case ERROR_CAMERA_DEVICE: case ERROR_CAMERA_SERVICE: - r = new Runnable() { + mInError = true; + Runnable r = new Runnable() { @Override public void run() { if (!CameraDeviceImpl.this.isClosed()) { @@ -1129,21 +1149,19 @@ public class CameraDeviceImpl extends CameraDevice { } } }; + CameraDeviceImpl.this.mDeviceHandler.post(r); + break; + case ERROR_CAMERA_REQUEST: + case ERROR_CAMERA_RESULT: + case ERROR_CAMERA_BUFFER: + onCaptureErrorLocked(errorCode, resultExtras); break; } - CameraDeviceImpl.this.mDeviceHandler.post(r); - - // Fire onCaptureSequenceCompleted - if (DEBUG) { - Log.v(TAG, String.format("got error frame %d", resultExtras.getFrameNumber())); - } - mFrameNumberTracker.updateTracker(resultExtras.getFrameNumber(), /*error*/true); - checkAndFireSequenceComplete(); } } @Override - public void onCameraIdle() { + public void onDeviceIdle() { if (DEBUG) { Log.d(TAG, "Camera now idle"); } @@ -1246,7 +1264,6 @@ public class CameraDeviceImpl extends CameraDevice { final CaptureRequest request = holder.getRequest(resultExtras.getSubsequenceId()); - Runnable resultDispatch = null; // Either send a partial result or the final capture completed result @@ -1290,11 +1307,67 @@ public class CameraDeviceImpl extends CameraDevice { if (!isPartialResult) { checkAndFireSequenceComplete(); } + } + } + /** + * Called by onDeviceError for handling single-capture failures. + */ + private void onCaptureErrorLocked(int errorCode, CaptureResultExtras resultExtras) { + + final int requestId = resultExtras.getRequestId(); + final int subsequenceId = resultExtras.getSubsequenceId(); + final long frameNumber = resultExtras.getFrameNumber(); + final CaptureListenerHolder holder = + CameraDeviceImpl.this.mCaptureListenerMap.get(requestId); + + final CaptureRequest request = holder.getRequest(subsequenceId); + + // No way to report buffer errors right now + if (errorCode == ERROR_CAMERA_BUFFER) { + Log.e(TAG, String.format("Lost output buffer reported for frame %d", frameNumber)); + return; + } + + boolean mayHaveBuffers = (errorCode == ERROR_CAMERA_RESULT); + + // This is only approximate - exact handling needs the camera service and HAL to + // disambiguate between request failures to due abort and due to real errors. + // For now, assume that if the session believes we're mid-abort, then the error + // is due to abort. + int reason = (mCurrentSession != null && mCurrentSession.isAborting()) ? + CaptureFailure.REASON_FLUSHED : + CaptureFailure.REASON_ERROR; + + final CaptureFailure failure = new CaptureFailure( + request, + reason, + /*dropped*/ mayHaveBuffers, + requestId, + frameNumber); + + Runnable failureDispatch = new Runnable() { + @Override + public void run() { + if (!CameraDeviceImpl.this.isClosed()){ + holder.getListener().onCaptureFailed( + CameraDeviceImpl.this, + request, + failure); + } + } + }; + holder.getHandler().post(failureDispatch); + + // Fire onCaptureSequenceCompleted if appropriate + if (DEBUG) { + Log.v(TAG, String.format("got error frame %d", frameNumber)); } + mFrameNumberTracker.updateTracker(frameNumber, /*error*/true); + checkAndFireSequenceComplete(); } - } + } // public class CameraDeviceCallbacks /** * Default handler management. diff --git a/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java b/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java index 5cbf109..410934e 100644 --- a/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java +++ b/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java @@ -211,7 +211,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } @Override - public void onCameraError(final int errorCode, final CaptureResultExtras resultExtras) { + public void onDeviceError(final int errorCode, final CaptureResultExtras resultExtras) { Message msg = getHandler().obtainMessage(CAMERA_ERROR, /*arg1*/ errorCode, /*arg2*/ 0, /*obj*/ resultExtras); @@ -219,7 +219,7 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { } @Override - public void onCameraIdle() { + public void onDeviceIdle() { Message msg = getHandler().obtainMessage(CAMERA_IDLE); getHandler().sendMessage(msg); } @@ -267,11 +267,11 @@ public class CameraDeviceUserShim implements ICameraDeviceUser { case CAMERA_ERROR: { int errorCode = msg.arg1; CaptureResultExtras resultExtras = (CaptureResultExtras) msg.obj; - mCallbacks.onCameraError(errorCode, resultExtras); + mCallbacks.onDeviceError(errorCode, resultExtras); break; } case CAMERA_IDLE: - mCallbacks.onCameraIdle(); + mCallbacks.onDeviceIdle(); break; case CAPTURE_STARTED: { long timestamp = msg.arg2 & 0xFFFFFFFFL; diff --git a/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java b/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java index 1cf7797..ffc55f1 100644 --- a/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java +++ b/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java @@ -97,7 +97,7 @@ public class LegacyCameraDevice implements AutoCloseable { Log.d(TAG, "doing onError callback."); } try { - mDeviceCallbacks.onCameraError(errorCode, extras); + mDeviceCallbacks.onDeviceError(errorCode, extras); } catch (RemoteException e) { throw new IllegalStateException( "Received remote exception during onCameraError callback: ", e); @@ -125,7 +125,7 @@ public class LegacyCameraDevice implements AutoCloseable { Log.d(TAG, "doing onIdle callback."); } try { - mDeviceCallbacks.onCameraIdle(); + mDeviceCallbacks.onDeviceIdle(); } catch (RemoteException e) { throw new IllegalStateException( "Received remote exception during onCameraIdle callback: ", e); diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java index 4f35b16..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"; @@ -2272,6 +2276,8 @@ public final class ContactsContract { * The default value is "0" * </p> * <p>Type: INTEGER</p> + * + * @hide */ public static final String NAME_VERIFIED = "name_verified"; @@ -5023,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> @@ -8066,6 +8073,21 @@ public final class ContactsContract { } /** + * Pins a contact at a provided position, or unpins a contact. + * + * @param contentResolver to perform the pinning operation on. + * @param pinnedPosition the position to pin the contact at. To unpin a contact, use + * {@link PinnedPositions#UNPINNED}. + */ + public static void pin( + ContentResolver contentResolver, long contactId, int pinnedPosition) { + final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId)); + final ContentValues values = new ContentValues(); + values.put(Contacts.PINNED, pinnedPosition); + contentResolver.update(uri, values, null, null); + } + + /** * Default value for the pinned position of an unpinned contact. */ public static final int UNPINNED = 0; @@ -8097,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/java/android/util/Log.java b/core/java/android/util/Log.java index 2b81072..a9b3571 100644 --- a/core/java/android/util/Log.java +++ b/core/java/android/util/Log.java @@ -96,12 +96,12 @@ public final class Log { * @hide */ public interface TerribleFailureHandler { - void onTerribleFailure(String tag, TerribleFailure what); + void onTerribleFailure(String tag, TerribleFailure what, boolean system); } private static TerribleFailureHandler sWtfHandler = new TerribleFailureHandler() { - public void onTerribleFailure(String tag, TerribleFailure what) { - RuntimeInit.wtf(tag, what); + public void onTerribleFailure(String tag, TerribleFailure what, boolean system) { + RuntimeInit.wtf(tag, what, system); } }; @@ -253,7 +253,7 @@ public final class Log { * @param msg The message you would like logged. */ public static int wtf(String tag, String msg) { - return wtf(LOG_ID_MAIN, tag, msg, null, false); + return wtf(LOG_ID_MAIN, tag, msg, null, false, false); } /** @@ -262,7 +262,7 @@ public final class Log { * @hide */ public static int wtfStack(String tag, String msg) { - return wtf(LOG_ID_MAIN, tag, msg, null, true); + return wtf(LOG_ID_MAIN, tag, msg, null, true, false); } /** @@ -272,7 +272,7 @@ public final class Log { * @param tr An exception to log. */ public static int wtf(String tag, Throwable tr) { - return wtf(LOG_ID_MAIN, tag, tr.getMessage(), tr, false); + return wtf(LOG_ID_MAIN, tag, tr.getMessage(), tr, false, false); } /** @@ -283,14 +283,15 @@ public final class Log { * @param tr An exception to log. May be null. */ public static int wtf(String tag, String msg, Throwable tr) { - return wtf(LOG_ID_MAIN, tag, msg, tr, false); + return wtf(LOG_ID_MAIN, tag, msg, tr, false, false); } - static int wtf(int logId, String tag, String msg, Throwable tr, boolean localStack) { + static int wtf(int logId, String tag, String msg, Throwable tr, boolean localStack, + boolean system) { TerribleFailure what = new TerribleFailure(msg, tr); int bytes = println_native(logId, ASSERT, tag, msg + '\n' + getStackTraceString(localStack ? what : tr)); - sWtfHandler.onTerribleFailure(tag, what); + sWtfHandler.onTerribleFailure(tag, what, system); return bytes; } diff --git a/core/java/android/util/Slog.java b/core/java/android/util/Slog.java index b25d80f..7a5fd50 100644 --- a/core/java/android/util/Slog.java +++ b/core/java/android/util/Slog.java @@ -74,19 +74,19 @@ public final class Slog { } public static int wtf(String tag, String msg) { - return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, false); + return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, false, true); } public static int wtfStack(String tag, String msg) { - return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, true); + return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, true, true); } public static int wtf(String tag, Throwable tr) { - return Log.wtf(Log.LOG_ID_SYSTEM, tag, tr.getMessage(), tr, false); + return Log.wtf(Log.LOG_ID_SYSTEM, tag, tr.getMessage(), tr, false, true); } public static int wtf(String tag, String msg, Throwable tr) { - return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, tr, false); + return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, tr, false, true); } public static int println(int priority, String tag, String msg) { diff --git a/core/java/com/android/internal/app/ToolbarActionBar.java b/core/java/com/android/internal/app/ToolbarActionBar.java index 13eb182..abe8a9f 100644 --- a/core/java/com/android/internal/app/ToolbarActionBar.java +++ b/core/java/com/android/internal/app/ToolbarActionBar.java @@ -226,6 +226,11 @@ public class ToolbarActionBar extends ActionBar { } @Override + public void setWindowTitle(CharSequence title) { + mDecorToolbar.setWindowTitle(title); + } + + @Override public void setSubtitle(CharSequence subtitle) { mDecorToolbar.setSubtitle(subtitle); } diff --git a/core/java/com/android/internal/app/WindowDecorActionBar.java b/core/java/com/android/internal/app/WindowDecorActionBar.java index b58e1db..a8f7bb3 100644 --- a/core/java/com/android/internal/app/WindowDecorActionBar.java +++ b/core/java/com/android/internal/app/WindowDecorActionBar.java @@ -431,6 +431,11 @@ public class WindowDecorActionBar extends ActionBar implements mDecorToolbar.setTitle(title); } + @Override + public void setWindowTitle(CharSequence title) { + mDecorToolbar.setWindowTitle(title); + } + public void setSubtitle(CharSequence subtitle) { mDecorToolbar.setSubtitle(subtitle); } diff --git a/core/java/com/android/internal/os/RuntimeInit.java b/core/java/com/android/internal/os/RuntimeInit.java index d35fce4..29ccb6a 100644 --- a/core/java/com/android/internal/os/RuntimeInit.java +++ b/core/java/com/android/internal/os/RuntimeInit.java @@ -338,10 +338,10 @@ public class RuntimeInit { * @param tag to record with the error * @param t exception describing the error site and conditions */ - public static void wtf(String tag, Throwable t) { + public static void wtf(String tag, Throwable t, boolean system) { try { if (ActivityManagerNative.getDefault().handleApplicationWtf( - mApplicationObject, tag, new ApplicationErrorReport.CrashInfo(t))) { + mApplicationObject, tag, system, new ApplicationErrorReport.CrashInfo(t))) { // The Activity Manager has already written us off -- now exit. Process.killProcess(Process.myPid()); System.exit(10); diff --git a/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java b/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java index 5da5ae9..250bbac 100644 --- a/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java +++ b/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java @@ -162,6 +162,8 @@ public class ToolbarWidgetWrapper implements DecorToolbar { } a.recycle(); + } else { + mDisplayOpts = detectDisplayOptions(); } if (TextUtils.isEmpty(mToolbar.getNavigationContentDescription())) { @@ -181,6 +183,15 @@ public class ToolbarWidgetWrapper implements DecorToolbar { }); } + private int detectDisplayOptions() { + int opts = ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | + ActionBar.DISPLAY_USE_LOGO; + if (mToolbar.getNavigationIcon() != null) { + opts |= ActionBar.DISPLAY_HOME_AS_UP; + } + return opts; + } + @Override public ViewGroup getViewGroup() { return mToolbar; diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index a8b8bef..62d8036 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -879,9 +879,17 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) parseRuntimeOption("dalvik.vm.profile.max-stack-depth", profileMaxStackDepth, "-Xprofile-max-stack-depth:"); - } - parseRuntimeOption("ro.dalvik.vm.native.bridge", nativeBridgeLibrary, "-XX:NativeBridge="); + // Native bridge library. "0" means that native bridge is disabled. + property_get("ro.dalvik.vm.native.bridge", propBuf, ""); + if (propBuf[0] == '\0') { + ALOGW("ro.dalvik.vm.native.bridge is not expected to be empty"); + } else if (strcmp(propBuf, "0") != 0) { + snprintf(nativeBridgeLibrary, sizeof("-XX:NativeBridge=") + PROPERTY_VALUE_MAX, + "-XX:NativeBridge=%s", propBuf); + addOption(nativeBridgeLibrary); + } + } initArgs.version = JNI_VERSION_1_4; initArgs.options = mOptions.editArray(); 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); diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 672ad84..7c5233c 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -2208,7 +2208,7 @@ <permission android:name="android.permission.MODIFY_PARENTAL_CONTROLS" android:label="@string/permlab_modifyParentalControls" android:description="@string/permdesc_modifyParentalControls" - android:protectionLevel="signature" /> + android:protectionLevel="signature|system" /> <!-- Must be required by device administration receiver, to ensure that only the system can interact with it. --> diff --git a/core/res/res/layout/preference_material.xml b/core/res/res/layout/preference_material.xml index 3919f5f..778e70a 100644 --- a/core/res/res/layout/preference_material.xml +++ b/core/res/res/layout/preference_material.xml @@ -20,58 +20,62 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:minHeight="?android:attr/listPreferredItemHeightSmall" + android:minHeight="?attr/listPreferredItemHeightSmall" android:gravity="center_vertical" android:paddingStart="?attr/listPreferredItemPaddingStart" android:paddingEnd="?attr/listPreferredItemPaddingEnd" - android:background="?android:attr/activatedBackgroundIndicator"> + android:background="?attr/activatedBackgroundIndicator"> <LinearLayout - android:id="@+android:id/icon_frame" + android:id="@+id/icon_frame" android:layout_width="wrap_content" android:layout_height="match_parent" - android:minWidth="58dip" + android:layout_marginStart="-4dp" + android:minWidth="60dp" android:gravity="start|center_vertical" - android:orientation="horizontal"> + android:orientation="horizontal" + android:paddingEnd="12dp" + android:paddingTop="4dp" + android:paddingBottom="4dp"> <ImageView - android:id="@+android:id/icon" + android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:scaleType="centerInside" - android:layout_marginEnd="8dip" /> + android:maxWidth="48dp" + android:maxHeight="48dp" /> </LinearLayout> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" - android:paddingTop="16dip" - android:paddingBottom="16dip"> + android:paddingTop="16dp" + android:paddingBottom="16dp"> - <TextView android:id="@+android:id/title" + <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" - android:textAppearance="?android:attr/textAppearanceListItem" + android:textAppearance="?attr/textAppearanceListItem" android:ellipsize="marquee" /> - <TextView android:id="@+android:id/summary" + <TextView android:id="@+id/summary" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_below="@android:id/title" - android:layout_alignStart="@android:id/title" - android:textAppearance="?android:attr/textAppearanceListItemSecondary" - android:textColor="?android:attr/textColorSecondary" + android:layout_below="@id/title" + android:layout_alignStart="@id/title" + android:textAppearance="?attr/textAppearanceListItemSecondary" + android:textColor="?attr/textColorSecondary" android:maxLines="10" /> </RelativeLayout> <!-- Preference should place its actual preference widget here. --> - <LinearLayout android:id="@+android:id/widget_frame" + <LinearLayout android:id="@+id/widget_frame" android:layout_width="wrap_content" android:layout_height="match_parent" - android:minWidth="58dip" android:gravity="end|center_vertical" + android:paddingStart="16dp" android:orientation="vertical" /> </LinearLayout> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 4f0757c..af213ba 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -26,6 +26,7 @@ <item><xliff:g id="id">ime</xliff:g></item> <item><xliff:g id="id">sync_failing</xliff:g></item> <item><xliff:g id="id">sync_active</xliff:g></item> + <item><xliff:g id="id">cast</xliff:g></item> <item><xliff:g id="id">location</xliff:g></item> <item><xliff:g id="id">bluetooth</xliff:g></item> <item><xliff:g id="id">nfc</xliff:g></item> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 82125fe..35658cf 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -2535,12 +2535,17 @@ <public type="style" name="TextAppearance.StatusBar.Material.EventContent.Time" /> <public type="style" name="TextAppearance.StatusBar.Material.EventContent.Emphasis" /> - <public type="style" name="Widget.Material.Spinner.Form" /> - <public type="style" name="Widget.Material.Light.Spinner.Form" /> + <public type="style" name="Widget.Material.Spinner.Underlined" /> + <public type="style" name="Widget.Material.Light.Spinner.Underlined" /> <public type="style" name="TextAppearance.Material.Widget.Toolbar.Title" /> <public type="style" name="TextAppearance.Material.Widget.Toolbar.Subtitle" /> + <public type="style" name="Theme.Material.Dialog.Alert" /> + <public type="style" name="Theme.Material.Dialog.Presentation" /> + <public type="style" name="Theme.Material.Light.Dialog.Alert" /> + <public type="style" name="Theme.Material.Light.Dialog.Presentation" /> + <public-padding type="string" name="l_resource_pad" end="0x01040030" /> <public type="string" name="config_webSettingsDefaultTextEncoding" /> diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml index fb70d6b..3ee5552 100644 --- a/core/res/res/values/styles_material.xml +++ b/core/res/res/values/styles_material.xml @@ -308,7 +308,7 @@ please see styles_device_defaults.xml. <style name="TextAppearance.Material.Widget.TextView.PopupMenu" parent="TextAppearance.Material.Menu" /> <style name="TextAppearance.Material.Widget.TextView.SpinnerItem" /> - <style name="TextAppearance.Material.Widget.DropDownItem"> + <style name="TextAppearance.Material.Widget.DropDownItem" parent="TextAppearance.Material.Menu"> <item name="textColor">?attr/textColorPrimaryDisableOnly</item> </style> @@ -759,7 +759,7 @@ please see styles_device_defaults.xml. <item name="overlapAnchor">true</item> </style> - <style name="Widget.Material.Spinner.Form"> + <style name="Widget.Material.Spinner.Underlined"> <item name="background">@drawable/spinner_textfield_background_material</item> </style> @@ -1022,7 +1022,7 @@ please see styles_device_defaults.xml. <style name="Widget.Material.Light.Spinner" parent="Widget.Material.Spinner" /> <style name="Widget.Material.Light.Spinner.DropDown" parent="Widget.Material.Spinner.DropDown"/> <style name="Widget.Material.Light.Spinner.DropDown.ActionBar" parent="Widget.Material.Spinner.DropDown.ActionBar"/> - <style name="Widget.Material.Light.Spinner.Form" parent="Widget.Material.Spinner.Form" /> + <style name="Widget.Material.Light.Spinner.Underlined" parent="Widget.Material.Spinner.Underlined" /> <style name="Widget.Material.Light.TabWidget" parent="Widget.Material.TabWidget"/> <style name="Widget.Material.Light.WebTextView" parent="Widget.Material.WebTextView"/> <style name="Widget.Material.Light.WebView" parent="Widget.Material.WebView"/> |