diff options
Diffstat (limited to 'core/java')
10 files changed, 131 insertions, 79 deletions
diff --git a/core/java/android/hardware/hdmi/HdmiClient.java b/core/java/android/hardware/hdmi/HdmiClient.java index c43e21a..5d26a57 100644 --- a/core/java/android/hardware/hdmi/HdmiClient.java +++ b/core/java/android/hardware/hdmi/HdmiClient.java @@ -1,5 +1,6 @@ package android.hardware.hdmi; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.hardware.hdmi.HdmiControlManager.VendorCommandListener; import android.hardware.hdmi.IHdmiVendorCommandListener; @@ -25,6 +26,21 @@ public abstract class HdmiClient { } /** + * Returns the active source information. + * + * @return {@link HdmiCecDeviceInfo} object that describes the active source + * or active routing path + */ + public HdmiCecDeviceInfo getActiveSource() { + try { + return mService.getActiveSource(); + } catch (RemoteException e) { + Log.e(TAG, "getActiveSource threw exception ", e); + } + return null; + } + + /** * Send a key event to other logical device. * * @param keyCode key code to send. Defined in {@link android.view.KeyEvent}. @@ -60,7 +76,10 @@ public abstract class HdmiClient { * * @param listener listener object */ - public void addVendorCommandListener(VendorCommandListener listener) { + public void addVendorCommandListener(@NonNull VendorCommandListener listener) { + if (listener == null) { + throw new IllegalArgumentException("listener cannot be null"); + } try { mService.addVendorCommandListener(getListenerWrapper(listener), getDeviceType()); } catch (RemoteException e) { diff --git a/core/java/android/hardware/hdmi/HdmiControlManager.java b/core/java/android/hardware/hdmi/HdmiControlManager.java index a4a3ac3..e7bd3e4 100644 --- a/core/java/android/hardware/hdmi/HdmiControlManager.java +++ b/core/java/android/hardware/hdmi/HdmiControlManager.java @@ -245,7 +245,30 @@ public final class HdmiControlManager { } /** - * Gets an object that represents a HDMI-CEC logical device of type playback on the system. + * Gets an object that represents an HDMI-CEC logical device of a specified type. + * + * @param type CEC device type + * @return {@link HdmiClient} instance. {@code null} on failure. + * @see {@link HdmiCecDeviceInfo#DEVICE_PLAYBACK} + * @see {@link HdmiCecDeviceInfo#DEVICE_TV} + */ + @Nullable + public HdmiClient getClient(int type) { + if (mService == null) { + return null; + } + switch (type) { + case HdmiCecDeviceInfo.DEVICE_TV: + return mHasTvDevice ? new HdmiTvClient(mService) : null; + case HdmiCecDeviceInfo.DEVICE_PLAYBACK: + return mHasPlaybackDevice ? new HdmiPlaybackClient(mService) : null; + default: + return null; + } + } + + /** + * Gets an object that represents an HDMI-CEC logical device of type playback on the system. * * <p>Used to send HDMI control messages to other devices like TV or audio amplifier through * HDMI bus. It is also possible to communicate with other logical devices hosted in the same @@ -255,14 +278,11 @@ public final class HdmiControlManager { */ @Nullable public HdmiPlaybackClient getPlaybackClient() { - if (mService == null || !mHasPlaybackDevice) { - return null; - } - return new HdmiPlaybackClient(mService); + return (HdmiPlaybackClient) getClient(HdmiCecDeviceInfo.DEVICE_PLAYBACK); } /** - * Gets an object that represents a HDMI-CEC logical device of type TV on the system. + * Gets an object that represents an HDMI-CEC logical device of type TV on the system. * * <p>Used to send HDMI control messages to other devices and manage them through * HDMI bus. It is also possible to communicate with other logical devices hosted in the same @@ -272,10 +292,7 @@ public final class HdmiControlManager { */ @Nullable public HdmiTvClient getTvClient() { - if (mService == null || !mHasTvDevice) { - return null; - } - return new HdmiTvClient(mService); + return (HdmiTvClient) getClient(HdmiCecDeviceInfo.DEVICE_TV); } /** diff --git a/core/java/android/hardware/hdmi/HdmiRecordListener.java b/core/java/android/hardware/hdmi/HdmiRecordListener.java index fe44bd9..105a8ca 100644 --- a/core/java/android/hardware/hdmi/HdmiRecordListener.java +++ b/core/java/android/hardware/hdmi/HdmiRecordListener.java @@ -147,8 +147,8 @@ public abstract class HdmiRecordListener { * <li>{@link HdmiControlManager#TIMER_STATUS_PROGRAMMED_INFO_NO_MEDIA_INFO} * </ul> * - * @throw {@link IllegalStateException} if it's called when {@link #isProgrammed()} - * returns false + * @throws IllegalStateException if it's called when {@link #isProgrammed()} + * returns false */ public int getProgrammedInfo() { if (!isProgrammed()) { @@ -175,8 +175,8 @@ public abstract class HdmiRecordListener { * <li>{@link HdmiControlManager#TIMER_STATUS_NOT_PROGRAMMED_DUPLICATED} * </ul> * - * @throw {@link IllegalStateException} if it's called when {@link #isProgrammed()} - * returns true + * @throws IllegalStateException if it's called when {@link #isProgrammed()} + * returns true */ public int getNotProgammedError() { if (isProgrammed()) { diff --git a/core/java/android/hardware/hdmi/HdmiRecordSources.java b/core/java/android/hardware/hdmi/HdmiRecordSources.java index 917d1d9..dcc41fa 100644 --- a/core/java/android/hardware/hdmi/HdmiRecordSources.java +++ b/core/java/android/hardware/hdmi/HdmiRecordSources.java @@ -71,7 +71,7 @@ public final class HdmiRecordSources { return includeType ? mExtraDataSize + 1 : mExtraDataSize; } - public final int toByteArray(boolean includeType, byte[] data, int index) { + final int toByteArray(boolean includeType, byte[] data, int index) { if (includeType) { // 1 to 8 bytes (depends on source). // {[Record Source Type]} | @@ -161,7 +161,7 @@ public final class HdmiRecordSources { * Interface for digital source identification. */ private interface DigitalServiceIdentification { - void toByteArray(byte[] data, int index); + int toByteArray(byte[] data, int index); } /** @@ -193,8 +193,9 @@ public final class HdmiRecordSources { } @Override - public void toByteArray(byte[] data, int index) { - threeFieldsToSixBytes(mTransportStreamId, mServiceId, mOriginalNetworkId, data, index); + public int toByteArray(byte[] data, int index) { + return threeFieldsToSixBytes(mTransportStreamId, mServiceId, mOriginalNetworkId, data, + index); } } @@ -221,8 +222,8 @@ public final class HdmiRecordSources { } @Override - public void toByteArray(byte[] data, int index) { - threeFieldsToSixBytes(mTransportStreamId, mProgramNumber, 0, data, index); + public int toByteArray(byte[] data, int index) { + return threeFieldsToSixBytes(mTransportStreamId, mProgramNumber, 0, data, index); } } @@ -255,8 +256,9 @@ public final class HdmiRecordSources { } @Override - public void toByteArray(byte[] data, int index) { - threeFieldsToSixBytes(mTransportStreamId, mServiceId, mOriginalNetworkId, data, index); + public int toByteArray(byte[] data, int index) { + return threeFieldsToSixBytes(mTransportStreamId, mServiceId, mOriginalNetworkId, data, + index); } } @@ -283,12 +285,13 @@ public final class HdmiRecordSources { mMinorChannelNumber = minorNumer; } - private void toByteArray(byte[] data, int index) { + private int toByteArray(byte[] data, int index) { // The first 6 bits for format, the 10 bits for major number. data[index] = (byte) (((mChannelNumberFormat << 2) | (mMajorChannelNumber >>> 8) & 0x3)); data[index + 1] = (byte) (mMajorChannelNumber & 0xFF); // Minor number uses the next 16 bits. shortToByteArray((short) mMinorChannelNumber, data, index + 2); + return 4; } } @@ -323,11 +326,12 @@ public final class HdmiRecordSources { } @Override - public void toByteArray(byte[] data, int index) { + public int toByteArray(byte[] data, int index) { mChannelIdentifier.toByteArray(data, index); // The last 2 bytes is reserved for future use. data[index + 4] = 0; data[index + 5] = 0; + return 6; } } diff --git a/core/java/android/hardware/hdmi/HdmiTimerRecordSources.java b/core/java/android/hardware/hdmi/HdmiTimerRecordSources.java index db2d6d8..1780707 100644 --- a/core/java/android/hardware/hdmi/HdmiTimerRecordSources.java +++ b/core/java/android/hardware/hdmi/HdmiTimerRecordSources.java @@ -210,7 +210,7 @@ public class HdmiTimerRecordSources { * @hide */ @SystemApi - public static class Time extends TimeUnit { + public static final class Time extends TimeUnit { private Time(int hour, int minute) { super(hour, minute); } @@ -221,7 +221,7 @@ public class HdmiTimerRecordSources { * @hide */ @SystemApi - public static class Duration extends TimeUnit { + public static final class Duration extends TimeUnit { private Duration(int hour, int minute) { super(hour, minute); } @@ -298,7 +298,7 @@ public class HdmiTimerRecordSources { * @hide */ @SystemApi - public static class TimerInfo { + public static final class TimerInfo { private static final int DAY_OF_MONTH_SIZE = 1; private static final int MONTH_OF_YEAR_SIZE = 1; private static final int START_TIME_SIZE = 2; // 1byte for hour and 1byte for minute. @@ -373,7 +373,7 @@ public class HdmiTimerRecordSources { * @hide */ @SystemApi - public static class TimerRecordSource { + public static final class TimerRecordSource { private final RecordSource mRecordSource; private final TimerInfo mTimerInfo; diff --git a/core/java/android/hardware/hdmi/HdmiTvClient.java b/core/java/android/hardware/hdmi/HdmiTvClient.java index 2735108..077a17e 100644 --- a/core/java/android/hardware/hdmi/HdmiTvClient.java +++ b/core/java/android/hardware/hdmi/HdmiTvClient.java @@ -114,15 +114,14 @@ public final class HdmiTvClient extends HdmiClient { /** * Select a CEC logical device to be a new active source. * - * @param logicalAddress - * @param callback + * @param logicalAddress logical address of the device to select + * @param callback callback to get the result with + * @throws {@link IllegalArgumentException} if the {@code callback} is null */ public void deviceSelect(int logicalAddress, @NonNull SelectCallback callback) { if (callback == null) { throw new IllegalArgumentException("callback must not be null."); } - - // TODO: Replace SelectCallback with PartialResult. try { mService.deviceSelect(logicalAddress, getCallbackWrapper(callback)); } catch (RemoteException e) { @@ -131,6 +130,24 @@ public final class HdmiTvClient extends HdmiClient { } /** + * Select a HDMI port to be a new route path. + * + * @param portId HDMI port to select + * @param callback callback to get the result with + * @throws {@link IllegalArgumentException} if the {@code callback} is null + */ + public void portSelect(int portId, @NonNull SelectCallback callback) { + if (callback == null) { + throw new IllegalArgumentException("Callback must not be null"); + } + try { + mService.portSelect(portId, getCallbackWrapper(callback)); + } catch (RemoteException e) { + Log.e(TAG, "failed to select port: ", e); + } + } + + /** * Set system audio volume * * @param oldIndex current volume index diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java index 0075d0b..7245975 100644 --- a/core/java/android/speech/tts/TextToSpeech.java +++ b/core/java/android/speech/tts/TextToSpeech.java @@ -2029,6 +2029,11 @@ public class TextToSpeech { mParams.putString(Engine.KEY_PARAM_LANGUAGE, defaultLanguage[0]); mParams.putString(Engine.KEY_PARAM_COUNTRY, defaultLanguage[1]); mParams.putString(Engine.KEY_PARAM_VARIANT, defaultLanguage[2]); + + // Get the default voice for the locale. + String defaultVoiceName = mService.getDefaultVoiceNameFor( + defaultLanguage[0], defaultLanguage[1], defaultLanguage[2]); + mParams.putString(Engine.KEY_PARAM_VOICE_NAME, defaultVoiceName); } Log.i(TAG, "Set up connection to " + mName); diff --git a/core/java/android/view/accessibility/AccessibilityManager.java b/core/java/android/view/accessibility/AccessibilityManager.java index 94e2c0e..c3b17db 100644 --- a/core/java/android/view/accessibility/AccessibilityManager.java +++ b/core/java/android/view/accessibility/AccessibilityManager.java @@ -80,41 +80,14 @@ public final class AccessibilityManager { public static final int STATE_FLAG_HIGH_TEXT_CONTRAST_ENABLED = 0x00000004; /** @hide */ - public static final int INVERSION_DISABLED = -1; - - /** @hide */ - public static final int INVERSION_STANDARD = 0; - - /** @hide */ - public static final int INVERSION_HUE_ONLY = 1; - - /** @hide */ - public static final int INVERSION_VALUE_ONLY = 2; - - /** @hide */ public static final int DALTONIZER_DISABLED = -1; /** @hide */ public static final int DALTONIZER_SIMULATE_MONOCHROMACY = 0; /** @hide */ - public static final int DALTONIZER_SIMULATE_PROTANOMALY = 1; - - /** @hide */ - public static final int DALTONIZER_SIMULATE_DEUTERANOMALY = 2; - - /** @hide */ - public static final int DALTONIZER_SIMULATE_TRITANOMALY = 3; - - /** @hide */ - public static final int DALTONIZER_CORRECT_PROTANOMALY = 11; - - /** @hide */ public static final int DALTONIZER_CORRECT_DEUTERANOMALY = 12; - /** @hide */ - public static final int DALTONIZER_CORRECT_TRITANOMALY = 13; - static final Object sInstanceSync = new Object(); private static AccessibilityManager sInstance; @@ -134,16 +107,13 @@ public final class AccessibilityManager { boolean mIsHighTextContrastEnabled; private final CopyOnWriteArrayList<AccessibilityStateChangeListener> - mAccessibilityStateChangeListeners = new CopyOnWriteArrayList< - AccessibilityStateChangeListener>(); + mAccessibilityStateChangeListeners = new CopyOnWriteArrayList<>(); private final CopyOnWriteArrayList<TouchExplorationStateChangeListener> - mTouchExplorationStateChangeListeners = new CopyOnWriteArrayList< - TouchExplorationStateChangeListener>(); + mTouchExplorationStateChangeListeners = new CopyOnWriteArrayList<>(); private final CopyOnWriteArrayList<HighTextContrastChangeListener> - mHighTextContrastStateChangeListeners = new CopyOnWriteArrayList< - HighTextContrastChangeListener>(); + mHighTextContrastStateChangeListeners = new CopyOnWriteArrayList<>(); /** * Listener for the system accessibility state. To listen for changes to the @@ -197,9 +167,13 @@ public final class AccessibilityManager { private final IAccessibilityManagerClient.Stub mClient = new IAccessibilityManagerClient.Stub() { public void setState(int state) { - synchronized (mLock) { - setStateLocked(state); - } + // We do not want to change this immediately as the applicatoin may + // have already checked that accessibility is on and fired an event, + // that is now propagating up the view tree, Hence, if accessibility + // is now off an exception will be thrown. We want to have the exception + // enforcement to guard against apps that fire unnecessary accessibility + // events when accessibility is off. + mHandler.obtainMessage(MyHandler.MSG_SET_STATE, state, 0).sendToTarget(); } }; @@ -393,7 +367,7 @@ public final class AccessibilityManager { @Deprecated public List<ServiceInfo> getAccessibilityServiceList() { List<AccessibilityServiceInfo> infos = getInstalledAccessibilityServiceList(); - List<ServiceInfo> services = new ArrayList<ServiceInfo>(); + List<ServiceInfo> services = new ArrayList<>(); final int infoCount = infos.size(); for (int i = 0; i < infoCount; i++) { AccessibilityServiceInfo info = infos.get(i); @@ -446,6 +420,7 @@ public final class AccessibilityManager { * @see AccessibilityServiceInfo#FEEDBACK_HAPTIC * @see AccessibilityServiceInfo#FEEDBACK_SPOKEN * @see AccessibilityServiceInfo#FEEDBACK_VISUAL + * @see AccessibilityServiceInfo#FEEDBACK_BRAILLE */ public List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList( int feedbackTypeFlags) { @@ -705,6 +680,7 @@ public final class AccessibilityManager { public static final int MSG_NOTIFY_ACCESSIBILITY_STATE_CHANGED = 1; public static final int MSG_NOTIFY_EXPLORATION_STATE_CHANGED = 2; public static final int MSG_NOTIFY_HIGH_TEXT_CONTRAST_STATE_CHANGED = 3; + public static final int MSG_SET_STATE = 4; public MyHandler(Looper looper) { super(looper, null, false); @@ -724,6 +700,14 @@ public final class AccessibilityManager { case MSG_NOTIFY_HIGH_TEXT_CONTRAST_STATE_CHANGED: { handleNotifyHighTextContrastStateChanged(); } break; + + case MSG_SET_STATE: { + // See comment at mClient + final int state = message.arg1; + synchronized (mLock) { + setStateLocked(state); + } + } break; } } } diff --git a/core/java/android/webkit/CookieSyncManager.java b/core/java/android/webkit/CookieSyncManager.java index 1c364c0..d9546ca 100644 --- a/core/java/android/webkit/CookieSyncManager.java +++ b/core/java/android/webkit/CookieSyncManager.java @@ -21,13 +21,6 @@ import android.util.Log; /** - * @deprecated The WebView now automatically syncs cookies as necessary. - * You no longer need to create or use the CookieSyncManager. - * To manually force a sync you can use the CookieManager - * method {@link CookieManager#flush} which is a synchronous - * replacement for {@link #sync}. - * <p> - * * The CookieSyncManager is used to synchronize the browser cookie store * between RAM and permanent storage. To get the best performance, browser cookies are * saved in RAM. A separate thread saves the cookies between, driven by a timer. @@ -61,6 +54,12 @@ import android.util.Log; * WebViewClient#onPageFinished}. Note that even sync() happens * asynchronously, so don't do it just as your activity is shutting * down. + * + * @deprecated The WebView now automatically syncs cookies as necessary. + * You no longer need to create or use the CookieSyncManager. + * To manually force a sync you can use the CookieManager + * method {@link CookieManager#flush} which is a synchronous + * replacement for {@link #sync}. */ @Deprecated public final class CookieSyncManager extends WebSyncManager { diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java index fa16fae..d93ca2c 100644 --- a/core/java/android/webkit/WebViewFactory.java +++ b/core/java/android/webkit/WebViewFactory.java @@ -21,6 +21,7 @@ import android.app.Application; import android.app.AppGlobals; import android.content.Context; import android.content.pm.ApplicationInfo; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Build; import android.os.Process; @@ -109,8 +110,14 @@ public final class WebViewFactory { private static Class<WebViewFactoryProvider> getFactoryClass() throws ClassNotFoundException { Application initialApplication = AppGlobals.getInitialApplication(); try { - Context webViewContext = initialApplication.createPackageContext( - getWebViewPackageName(), + // First fetch the package info so we can log the webview package version. + String packageName = getWebViewPackageName(); + PackageInfo pi = initialApplication.getPackageManager().getPackageInfo(packageName, 0); + Log.i(LOGTAG, "Loading " + packageName + " version " + pi.versionName + + " (code " + pi.versionCode + ")"); + + // Construct a package context to load the Java code into the current app. + Context webViewContext = initialApplication.createPackageContext(packageName, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); initialApplication.getAssets().addAssetPath( webViewContext.getApplicationInfo().sourceDir); |
