diff options
Diffstat (limited to 'core/java')
9 files changed, 198 insertions, 42 deletions
diff --git a/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java b/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java index 161c339..834a587 100644 --- a/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java +++ b/core/java/android/bluetooth/BluetoothActivityEnergyInfo.java @@ -28,10 +28,10 @@ import android.os.Parcelable; public final class BluetoothActivityEnergyInfo implements Parcelable { private final long mTimestamp; private final int mBluetoothStackState; - private final int mControllerTxTimeMs; - private final int mControllerRxTimeMs; - private final int mControllerIdleTimeMs; - private final int mControllerEnergyUsed; + private final long mControllerTxTimeMs; + private final long mControllerRxTimeMs; + private final long mControllerIdleTimeMs; + private final long mControllerEnergyUsed; public static final int BT_STACK_STATE_INVALID = 0; public static final int BT_STACK_STATE_STATE_ACTIVE = 1; @@ -39,7 +39,7 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { public static final int BT_STACK_STATE_STATE_IDLE = 3; public BluetoothActivityEnergyInfo(long timestamp, int stackState, - int txTime, int rxTime, int idleTime, int energyUsed) { + long txTime, long rxTime, long idleTime, long energyUsed) { mTimestamp = timestamp; mBluetoothStackState = stackState; mControllerTxTimeMs = txTime; @@ -65,10 +65,10 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { public BluetoothActivityEnergyInfo createFromParcel(Parcel in) { long timestamp = in.readLong(); int stackState = in.readInt(); - int txTime = in.readInt(); - int rxTime = in.readInt(); - int idleTime = in.readInt(); - int energyUsed = in.readInt(); + long txTime = in.readLong(); + long rxTime = in.readLong(); + long idleTime = in.readLong(); + long energyUsed = in.readLong(); return new BluetoothActivityEnergyInfo(timestamp, stackState, txTime, rxTime, idleTime, energyUsed); } @@ -80,10 +80,10 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { public void writeToParcel(Parcel out, int flags) { out.writeLong(mTimestamp); out.writeInt(mBluetoothStackState); - out.writeInt(mControllerTxTimeMs); - out.writeInt(mControllerRxTimeMs); - out.writeInt(mControllerIdleTimeMs); - out.writeInt(mControllerEnergyUsed); + out.writeLong(mControllerTxTimeMs); + out.writeLong(mControllerRxTimeMs); + out.writeLong(mControllerIdleTimeMs); + out.writeLong(mControllerEnergyUsed); } public int describeContents() { @@ -100,21 +100,21 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { /** * @return tx time in ms */ - public int getControllerTxTimeMillis() { + public long getControllerTxTimeMillis() { return mControllerTxTimeMs; } /** * @return rx time in ms */ - public int getControllerRxTimeMillis() { + public long getControllerRxTimeMillis() { return mControllerRxTimeMs; } /** * @return idle time in ms */ - public int getControllerIdleTimeMillis() { + public long getControllerIdleTimeMillis() { return mControllerIdleTimeMs; } @@ -122,7 +122,7 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { * product of current(mA), voltage(V) and time(ms) * @return energy used */ - public int getControllerEnergyUsed() { + public long getControllerEnergyUsed() { return mControllerEnergyUsed; } @@ -137,8 +137,8 @@ public final class BluetoothActivityEnergyInfo implements Parcelable { * @return if the record is valid */ public boolean isValid() { - return ((getControllerTxTimeMillis() !=0) || - (getControllerRxTimeMillis() !=0) || - (getControllerIdleTimeMillis() !=0)); + return ((mControllerTxTimeMs !=0) || + (mControllerRxTimeMs !=0) || + (mControllerIdleTimeMs !=0)); } } diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java index 04510d9..152bc22 100644 --- a/core/java/android/hardware/camera2/CameraCharacteristics.java +++ b/core/java/android/hardware/camera2/CameraCharacteristics.java @@ -1109,13 +1109,13 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri /** * <p>The correction coefficients to correct for this camera device's * radial and tangential lens distortion.</p> - * <p>Three radial distortion coefficients <code>[kappa_1, kappa_2, + * <p>Four radial distortion coefficients <code>[kappa_0, kappa_1, kappa_2, * kappa_3]</code> and two tangential distortion coefficients * <code>[kappa_4, kappa_5]</code> that can be used to correct the * lens's geometric distortion with the mapping equations:</p> - * <pre><code> x_c = x_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) + + * <pre><code> x_c = x_i * ( kappa_0 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) + * kappa_4 * (2 * x_i * y_i) + kappa_5 * ( r^2 + 2 * x_i^2 ) - * y_c = y_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) + + * y_c = y_i * ( kappa_0 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) + * kappa_5 * (2 * x_i * y_i) + kappa_4 * ( r^2 + 2 * y_i^2 ) * </code></pre> * <p>Here, <code>[x_c, y_c]</code> are the coordinates to sample in the diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java index 3bb2fdb..479583c 100644 --- a/core/java/android/hardware/camera2/CaptureResult.java +++ b/core/java/android/hardware/camera2/CaptureResult.java @@ -2671,13 +2671,13 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { /** * <p>The correction coefficients to correct for this camera device's * radial and tangential lens distortion.</p> - * <p>Three radial distortion coefficients <code>[kappa_1, kappa_2, + * <p>Four radial distortion coefficients <code>[kappa_0, kappa_1, kappa_2, * kappa_3]</code> and two tangential distortion coefficients * <code>[kappa_4, kappa_5]</code> that can be used to correct the * lens's geometric distortion with the mapping equations:</p> - * <pre><code> x_c = x_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) + + * <pre><code> x_c = x_i * ( kappa_0 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) + * kappa_4 * (2 * x_i * y_i) + kappa_5 * ( r^2 + 2 * x_i^2 ) - * y_c = y_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) + + * y_c = y_i * ( kappa_0 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) + * kappa_5 * (2 * x_i * y_i) + kappa_4 * ( r^2 + 2 * y_i^2 ) * </code></pre> * <p>Here, <code>[x_c, y_c]</code> are the coordinates to sample in the diff --git a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java index 8512b23..a1ebe6a 100644 --- a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java +++ b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java @@ -2053,8 +2053,10 @@ public class CameraDeviceImpl extends CameraDevice { requestMetadata, /*reprocess*/false, CameraCaptureSession.SESSION_ID_NONE); // Overwrite the capture intent to make sure a good value is set. - Surface[] surfaces = (Surface[])outputSurfaces.toArray(); - if (outputSurfaces.size() == 1 && SurfaceUtils.isSurfaceForHwVideoEncoder(surfaces[0])) { + Iterator<Surface> iterator = outputSurfaces.iterator(); + Surface firstSurface = iterator.next(); + Surface secondSurface = null; + if (outputSurfaces.size() == 1 && SurfaceUtils.isSurfaceForHwVideoEncoder(firstSurface)) { singleTargetRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_PREVIEW); } else { @@ -2071,19 +2073,20 @@ public class CameraDeviceImpl extends CameraDevice { requestMetadata, /*reprocess*/false, CameraCaptureSession.SESSION_ID_NONE); doubleTargetRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_VIDEO_RECORD); - doubleTargetRequestBuilder.addTarget(surfaces[0]); - doubleTargetRequestBuilder.addTarget(surfaces[1]); + doubleTargetRequestBuilder.addTarget(firstSurface); + secondSurface = iterator.next(); + doubleTargetRequestBuilder.addTarget(secondSurface); doubleTargetRequestBuilder.setPartOfCHSRequestList(/*partOfCHSList*/true); // Make sure singleTargetRequestBuilder contains only recording surface for // preview + recording case. - Surface recordingSurface = surfaces[0]; + Surface recordingSurface = firstSurface; if (!SurfaceUtils.isSurfaceForHwVideoEncoder(recordingSurface)) { - recordingSurface = surfaces[1]; + recordingSurface = secondSurface; } singleTargetRequestBuilder.addTarget(recordingSurface); } else { // Single output case: either recording or preview. - singleTargetRequestBuilder.addTarget(surfaces[0]); + singleTargetRequestBuilder.addTarget(firstSurface); } // Generate the final request list. diff --git a/core/java/android/text/style/TtsSpan.java b/core/java/android/text/style/TtsSpan.java index c40f11f..93a156b 100644 --- a/core/java/android/text/style/TtsSpan.java +++ b/core/java/android/text/style/TtsSpan.java @@ -165,7 +165,7 @@ public class TtsSpan implements ParcelableSpan { /** * The text associated with this span is a series of characters that have to - * be read verbatim. The engine will attempt to ready out any character like + * be read verbatim. The engine will attempt to read out any character like * punctuation but excluding whitespace. {@link #ARG_VERBATIM} is required. * Also accepts the arguments {@link #ARG_GENDER}, * {@link #ARG_ANIMACY}, {@link #ARG_MULTIPLICITY} and {@link #ARG_CASE}. diff --git a/core/java/android/transition/Explode.java b/core/java/android/transition/Explode.java index 788676a..3445ef2 100644 --- a/core/java/android/transition/Explode.java +++ b/core/java/android/transition/Explode.java @@ -90,7 +90,7 @@ public class Explode extends Visibility { float startY = endY + mTempLoc[1]; return TranslationAnimationCreator.createAnimation(view, endValues, bounds.left, bounds.top, - startX, startY, endX, endY, sDecelerate); + startX, startY, endX, endY, sDecelerate, this); } @Override @@ -119,7 +119,7 @@ public class Explode extends Visibility { endY += mTempLoc[1]; return TranslationAnimationCreator.createAnimation(view, startValues, - viewPosX, viewPosY, startX, startY, endX, endY, sAccelerate); + viewPosX, viewPosY, startX, startY, endX, endY, sAccelerate, this); } private void calculateOut(View sceneRoot, Rect bounds, int[] outVector) { diff --git a/core/java/android/transition/Slide.java b/core/java/android/transition/Slide.java index be1d907..9063b43 100644 --- a/core/java/android/transition/Slide.java +++ b/core/java/android/transition/Slide.java @@ -231,7 +231,7 @@ public class Slide extends Visibility { float startY = mSlideCalculator.getGoneY(sceneRoot, view); return TranslationAnimationCreator .createAnimation(view, endValues, position[0], position[1], - startX, startY, endX, endY, sDecelerate); + startX, startY, endX, endY, sDecelerate, this); } @Override @@ -247,6 +247,6 @@ public class Slide extends Visibility { float endY = mSlideCalculator.getGoneY(sceneRoot, view); return TranslationAnimationCreator .createAnimation(view, startValues, position[0], position[1], - startX, startY, endX, endY, sAccelerate); + startX, startY, endX, endY, sAccelerate, this); } } diff --git a/core/java/android/transition/TranslationAnimationCreator.java b/core/java/android/transition/TranslationAnimationCreator.java index de71fd7..1554975 100644 --- a/core/java/android/transition/TranslationAnimationCreator.java +++ b/core/java/android/transition/TranslationAnimationCreator.java @@ -22,6 +22,7 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.TimeInterpolator; import android.graphics.Path; +import android.transition.Transition.TransitionListener; import android.view.View; /** @@ -48,7 +49,8 @@ class TranslationAnimationCreator { * a previous interruption, in which case it moves from the current position to (endX, endY). */ static Animator createAnimation(View view, TransitionValues values, int viewPosX, int viewPosY, - float startX, float startY, float endX, float endY, TimeInterpolator interpolator) { + float startX, float startY, float endX, float endY, TimeInterpolator interpolator, + Transition transition) { float terminalX = view.getTranslationX(); float terminalY = view.getTranslationY(); int[] startPosition = (int[]) values.view.getTag(R.id.transitionPosition); @@ -73,13 +75,15 @@ class TranslationAnimationCreator { TransitionPositionListener listener = new TransitionPositionListener(view, values.view, startPosX, startPosY, terminalX, terminalY); + transition.addListener(listener); anim.addListener(listener); anim.addPauseListener(listener); anim.setInterpolator(interpolator); return anim; } - private static class TransitionPositionListener extends AnimatorListenerAdapter { + private static class TransitionPositionListener extends AnimatorListenerAdapter implements + TransitionListener { private final View mViewInHierarchy; private final View mMovingView; @@ -117,8 +121,6 @@ class TranslationAnimationCreator { @Override public void onAnimationEnd(Animator animator) { - mMovingView.setTranslationX(mTerminalX); - mMovingView.setTranslationY(mTerminalY); } @Override @@ -134,6 +136,28 @@ class TranslationAnimationCreator { mMovingView.setTranslationX(mPausedX); mMovingView.setTranslationY(mPausedY); } + + @Override + public void onTransitionStart(Transition transition) { + } + + @Override + public void onTransitionEnd(Transition transition) { + mMovingView.setTranslationX(mTerminalX); + mMovingView.setTranslationY(mTerminalY); + } + + @Override + public void onTransitionCancel(Transition transition) { + } + + @Override + public void onTransitionPause(Transition transition) { + } + + @Override + public void onTransitionResume(Transition transition) { + } } } diff --git a/core/java/com/android/internal/app/AssistUtils.java b/core/java/com/android/internal/app/AssistUtils.java new file mode 100644 index 0000000..b520384 --- /dev/null +++ b/core/java/com/android/internal/app/AssistUtils.java @@ -0,0 +1,129 @@ +/* + * 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 com.android.internal.app; + +import android.app.SearchManager; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.provider.Settings; +import android.util.Log; + +/** + * Utility method for dealing with the assistant aspects of + * {@link com.android.internal.app.IVoiceInteractionManagerService IVoiceInteractionManagerService}. + */ +public class AssistUtils { + + private static final String TAG = "AssistUtils"; + + private final Context mContext; + private final IVoiceInteractionManagerService mVoiceInteractionManagerService; + + public AssistUtils(Context context) { + mContext = context; + mVoiceInteractionManagerService = IVoiceInteractionManagerService.Stub.asInterface( + ServiceManager.getService(Context.VOICE_INTERACTION_MANAGER_SERVICE)); + } + + public void showSessionForActiveService(IVoiceInteractionSessionShowCallback showCallback) { + try { + mVoiceInteractionManagerService.showSessionForActiveService(showCallback); + } catch (RemoteException e) { + Log.w(TAG, "Failed to call showSessionForActiveService", e); + } + } + + public void launchVoiceAssistFromKeyguard() { + try { + mVoiceInteractionManagerService.launchVoiceAssistFromKeyguard(); + } catch (RemoteException e) { + Log.w(TAG, "Failed to call launchVoiceAssistFromKeyguard", e); + } + } + + public boolean activeServiceSupportsAssistGesture() { + try { + return mVoiceInteractionManagerService != null + && mVoiceInteractionManagerService.activeServiceSupportsAssist(); + } catch (RemoteException e) { + Log.w(TAG, "Failed to call activeServiceSupportsAssistGesture", e); + return false; + } + } + + public boolean activeServiceSupportsLaunchFromKeyguard() { + try { + return mVoiceInteractionManagerService != null + && mVoiceInteractionManagerService.activeServiceSupportsLaunchFromKeyguard(); + } catch (RemoteException e) { + Log.w(TAG, "Failed to call activeServiceSupportsLaunchFromKeyguard", e); + return false; + } + } + + public ComponentName getActiveServiceComponentName() { + try { + return mVoiceInteractionManagerService.getActiveServiceComponentName(); + } catch (RemoteException e) { + Log.w(TAG, "Failed to call getActiveServiceComponentName", e); + return null; + } + } + + public boolean isSessionRunning() { + try { + return mVoiceInteractionManagerService != null + && mVoiceInteractionManagerService.isSessionRunning(); + } catch (RemoteException e) { + Log.w(TAG, "Failed to call isSessionRunning", e); + return false; + } + } + + public void hideCurrentSession() { + try { + mVoiceInteractionManagerService.hideCurrentSession(); + } catch (RemoteException e) { + Log.w(TAG, "Failed to call hideCurrentSession", e); + } + } + + public ComponentName getAssistComponentForUser(int userId) { + final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(), + Settings.Secure.ASSISTANT, userId); + if (setting != null) { + return ComponentName.unflattenFromString(setting); + } + + // Fallback to keep backward compatible behavior when there is no user setting. + if (activeServiceSupportsAssistGesture()) { + return getActiveServiceComponentName(); + } + + Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) + .getAssistIntent(mContext, false, userId); + if (intent != null) { + return intent.getComponent(); + } + + return null; + } + +} |