diff options
author | Mike Lockwood <lockwood@google.com> | 2012-02-10 15:26:36 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-10 15:26:36 -0800 |
commit | c199e2c7e0f8895273fdd912c5c88495a8b30e35 (patch) | |
tree | 3cc7fa6ff0f78905e27fc3184d3d0904116594ae | |
parent | 0ee0969ffb92d40c290c9da9bfc6f2cd5b1ba3aa (diff) | |
parent | efeba018bde81e02e1255714e3d4eeeb43c055e7 (diff) | |
download | frameworks_base-c199e2c7e0f8895273fdd912c5c88495a8b30e35.zip frameworks_base-c199e2c7e0f8895273fdd912c5c88495a8b30e35.tar.gz frameworks_base-c199e2c7e0f8895273fdd912c5c88495a8b30e35.tar.bz2 |
Merge changes Iefeba018,I1ce5b26d,Ie3f59793,Id3c5e1ec,I9063154a,Ib7bd88a3,I20963df8,I01060b08,I7dc29739,I5c55a051,Ia07aa3c4,I3194ea94,I0dc37cce,Ic3a7bb65,I0a7eaecf,Ifa7b0614,Ice952c8e,Ia5abdb9e,Ifcb310f9,If5f4ec97,I4767690f,I79824179,I6e0f981e,Id60ae7f6
* changes:
EthernetDataTracker: Don't run DHCP or set network available until link is up
Only send master volume or mute updates if the settings have changed
Make AudioManager.adjustMasterVolume public and hidden
Allow disabling network stats support in a resource overlay
Restore persisted master volume if the media server restarts
Don't allow changing master volume when muted
Show the flags in package manager debugging.
Modified the constructor of EndpointBase
Add a getEndpointInfo accessor to AIDL-generated RPC proxy classes
Defer persisting master data to avoid excessive database writes
Add an option that disables the AUDIO_BECOMING_NOISY intent send when a headset is hotplugged.
Remove reference counting and client death notification for master mute
AudioService: Send broadcasts when master volume and mute state change
Use the new get/putFlattenable methods on RpcData.
Don't try to unmarshal void return types when there are out parameters being returned.
AudioManager: Add wrapper methods for master volume support
AudioManager: Add support for master mute
NetworkTimeUpdateService: Schedule NTP on ethernet connect as well as wifi
For events, require that the parameters be marked in.
PhoneWindowManager: stifle warning that ITelephony service does not exist
AudioManager: transparently convert volume settings for other streams to master volume if config_useMasterVolume is set.
Support putting Flattenables in Lists.
Was generating code that uses the wrong RpcData.
store the hw addr in the extraInfo field of ethernet NetworkInfos
20 files changed, 500 insertions, 124 deletions
diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java index 02e81b6..fb09ba5 100644 --- a/core/java/android/net/EthernetDataTracker.java +++ b/core/java/android/net/EthernetDataTracker.java @@ -49,6 +49,7 @@ public class EthernetDataTracker implements NetworkStateTracker { private LinkCapabilities mLinkCapabilities; private NetworkInfo mNetworkInfo; private InterfaceObserver mInterfaceObserver; + private String mHwAddr; /* For sending events to connectivity service handler */ private Handler mCsHandler; @@ -74,6 +75,7 @@ public class EthernetDataTracker implements NetworkStateTracker { if (mIface.equals(iface) && mLinkUp != up) { Log.d(TAG, "Interface " + iface + " link " + (up ? "up" : "down")); mLinkUp = up; + mTracker.mNetworkInfo.setIsAvailable(up); // use DHCP if (up) { @@ -101,10 +103,6 @@ public class EthernetDataTracker implements NetworkStateTracker { mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_ETHERNET, 0, NETWORKTYPE, ""); mLinkProperties = new LinkProperties(); mLinkCapabilities = new LinkCapabilities(); - mLinkUp = false; - - mNetworkInfo.setIsAvailable(false); - setTeardownRequested(false); } private void interfaceAdded(String iface) { @@ -113,7 +111,7 @@ public class EthernetDataTracker implements NetworkStateTracker { Log.d(TAG, "Adding " + iface); - synchronized(mIface) { + synchronized(this) { if(!mIface.isEmpty()) return; mIface = iface; @@ -122,8 +120,6 @@ public class EthernetDataTracker implements NetworkStateTracker { mNetworkInfo.setIsAvailable(true); Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); msg.sendToTarget(); - - runDhcp(); } public void disconnect() { @@ -132,7 +128,7 @@ public class EthernetDataTracker implements NetworkStateTracker { mLinkProperties.clear(); mNetworkInfo.setIsAvailable(false); - mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null, null); + mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null, mHwAddr); Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); msg.sendToTarget(); @@ -154,7 +150,7 @@ public class EthernetDataTracker implements NetworkStateTracker { return; Log.d(TAG, "Removing " + iface); - disconnect(); + disconnect(); mIface = ""; } @@ -169,7 +165,7 @@ public class EthernetDataTracker implements NetworkStateTracker { mLinkProperties = dhcpInfoInternal.makeLinkProperties(); mLinkProperties.setInterfaceName(mIface); - mNetworkInfo.setDetailedState(DetailedState.CONNECTED, null, null); + mNetworkInfo.setDetailedState(DetailedState.CONNECTED, null, mHwAddr); Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo); msg.sendToTarget(); } @@ -216,8 +212,15 @@ public class EthernetDataTracker implements NetworkStateTracker { for (String iface : ifaces) { if (iface.matches(sIfaceMatch)) { mIface = iface; + service.setInterfaceUp(iface); InterfaceConfiguration config = service.getInterfaceConfig(iface); mLinkUp = config.isActive(); + if (config != null && mHwAddr == null) { + mHwAddr = config.getHardwareAddress(); + if (mHwAddr != null) { + mNetworkInfo.setExtraInfo(mHwAddr); + } + } reconnect(); break; } @@ -247,9 +250,11 @@ public class EthernetDataTracker implements NetworkStateTracker { * Re-enable connectivity to a network after a {@link #teardown()}. */ public boolean reconnect() { - mTeardownRequested.set(false); - runDhcp(); - return true; + if (mLinkUp) { + mTeardownRequested.set(false); + runDhcp(); + } + return mLinkUp; } /** diff --git a/core/java/android/net/NetworkInfo.java b/core/java/android/net/NetworkInfo.java index 7286f0d..2f43cb8 100644 --- a/core/java/android/net/NetworkInfo.java +++ b/core/java/android/net/NetworkInfo.java @@ -351,6 +351,18 @@ public class NetworkInfo implements Parcelable { } /** + * Set the extraInfo field. + * @param extraInfo an optional {@code String} providing addditional network state + * information passed up from the lower networking layers. + * @hide + */ + public void setExtraInfo(String extraInfo) { + synchronized (this) { + this.mExtraInfo = extraInfo; + } + } + + /** * Report the reason an attempt to establish connectivity failed, * if one is available. * @return the reason for failure, or null if not available diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java index 0d60d3f..9152cc3 100644 --- a/core/java/android/view/VolumePanel.java +++ b/core/java/android/view/VolumePanel.java @@ -91,9 +91,10 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie private static final int MSG_VIBRATE = 4; private static final int MSG_TIMEOUT = 5; private static final int MSG_RINGER_MODE_CHANGED = 6; + private static final int MSG_MUTE_CHANGED = 7; // Pseudo stream type for master volume - private static final int STREAM_MASTER = -1; + private static final int STREAM_MASTER = -100; protected Context mContext; private AudioManager mAudioManager; @@ -295,45 +296,39 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie private boolean isMuted(int streamType) { if (streamType == STREAM_MASTER) { - // master volume mute not yet supported - return false; + return mAudioService.isMasterMute(); } else { return mAudioService.isStreamMute(streamType); } } private int getStreamMaxVolume(int streamType) { - // master volume is 0.0f - 1.0f, but we will use 0 - 100 internally if (streamType == STREAM_MASTER) { - return 100; + return mAudioService.getMasterMaxVolume(); } else { return mAudioService.getStreamMaxVolume(streamType); } } private int getStreamVolume(int streamType) { - // master volume is 0.0f - 1.0f, but we will use 0 - 100 internally if (streamType == STREAM_MASTER) { - return Math.round(mAudioService.getMasterVolume() * 100); + return mAudioService.getMasterVolume(); } else { return mAudioService.getStreamVolume(streamType); } } private void setStreamVolume(int streamType, int index, int flags) { - // master volume is 0.0f - 1.0f, but we will use 0 - 100 internally if (streamType == STREAM_MASTER) { - mAudioService.setMasterVolume((float)index / 100.0f); + mAudioService.setMasterVolume(index, flags); } else { mAudioService.setStreamVolume(streamType, index, flags); } } private int getLastAudibleStreamVolume(int streamType) { - // master volume is 0.0f - 1.0f, but we will use 0 - 100 internally if (streamType == STREAM_MASTER) { - // master volume mute not yet supported - return getStreamVolume(STREAM_MASTER); + return mAudioService.getLastAudibleMasterVolume(); } else { return mAudioService.getLastAudibleStreamVolume(streamType); } @@ -456,6 +451,19 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie postVolumeChanged(STREAM_MASTER, flags); } + public void postMuteChanged(int streamType, int flags) { + if (hasMessages(MSG_VOLUME_CHANGED)) return; + if (mStreamControls == null) { + createSliders(); + } + removeMessages(MSG_FREE_RESOURCES); + obtainMessage(MSG_MUTE_CHANGED, streamType, flags).sendToTarget(); + } + + public void postMasterMuteChanged(int flags) { + postMuteChanged(STREAM_MASTER, flags); + } + /** * Override this if you have other work to do when the volume changes (for * example, vibrating, playing a sound, etc.). Make sure to call through to @@ -489,6 +497,18 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie resetTimeout(); } + protected void onMuteChanged(int streamType, int flags) { + + if (LOGD) Log.d(TAG, "onMuteChanged(streamType: " + streamType + ", flags: " + flags + ")"); + + StreamControl sc = mStreamControls.get(streamType); + if (sc != null) { + sc.icon.setImageResource(isMuted(sc.streamType) ? sc.iconMuteRes : sc.iconRes); + } + + onVolumeChanged(streamType, flags); + } + protected void onShowVolumeChanged(int streamType, int flags) { int index = isMuted(streamType) ? getLastAudibleStreamVolume(streamType) @@ -687,6 +707,11 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie break; } + case MSG_MUTE_CHANGED: { + onMuteChanged(msg.arg1, msg.arg2); + break; + } + case MSG_FREE_RESOURCES: { onFreeResources(); break; diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index d2207af..87099f8 100755 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -65,6 +65,10 @@ master volume stream and nothing else . --> <bool name="config_useMasterVolume">false</bool> + <!-- Flag indicating whether the AUDIO_BECOMING_NOISY notification should + be sent during an change to the audio output device. --> + <bool name="config_sendAudioBecomingNoisy">true</bool> + <!-- The duration (in milliseconds) of a short animation. --> <integer name="config_shortAnimTime">200</integer> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 381ec7f..6e374e8 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -236,6 +236,7 @@ <java-symbol type="bool" name="split_action_bar_is_narrow" /> <java-symbol type="bool" name="config_useMasterVolume" /> <java-symbol type="bool" name="config_enableWallpaperService" /> + <java-symbol type="bool" name="config_sendAudioBecomingNoisy" /> <java-symbol type="integer" name="config_cursorWindowSize" /> <java-symbol type="integer" name="config_longPressOnPowerBehavior" /> diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 3f5d192..9748d3b 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -91,7 +91,8 @@ public class AudioManager { * @see #EXTRA_VIBRATE_SETTING */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String VIBRATE_SETTING_CHANGED_ACTION = "android.media.VIBRATE_SETTING_CHANGED"; + public static final String VIBRATE_SETTING_CHANGED_ACTION = + "android.media.VIBRATE_SETTING_CHANGED"; /** * @hide Broadcast intent when the volume for a particular stream type changes. @@ -105,6 +106,27 @@ public class AudioManager { public static final String VOLUME_CHANGED_ACTION = "android.media.VOLUME_CHANGED_ACTION"; /** + * @hide Broadcast intent when the master volume changes. + * Includes the new volume + * + * @see #EXTRA_MASTER_VOLUME_VALUE + * @see #EXTRA_PREV_MASTER_VOLUME_VALUE + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String MASTER_VOLUME_CHANGED_ACTION = + "android.media.MASTER_VOLUME_CHANGED_ACTION"; + + /** + * @hide Broadcast intent when the master mute state changes. + * Includes the the new volume + * + * @see #EXTRA_MASTER_VOLUME_MUTED + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String MASTER_MUTE_CHANGED_ACTION = + "android.media.MASTER_MUTE_CHANGED_ACTION"; + + /** * The new vibrate setting for a particular type. * * @see #VIBRATE_SETTING_CHANGED_ACTION @@ -141,6 +163,27 @@ public class AudioManager { public static final String EXTRA_PREV_VOLUME_STREAM_VALUE = "android.media.EXTRA_PREV_VOLUME_STREAM_VALUE"; + /** + * @hide The new master volume value for the master volume changed intent. + * Value is integer between 0 and 100 inclusive. + */ + public static final String EXTRA_MASTER_VOLUME_VALUE = + "android.media.EXTRA_MASTER_VOLUME_VALUE"; + + /** + * @hide The previous master volume value for the master volume changed intent. + * Value is integer between 0 and 100 inclusive. + */ + public static final String EXTRA_PREV_MASTER_VOLUME_VALUE = + "android.media.EXTRA_PREV_MASTER_VOLUME_VALUE"; + + /** + * @hide The new master volume mute state for the master mute changed intent. + * Value is boolean + */ + public static final String EXTRA_MASTER_VOLUME_MUTED = + "android.media.EXTRA_MASTER_VOLUME_MUTED"; + /** The audio stream for phone calls */ public static final int STREAM_VOICE_CALL = AudioSystem.STREAM_VOICE_CALL; /** The audio stream for system sounds */ @@ -372,11 +415,12 @@ public class AudioManager { /** * @hide */ - public void preDispatchKeyEvent(int keyCode, int stream) { + public void preDispatchKeyEvent(KeyEvent event, int stream) { /* * If the user hits another key within the play sound delay, then * cancel the sound */ + int keyCode = event.getKeyCode(); if (keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_VOLUME_UP && keyCode != KeyEvent.KEYCODE_VOLUME_MUTE && mVolumeKeyUpTime + VolumePanel.PLAY_SOUND_DELAY @@ -397,7 +441,8 @@ public class AudioManager { /** * @hide */ - public void handleKeyDown(int keyCode, int stream) { + public void handleKeyDown(KeyEvent event, int stream) { + int keyCode = event.getKeyCode(); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: @@ -426,7 +471,13 @@ public class AudioManager { } break; case KeyEvent.KEYCODE_VOLUME_MUTE: - // TODO: Actually handle MUTE. + if (event.getRepeatCount() == 0) { + if (mUseMasterVolume) { + setMasterMute(!isMasterMute()); + } else { + // TODO: Actually handle MUTE. + } + } break; } } @@ -434,7 +485,8 @@ public class AudioManager { /** * @hide */ - public void handleKeyUp(int keyCode, int stream) { + public void handleKeyUp(KeyEvent event, int stream) { + int keyCode = event.getKeyCode(); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: @@ -460,9 +512,6 @@ public class AudioManager { mVolumeKeyUpTime = SystemClock.uptimeMillis(); break; - case KeyEvent.KEYCODE_VOLUME_MUTE: - // TODO: Actually handle MUTE. - break; } } @@ -485,7 +534,11 @@ public class AudioManager { public void adjustStreamVolume(int streamType, int direction, int flags) { IAudioService service = getService(); try { - service.adjustStreamVolume(streamType, direction, flags); + if (mUseMasterVolume) { + service.adjustMasterVolume(direction, flags); + } else { + service.adjustStreamVolume(streamType, direction, flags); + } } catch (RemoteException e) { Log.e(TAG, "Dead object in adjustStreamVolume", e); } @@ -511,7 +564,11 @@ public class AudioManager { public void adjustVolume(int direction, int flags) { IAudioService service = getService(); try { - service.adjustVolume(direction, flags); + if (mUseMasterVolume) { + service.adjustMasterVolume(direction, flags); + } else { + service.adjustVolume(direction, flags); + } } catch (RemoteException e) { Log.e(TAG, "Dead object in adjustVolume", e); } @@ -537,7 +594,11 @@ public class AudioManager { public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags) { IAudioService service = getService(); try { - service.adjustSuggestedStreamVolume(direction, suggestedStreamType, flags); + if (mUseMasterVolume) { + service.adjustMasterVolume(direction, flags); + } else { + service.adjustSuggestedStreamVolume(direction, suggestedStreamType, flags); + } } catch (RemoteException e) { Log.e(TAG, "Dead object in adjustSuggestedStreamVolume", e); } @@ -551,8 +612,9 @@ public class AudioManager { * {@link #ADJUST_LOWER}, {@link #ADJUST_RAISE}, or * {@link #ADJUST_SAME}. * @param flags One or more flags. + * @hide */ - private void adjustMasterVolume(int direction, int flags) { + public void adjustMasterVolume(int direction, int flags) { IAudioService service = getService(); try { service.adjustMasterVolume(direction, flags); @@ -603,7 +665,11 @@ public class AudioManager { public int getStreamMaxVolume(int streamType) { IAudioService service = getService(); try { - return service.getStreamMaxVolume(streamType); + if (mUseMasterVolume) { + return service.getMasterMaxVolume(); + } else { + return service.getStreamMaxVolume(streamType); + } } catch (RemoteException e) { Log.e(TAG, "Dead object in getStreamMaxVolume", e); return 0; @@ -621,7 +687,11 @@ public class AudioManager { public int getStreamVolume(int streamType) { IAudioService service = getService(); try { - return service.getStreamVolume(streamType); + if (mUseMasterVolume) { + return service.getMasterVolume(); + } else { + return service.getStreamVolume(streamType); + } } catch (RemoteException e) { Log.e(TAG, "Dead object in getStreamVolume", e); return 0; @@ -636,7 +706,11 @@ public class AudioManager { public int getLastAudibleStreamVolume(int streamType) { IAudioService service = getService(); try { - return service.getLastAudibleStreamVolume(streamType); + if (mUseMasterVolume) { + return service.getLastAudibleMasterVolume(); + } else { + return service.getLastAudibleStreamVolume(streamType); + } } catch (RemoteException e) { Log.e(TAG, "Dead object in getLastAudibleStreamVolume", e); return 0; @@ -679,13 +753,82 @@ public class AudioManager { public void setStreamVolume(int streamType, int index, int flags) { IAudioService service = getService(); try { - service.setStreamVolume(streamType, index, flags); + if (mUseMasterVolume) { + service.setMasterVolume(index, flags); + } else { + service.setStreamVolume(streamType, index, flags); + } } catch (RemoteException e) { Log.e(TAG, "Dead object in setStreamVolume", e); } } /** + * Returns the maximum volume index for master volume. + * + * @hide + */ + public int getMasterMaxVolume() { + IAudioService service = getService(); + try { + return service.getMasterMaxVolume(); + } catch (RemoteException e) { + Log.e(TAG, "Dead object in getMasterMaxVolume", e); + return 0; + } + } + + /** + * Returns the current volume index for master volume. + * + * @return The current volume index for master volume. + * @hide + */ + public int getMasterVolume() { + IAudioService service = getService(); + try { + return service.getMasterVolume(); + } catch (RemoteException e) { + Log.e(TAG, "Dead object in getMasterVolume", e); + return 0; + } + } + + /** + * Get last audible volume before master volume was muted. + * + * @hide + */ + public int getLastAudibleMasterVolume() { + IAudioService service = getService(); + try { + return service.getLastAudibleMasterVolume(); + } catch (RemoteException e) { + Log.e(TAG, "Dead object in getLastAudibleMasterVolume", e); + return 0; + } + } + + /** + * Sets the volume index for master volume. + * + * @param index The volume index to set. See + * {@link #getMasterMaxVolume(int)} for the largest valid value. + * @param flags One or more flags. + * @see #getMasterMaxVolume(int) + * @see #getMasterVolume(int) + * @hide + */ + public void setMasterVolume(int index, int flags) { + IAudioService service = getService(); + try { + service.setMasterVolume(index, flags); + } catch (RemoteException e) { + Log.e(TAG, "Dead object in setMasterVolume", e); + } + } + + /** * Solo or unsolo a particular stream. All other streams are muted. * <p> * The solo command is protected against client process death: if a process @@ -756,6 +899,35 @@ public class AudioManager { } /** + * set master mute state. + * + * @hide + */ + public void setMasterMute(boolean state) { + IAudioService service = getService(); + try { + service.setMasterMute(state, mICallBack); + } catch (RemoteException e) { + Log.e(TAG, "Dead object in setMasterMute", e); + } + } + + /** + * get master mute state. + * + * @hide + */ + public boolean isMasterMute() { + IAudioService service = getService(); + try { + return service.isMasterMute(); + } catch (RemoteException e) { + Log.e(TAG, "Dead object in isMasterMute", e); + return false; + } + } + + /** * forces the stream controlled by hard volume keys * specifying streamType == -1 releases control to the * logic. diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 8259202..23060aa 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -112,6 +112,7 @@ public class AudioService extends IAudioService.Stub { // AudioHandler message.whats private static final int MSG_SET_DEVICE_VOLUME = 0; private static final int MSG_PERSIST_VOLUME = 1; + private static final int MSG_PERSIST_MASTER_VOLUME = 2; private static final int MSG_PERSIST_RINGER_MODE = 3; private static final int MSG_PERSIST_VIBRATE_SETTING = 4; private static final int MSG_MEDIA_SERVER_DIED = 5; @@ -158,6 +159,10 @@ public class AudioService extends IAudioService.Stub { private static final int NUM_SOUNDPOOL_CHANNELS = 4; private static final int SOUND_EFFECT_VOLUME = 1000; + // Internally master volume is a float in the 0.0 - 1.0 range, + // but to support integer based AudioManager API we translate it to 0 - 100 + private static final int MAX_MASTER_VOLUME = 100; + /* Sound effect file names */ private static final String SOUND_EFFECTS_PATH = "/media/audio/ui/"; private static final String[] SOUND_EFFECT_FILES = new String[] { @@ -278,6 +283,9 @@ public class AudioService extends IAudioService.Stub { // Forced device usage for communications private int mForcedUseForComm; + // True if we have master volume support + private final boolean mUseMasterVolume; + // List of binder death handlers for setMode() client processes. // The last process to have called setMode() is at the top of the list. private final ArrayList <SetModeDeathHandler> mSetModeDeathHandlers = new ArrayList <SetModeDeathHandler>(); @@ -405,14 +413,9 @@ public class AudioService extends IAudioService.Stub { context.getSystemService(Context.TELEPHONY_SERVICE); tmgr.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); - if (context.getResources().getBoolean( - com.android.internal.R.bool.config_useMasterVolume)) { - float volume = Settings.System.getFloat(mContentResolver, - Settings.System.VOLUME_MASTER, -1.0f); - if (volume >= 0.0f) { - AudioSystem.setMasterVolume(volume); - } - } + mUseMasterVolume = context.getResources().getBoolean( + com.android.internal.R.bool.config_useMasterVolume); + restoreMasterVolume(); } private void createAudioSystemThread() { @@ -620,6 +623,7 @@ public class AudioService extends IAudioService.Stub { float volume = AudioSystem.getMasterVolume(); if (volume >= 0.0) { + // get current master volume adjusted to 0 to 100 if (direction == AudioManager.ADJUST_RAISE) { volume += MASTER_VOLUME_INCREMENT; if (volume > 1.0f) volume = 1.0f; @@ -627,11 +631,7 @@ public class AudioService extends IAudioService.Stub { volume -= MASTER_VOLUME_INCREMENT; if (volume < 0.0f) volume = 0.0f; } - AudioSystem.setMasterVolume(volume); - long origCallerIdentityToken = Binder.clearCallingIdentity(); - Settings.System.putFloat(mContentResolver, Settings.System.VOLUME_MASTER, volume); - Binder.restoreCallingIdentity(origCallerIdentityToken); - mVolumePanel.postMasterVolumeChanged(flags); + doSetMasterVolume(volume, flags); } } @@ -690,6 +690,27 @@ public class AudioService extends IAudioService.Stub { mContext.sendBroadcast(intent); } + // UI update and Broadcast Intent + private void sendMasterVolumeUpdate(int flags, int oldVolume, int newVolume) { + mVolumePanel.postMasterVolumeChanged(flags); + + Intent intent = new Intent(AudioManager.MASTER_VOLUME_CHANGED_ACTION); + intent.putExtra(AudioManager.EXTRA_PREV_MASTER_VOLUME_VALUE, oldVolume); + intent.putExtra(AudioManager.EXTRA_MASTER_VOLUME_VALUE, newVolume); + mContext.sendBroadcast(intent); + } + + // UI update and Broadcast Intent + private void sendMasterMuteUpdate(boolean muted, int flags) { + mVolumePanel.postMasterMuteChanged(flags); + + Intent intent = new Intent(AudioManager.MASTER_MUTE_CHANGED_ACTION); + intent.putExtra(AudioManager.EXTRA_MASTER_VOLUME_MUTED, muted); + long origCallerIdentityToken = Binder.clearCallingIdentity(); + mContext.sendStickyBroadcast(intent); + Binder.restoreCallingIdentity(origCallerIdentityToken); + } + /** * Sets the stream state's index, and posts a message to set system volume. * This will not call out to the UI. Assumes a valid stream type. @@ -758,6 +779,19 @@ public class AudioService extends IAudioService.Stub { return (mStreamStates[streamType].muteCount() != 0); } + /** @see AudioManager#setMasterMute(boolean, IBinder) */ + public void setMasterMute(boolean state, IBinder cb) { + if (state != AudioSystem.getMasterMute()) { + AudioSystem.setMasterMute(state); + sendMasterMuteUpdate(state, AudioManager.FLAG_SHOW_UI); + } + } + + /** get master mute state. */ + public boolean isMasterMute() { + return AudioSystem.getMasterMute(); + } + /** @see AudioManager#getStreamVolume(int) */ public int getStreamVolume(int streamType) { ensureValidStreamType(streamType); @@ -765,12 +799,29 @@ public class AudioService extends IAudioService.Stub { return (mStreamStates[streamType].getIndex(device, false /* lastAudible */) + 5) / 10; } - public float getMasterVolume() { - return AudioSystem.getMasterVolume(); + public int getMasterVolume() { + if (isMasterMute()) return 0; + return getLastAudibleMasterVolume(); + } + + public void setMasterVolume(int volume, int flags) { + doSetMasterVolume((float)volume / MAX_MASTER_VOLUME, flags); } - public void setMasterVolume(float volume) { - AudioSystem.setMasterVolume(volume); + private void doSetMasterVolume(float volume, int flags) { + // don't allow changing master volume when muted + if (!AudioSystem.getMasterMute()) { + int oldVolume = getMasterVolume(); + AudioSystem.setMasterVolume(volume); + + int newVolume = getMasterVolume(); + if (newVolume != oldVolume) { + // Post a persist master volume msg + sendMsg(mAudioHandler, MSG_PERSIST_MASTER_VOLUME, SENDMSG_REPLACE, + Math.round(volume * (float)1000.0), 0, null, PERSIST_DELAY); + sendMasterVolumeUpdate(flags, oldVolume, newVolume); + } + } } /** @see AudioManager#getStreamMaxVolume(int) */ @@ -779,6 +830,9 @@ public class AudioService extends IAudioService.Stub { return (mStreamStates[streamType].getMaxIndex() + 5) / 10; } + public int getMasterMaxVolume() { + return MAX_MASTER_VOLUME; + } /** Get last audible volume before stream was muted. */ public int getLastAudibleStreamVolume(int streamType) { @@ -787,6 +841,11 @@ public class AudioService extends IAudioService.Stub { return (mStreamStates[streamType].getIndex(device, true /* lastAudible */) + 5) / 10; } + /** Get last audible master volume before it was muted. */ + public int getLastAudibleMasterVolume() { + return Math.round(AudioSystem.getMasterVolume() * MAX_MASTER_VOLUME); + } + /** @see AudioManager#getRingerMode() */ public int getRingerMode() { synchronized(mSettingsLock) { @@ -857,6 +916,16 @@ public class AudioService extends IAudioService.Stub { } } + private void restoreMasterVolume() { + if (mUseMasterVolume) { + float volume = Settings.System.getFloat(mContentResolver, + Settings.System.VOLUME_MASTER, -1.0f); + if (volume >= 0.0f) { + AudioSystem.setMasterVolume(volume); + } + } + } + /** @see AudioManager#shouldVibrate(int) */ public boolean shouldVibrate(int vibrateType) { @@ -2396,6 +2465,11 @@ public class AudioService extends IAudioService.Stub { persistVolume((VolumeStreamState) msg.obj, msg.arg1, msg.arg2); break; + case MSG_PERSIST_MASTER_VOLUME: + Settings.System.putFloat(mContentResolver, Settings.System.VOLUME_MASTER, + (float)msg.arg1 / (float)1000.0); + break; + case MSG_PERSIST_RINGER_MODE: // note that the value persisted is the current ringer mode, not the // value of ringer mode as of the time the request was made to persist @@ -2456,6 +2530,9 @@ public class AudioService extends IAudioService.Stub { // Restore ringer mode setRingerModeInt(getRingerMode(), false); + // Restore master volume + restoreMasterVolume(); + // indicate the end of reconfiguration phase to audio HAL AudioSystem.setParameters("restarting=false"); break; @@ -2880,6 +2957,11 @@ public class AudioService extends IAudioService.Stub { adapter.getProfileProxy(mContext, mBluetoothProfileServiceListener, BluetoothProfile.A2DP); } + + if (mUseMasterVolume) { + // Send sticky broadcast for initial master mute state + sendMasterMuteUpdate(false, 0); + } } else if (action.equals(Intent.ACTION_PACKAGE_REMOVED)) { if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { // a package is being removed, not replaced diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl index 01a2314..17d8e4d 100644 --- a/media/java/android/media/IAudioService.aidl +++ b/media/java/android/media/IAudioService.aidl @@ -36,6 +36,8 @@ interface IAudioService { void adjustMasterVolume(int direction, int flags); void setStreamVolume(int streamType, int index, int flags); + + void setMasterVolume(int index, int flags); void setStreamSolo(int streamType, boolean state, IBinder cb); @@ -43,14 +45,22 @@ interface IAudioService { boolean isStreamMute(int streamType); + void setMasterMute(boolean state, IBinder cb); + + boolean isMasterMute(); + int getStreamVolume(int streamType); - float getMasterVolume(); + int getMasterVolume(); int getStreamMaxVolume(int streamType); + + int getMasterMaxVolume(); int getLastAudibleStreamVolume(int streamType); + int getLastAudibleMasterVolume(); + void setRingerMode(int ringerMode); int getRingerMode(); diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml index f7713aa..3beaac9 100644 --- a/packages/SettingsProvider/res/values/defaults.xml +++ b/packages/SettingsProvider/res/values/defaults.xml @@ -43,6 +43,7 @@ <bool name="assisted_gps_enabled">true</bool> <!-- 0 == mobile, 1 == wifi. --> <integer name="def_network_preference">1</integer> + <bool name="def_netstats_enabled">true</bool> <bool name="def_usb_mass_storage_enabled">true</bool> <bool name="def_wifi_on">false</bool> <bool name="def_networks_available_notification_on">true</bool> diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 3ebf44b..882aa66 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -1599,6 +1599,9 @@ public class DatabaseHelper extends SQLiteOpenHelper { loadBooleanSetting(stmt, Settings.Secure.DEVICE_PROVISIONED, R.bool.def_device_provisioned); + + loadBooleanSetting(stmt, Settings.Secure.NETSTATS_ENABLED, + R.bool.def_netstats_enabled); } finally { if (stmt != null) stmt.close(); } diff --git a/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java b/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java index abed18f..83f7788 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java +++ b/policy/src/com/android/internal/policy/impl/PhoneFallbackEventHandler.java @@ -52,8 +52,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { } public void preDispatchKeyEvent(KeyEvent event) { - getAudioManager().preDispatchKeyEvent(event.getKeyCode(), - AudioManager.USE_DEFAULT_STREAM_TYPE); + getAudioManager().preDispatchKeyEvent(event, AudioManager.USE_DEFAULT_STREAM_TYPE); } public boolean dispatchKeyEvent(KeyEvent event) { @@ -79,7 +78,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_MUTE: { - getAudioManager().handleKeyDown(keyCode, AudioManager.USE_DEFAULT_STREAM_TYPE); + getAudioManager().handleKeyDown(event, AudioManager.USE_DEFAULT_STREAM_TYPE); return true; } @@ -197,8 +196,7 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { AudioManager audioManager = (AudioManager)mContext.getSystemService( Context.AUDIO_SERVICE); if (audioManager != null) { - getAudioManager().handleKeyUp(keyCode, - AudioManager.USE_DEFAULT_STREAM_TYPE); + getAudioManager().handleKeyUp(event, AudioManager.USE_DEFAULT_STREAM_TYPE); } } return true; diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index f1fe43b..b87b8c3 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -1416,7 +1416,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // doesn't have one of these. In this case, we execute it here and // eat the event instead, because we have mVolumeControlStreamType // and they don't. - getAudioManager().handleKeyDown(keyCode, mVolumeControlStreamType); + getAudioManager().handleKeyDown(event, mVolumeControlStreamType); return true; } @@ -1478,7 +1478,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { // doesn't have one of these. In this case, we execute it here and // eat the event instead, because we have mVolumeControlStreamType // and they don't. - getAudioManager().handleKeyUp(keyCode, mVolumeControlStreamType); + getAudioManager().handleKeyUp(event, mVolumeControlStreamType); return true; } diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 1efb475..c12a4b7e 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -1516,12 +1516,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { } static ITelephony getTelephonyService() { - ITelephony telephonyService = ITelephony.Stub.asInterface( + return ITelephony.Stub.asInterface( ServiceManager.checkService(Context.TELEPHONY_SERVICE)); - if (telephonyService == null) { - Log.w(TAG, "Unable to find ITelephony interface."); - } - return telephonyService; } static IAudioService getAudioService() { diff --git a/services/java/com/android/server/NetworkTimeUpdateService.java b/services/java/com/android/server/NetworkTimeUpdateService.java index a7d1992..1ff914f 100644 --- a/services/java/com/android/server/NetworkTimeUpdateService.java +++ b/services/java/com/android/server/NetworkTimeUpdateService.java @@ -55,7 +55,7 @@ public class NetworkTimeUpdateService { private static final int EVENT_AUTO_TIME_CHANGED = 1; private static final int EVENT_POLL_NETWORK_TIME = 2; - private static final int EVENT_WIFI_CONNECTED = 3; + private static final int EVENT_NETWORK_CONNECTED = 3; /** Normal polling frequency */ private static final long POLLING_INTERVAL_MS = 24L * 60 * 60 * 1000; // 24 hrs @@ -240,8 +240,9 @@ public class NetworkTimeUpdateService { if (netInfo != null) { // Verify that it's a WIFI connection if (netInfo.getState() == NetworkInfo.State.CONNECTED && - netInfo.getType() == ConnectivityManager.TYPE_WIFI ) { - mHandler.obtainMessage(EVENT_WIFI_CONNECTED).sendToTarget(); + (netInfo.getType() == ConnectivityManager.TYPE_WIFI || + netInfo.getType() == ConnectivityManager.TYPE_ETHERNET) ) { + mHandler.obtainMessage(EVENT_NETWORK_CONNECTED).sendToTarget(); } } } @@ -260,7 +261,7 @@ public class NetworkTimeUpdateService { switch (msg.what) { case EVENT_AUTO_TIME_CHANGED: case EVENT_POLL_NETWORK_TIME: - case EVENT_WIFI_CONNECTED: + case EVENT_NETWORK_CONNECTED: onPollNetworkTime(msg.what); break; } diff --git a/services/java/com/android/server/WiredAccessoryObserver.java b/services/java/com/android/server/WiredAccessoryObserver.java index 6a63eac..326b940 100644 --- a/services/java/com/android/server/WiredAccessoryObserver.java +++ b/services/java/com/android/server/WiredAccessoryObserver.java @@ -191,8 +191,12 @@ class WiredAccessoryObserver extends UEventObserver { mHeadsetState = headsetState; if (headsetState == 0) { - Intent intent = new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY); - mContext.sendBroadcast(intent); + if (mContext.getResources().getBoolean( + com.android.internal.R.bool.config_sendAudioBecomingNoisy)) { + Intent intent = new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY); + mContext.sendBroadcast(intent); + } + // It can take hundreds of ms flush the audio pipeline after // apps pause audio playback, but audio route changes are // immediate, so delay the route change by 1000ms. diff --git a/services/java/com/android/server/pm/Settings.java b/services/java/com/android/server/pm/Settings.java index fdb6e4c..ebf954b 100644 --- a/services/java/com/android/server/pm/Settings.java +++ b/services/java/com/android/server/pm/Settings.java @@ -2012,6 +2012,39 @@ final class Settings { return false; } + static final void printFlags(PrintWriter pw, int val, Object[] spec) { + pw.print("[ "); + for (int i=0; i<spec.length; i+=2) { + int mask = (Integer)spec[i]; + if ((val & mask) != 0) { + pw.print(spec[i+1]); + pw.print(" "); + } + } + pw.print("]"); + } + + static final Object[] FLAG_DUMP_SPEC = new Object[] { + ApplicationInfo.FLAG_SYSTEM, "SYSTEM", + ApplicationInfo.FLAG_DEBUGGABLE, "DEBUGGABLE", + ApplicationInfo.FLAG_HAS_CODE, "HAS_CODE", + ApplicationInfo.FLAG_PERSISTENT, "PERSISTENT", + ApplicationInfo.FLAG_FACTORY_TEST, "FACTORY_TEST", + ApplicationInfo.FLAG_ALLOW_TASK_REPARENTING, "ALLOW_TASK_REPARENTING", + ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA, "ALLOW_CLEAR_USER_DATA", + ApplicationInfo.FLAG_UPDATED_SYSTEM_APP, "UPDATED_SYSTEM_APP", + ApplicationInfo.FLAG_TEST_ONLY, "TEST_ONLY", + ApplicationInfo.FLAG_VM_SAFE_MODE, "VM_SAFE_MODE", + ApplicationInfo.FLAG_ALLOW_BACKUP, "ALLOW_BACKUP", + ApplicationInfo.FLAG_KILL_AFTER_RESTORE, "KILL_AFTER_RESTORE", + ApplicationInfo.FLAG_RESTORE_ANY_VERSION, "RESTORE_ANY_VERSION", + ApplicationInfo.FLAG_EXTERNAL_STORAGE, "EXTERNAL_STORAGE", + ApplicationInfo.FLAG_LARGE_HEAP, "LARGE_HEAP", + ApplicationInfo.FLAG_STOPPED, "STOPPED", + ApplicationInfo.FLAG_FORWARD_LOCK, "FORWARD_LOCK", + ApplicationInfo.FLAG_CANT_SAVE_STATE, "CANT_SAVE_STATE", + }; + void dumpPackagesLPr(PrintWriter pw, String packageName, DumpState dumpState) { final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); final Date date = new Date(); @@ -2052,6 +2085,7 @@ final class Settings { pw.print(" nativeLibraryPath="); pw.println(ps.nativeLibraryPathString); pw.print(" versionCode="); pw.println(ps.versionCode); if (ps.pkg != null) { + pw.print(" flags="); printFlags(pw, ps.pkg.applicationInfo.flags, FLAG_DUMP_SPEC); pw.println(); pw.print(" versionName="); pw.println(ps.pkg.mVersionName); pw.print(" dataDir="); pw.println(ps.pkg.applicationInfo.dataDir); pw.print(" targetSdk="); pw.println(ps.pkg.applicationInfo.targetSdkVersion); diff --git a/tools/aidl/Type.cpp b/tools/aidl/Type.cpp index b84b3c4..42e1226 100755 --- a/tools/aidl/Type.cpp +++ b/tools/aidl/Type.cpp @@ -212,6 +212,12 @@ Type::CreatorName() const } string +Type::RpcCreatorName() const +{ + return ""; +} + +string Type::InstantiableName() const { return QualifiedName(); @@ -910,6 +916,12 @@ UserDataType::CreatorName() const return QualifiedName() + ".CREATOR"; } +string +UserDataType::RpcCreatorName() const +{ + return QualifiedName() + ".RPC_CREATOR"; +} + void UserDataType::WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel, int flags) { @@ -1004,48 +1016,17 @@ void UserDataType::WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v, Variable* data, int flags) { - // if (v != null) { - // RpcData _obj = new RpcData(); - // v.writeToRpcData(_obj); - // data.putRpcData(k, obj); - // } - IfStatement* ifpart = new IfStatement; - ifpart->expression = new Comparison(v, "!=", NULL_VALUE); - Variable* _obj = new Variable(RPC_DATA_TYPE, "_obj"); - ifpart->statements->Add(new VariableDeclaration(_obj, new NewExpression(RPC_DATA_TYPE))); - ifpart->statements->Add(new MethodCall(v, "writeToRpcData", 1, _obj)); - ifpart->statements->Add(new MethodCall(data, "putRpcData", 2, k, _obj)); - - addTo->Add(ifpart); + // data.putFlattenable(k, v); + addTo->Add(new MethodCall(data, "putFlattenable", 2, k, v)); } void UserDataType::CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, Variable* data, Variable** cl) { - // RpcData _obj_XX = data.getRpcData(k); - // if (_data_XX != null) - // v = CLASS.RPC_CREATOR.createFromParcel(parcel) - // } else { - // v = null; - // } - - StatementBlock* block = new StatementBlock; - addTo->Add(block); - - Variable* _obj = new Variable(RPC_DATA_TYPE, "_obj"); - block->Add(new VariableDeclaration(_obj, new MethodCall(data, "getRpcData", 1, k))); - - IfStatement* ifpart = new IfStatement(); - ifpart->expression = new Comparison(_obj, "!=", NULL_VALUE); - ifpart->statements->Add(new Assignment(v, - new MethodCall(v->type, "RPC_CREATOR.createFromRpcData", 1, data))); - - IfStatement* elsepart = new IfStatement(); - ifpart->elseif = elsepart; - elsepart->statements->Add(new Assignment(v, NULL_VALUE)); - - block->Add(ifpart); + // data.getFlattenable(k, CLASS.RPC_CREATOR); + addTo->Add(new Assignment(v, new MethodCall(data, "getFlattenable", 2, k, + new FieldVariable(v->type, "RPC_CREATOR")))); } // ================================================================ @@ -1221,17 +1202,32 @@ void GenericListType::WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v, Variable* data, int flags) { - addTo->Add(new MethodCall(data, "putList", 2, k, v)); + Type* generic = GenericArgumentTypes()[0]; + if (generic == RPC_DATA_TYPE) { + addTo->Add(new MethodCall(data, "putRpcDataList", 2, k, v)); + } else if (generic->RpcCreatorName() != "") { + addTo->Add(new MethodCall(data, "putFlattenableList", 2, k, v)); + } else { + addTo->Add(new MethodCall(data, "putList", 2, k, v)); + } } void GenericListType::CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, Variable* data, Variable** cl) { - string classArg = GenericArgumentTypes()[0]->QualifiedName(); - classArg += ".class"; - addTo->Add(new Assignment(v, new MethodCall(data, "getList", 2, k, - new LiteralExpression(classArg)))); + Type* generic = GenericArgumentTypes()[0]; + if (generic == RPC_DATA_TYPE) { + addTo->Add(new Assignment(v, new MethodCall(data, "getRpcDataList", 2, k))); + } else if (generic->RpcCreatorName() != "") { + addTo->Add(new Assignment(v, new MethodCall(data, "getFlattenableList", 2, k, + new LiteralExpression(generic->RpcCreatorName())))); + } else { + string classArg = GenericArgumentTypes()[0]->QualifiedName(); + classArg += ".class"; + addTo->Add(new Assignment(v, new MethodCall(data, "getList", 2, k, + new LiteralExpression(classArg)))); + } } diff --git a/tools/aidl/Type.h b/tools/aidl/Type.h index f2f3f21..ae12720 100755 --- a/tools/aidl/Type.h +++ b/tools/aidl/Type.h @@ -42,6 +42,7 @@ public: virtual string ImportType() const; virtual string CreatorName() const; + virtual string RpcCreatorName() const; virtual string InstantiableName() const; virtual void WriteToParcel(StatementBlock* addTo, Variable* v, @@ -358,6 +359,7 @@ public: const string& declFile = "", int declLine = -1); virtual string CreatorName() const; + virtual string RpcCreatorName() const; virtual void WriteToParcel(StatementBlock* addTo, Variable* v, Variable* parcel, int flags); diff --git a/tools/aidl/aidl.cpp b/tools/aidl/aidl.cpp index e5689b9..8dbbf50 100644 --- a/tools/aidl/aidl.cpp +++ b/tools/aidl/aidl.cpp @@ -475,6 +475,15 @@ check_method(const char* filename, int kind, method_type* m) err = 1; } + if (returnType == EVENT_FAKE_TYPE + && convert_direction(arg->direction.data) != IN_PARAMETER) { + fprintf(stderr, "%s:%d parameter %d: '%s %s' All paremeters on events must be 'in'.\n", + filename, m->type.type.lineno, index, + arg->type.type.data, arg->name.data); + err = 1; + goto next; + } + if (arg->direction.data == NULL && (arg->type.dimension != 0 || t->CanBeOutParameter())) { fprintf(stderr, "%s:%d parameter %d: '%s %s' can be an out" diff --git a/tools/aidl/generate_java_rpc.cpp b/tools/aidl/generate_java_rpc.cpp index e4867e4..ecff3a1 100644 --- a/tools/aidl/generate_java_rpc.cpp +++ b/tools/aidl/generate_java_rpc.cpp @@ -15,6 +15,8 @@ Type* RPC_BROKER_TYPE = new Type("com.android.athome.connector", "Broker", Type::BUILT_IN, false, false, false); Type* RPC_CONTAINER_TYPE = new Type("com.android.athome.connector", "ConnectorContainer", Type::BUILT_IN, false, false, false); +Type* PLACE_INFO_TYPE = new Type("android.support.place.connector", "PlaceInfo", + Type::BUILT_IN, false, false, false); // TODO: Just use Endpoint, so this works for all endpoints. Type* RPC_CONNECTOR_TYPE = new Type("com.android.athome.connector", "Connector", Type::BUILT_IN, false, false, false); @@ -293,6 +295,7 @@ public: private: void generate_ctor(); + void generate_get_endpoint_info(); }; RpcProxyClass::RpcProxyClass(const interface_type* iface, InterfaceType* interfaceType) @@ -312,6 +315,7 @@ RpcProxyClass::RpcProxyClass(const interface_type* iface, InterfaceType* interfa // methods generate_ctor(); + generate_get_endpoint_info(); } RpcProxyClass::~RpcProxyClass() @@ -335,6 +339,19 @@ RpcProxyClass::generate_ctor() ctor->statements->Add(new Assignment(this->endpoint, endpoint)); } +void +RpcProxyClass::generate_get_endpoint_info() +{ + Method* get = new Method; + get->modifiers = PUBLIC; + get->returnType = RPC_ENDPOINT_INFO_TYPE; + get->name = "getEndpointInfo"; + get->statements = new StatementBlock; + this->elements.push_back(get); + + get->statements->Add(new ReturnStatement(this->endpoint)); +} + // ================================================= class EventListenerClass : public DispatcherClass { @@ -460,15 +477,17 @@ EndpointBaseClass::generate_ctor() { Variable* container = new Variable(RPC_CONTAINER_TYPE, "container"); Variable* broker = new Variable(RPC_BROKER_TYPE, "broker"); + Variable* place = new Variable(PLACE_INFO_TYPE, "placeInfo"); Method* ctor = new Method; ctor->modifiers = PUBLIC; ctor->name = class_name_leaf(this->type->Name()); ctor->statements = new StatementBlock; ctor->parameters.push_back(container); ctor->parameters.push_back(broker); + ctor->parameters.push_back(place); this->elements.push_back(ctor); - ctor->statements->Add(new MethodCall("super", 2, container, broker)); + ctor->statements->Add(new MethodCall("super", 3, container, broker, place)); } // ================================================= @@ -739,11 +758,13 @@ generate_result_dispatcher_method(const method_type* method, // The return value { Type* t = NAMES.Search(method->type.type.data); - Variable* rv = new Variable(t, "rv"); - dispatchMethod->statements->Add(new VariableDeclaration(rv)); - generate_create_from_data(t, dispatchMethod->statements, "_result", rv, - resultData, &classLoader); - realCall->arguments.push_back(rv); + if (t != VOID_TYPE) { + Variable* rv = new Variable(t, "rv"); + dispatchMethod->statements->Add(new VariableDeclaration(rv)); + generate_create_from_data(t, dispatchMethod->statements, "_result", rv, + resultData, &classLoader); + realCall->arguments.push_back(rv); + } } VariableFactory stubArgs("arg"); |