Skip to content

Commit c199e2c

Browse files
Mike LockwoodAndroid (Google) Code Review
authored andcommitted
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
2 parents 0ee0969 + efeba01 commit c199e2c

File tree

20 files changed

+500
-124
lines changed

20 files changed

+500
-124
lines changed

core/java/android/net/EthernetDataTracker.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class EthernetDataTracker implements NetworkStateTracker {
4949
private LinkCapabilities mLinkCapabilities;
5050
private NetworkInfo mNetworkInfo;
5151
private InterfaceObserver mInterfaceObserver;
52+
private String mHwAddr;
5253

5354
/* For sending events to connectivity service handler */
5455
private Handler mCsHandler;
@@ -74,6 +75,7 @@ public void interfaceLinkStateChanged(String iface, boolean up) {
7475
if (mIface.equals(iface) && mLinkUp != up) {
7576
Log.d(TAG, "Interface " + iface + " link " + (up ? "up" : "down"));
7677
mLinkUp = up;
78+
mTracker.mNetworkInfo.setIsAvailable(up);
7779

7880
// use DHCP
7981
if (up) {
@@ -101,10 +103,6 @@ private EthernetDataTracker() {
101103
mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_ETHERNET, 0, NETWORKTYPE, "");
102104
mLinkProperties = new LinkProperties();
103105
mLinkCapabilities = new LinkCapabilities();
104-
mLinkUp = false;
105-
106-
mNetworkInfo.setIsAvailable(false);
107-
setTeardownRequested(false);
108106
}
109107

110108
private void interfaceAdded(String iface) {
@@ -113,7 +111,7 @@ private void interfaceAdded(String iface) {
113111

114112
Log.d(TAG, "Adding " + iface);
115113

116-
synchronized(mIface) {
114+
synchronized(this) {
117115
if(!mIface.isEmpty())
118116
return;
119117
mIface = iface;
@@ -122,8 +120,6 @@ private void interfaceAdded(String iface) {
122120
mNetworkInfo.setIsAvailable(true);
123121
Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo);
124122
msg.sendToTarget();
125-
126-
runDhcp();
127123
}
128124

129125
public void disconnect() {
@@ -132,7 +128,7 @@ public void disconnect() {
132128

133129
mLinkProperties.clear();
134130
mNetworkInfo.setIsAvailable(false);
135-
mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null, null);
131+
mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null, mHwAddr);
136132

137133
Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo);
138134
msg.sendToTarget();
@@ -154,7 +150,7 @@ private void interfaceRemoved(String iface) {
154150
return;
155151

156152
Log.d(TAG, "Removing " + iface);
157-
disconnect();
153+
disconnect();
158154
mIface = "";
159155
}
160156

@@ -169,7 +165,7 @@ public void run() {
169165
mLinkProperties = dhcpInfoInternal.makeLinkProperties();
170166
mLinkProperties.setInterfaceName(mIface);
171167

172-
mNetworkInfo.setDetailedState(DetailedState.CONNECTED, null, null);
168+
mNetworkInfo.setDetailedState(DetailedState.CONNECTED, null, mHwAddr);
173169
Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
174170
msg.sendToTarget();
175171
}
@@ -216,8 +212,15 @@ public void startMonitoring(Context context, Handler target) {
216212
for (String iface : ifaces) {
217213
if (iface.matches(sIfaceMatch)) {
218214
mIface = iface;
215+
service.setInterfaceUp(iface);
219216
InterfaceConfiguration config = service.getInterfaceConfig(iface);
220217
mLinkUp = config.isActive();
218+
if (config != null && mHwAddr == null) {
219+
mHwAddr = config.getHardwareAddress();
220+
if (mHwAddr != null) {
221+
mNetworkInfo.setExtraInfo(mHwAddr);
222+
}
223+
}
221224
reconnect();
222225
break;
223226
}
@@ -247,9 +250,11 @@ public boolean teardown() {
247250
* Re-enable connectivity to a network after a {@link #teardown()}.
248251
*/
249252
public boolean reconnect() {
250-
mTeardownRequested.set(false);
251-
runDhcp();
252-
return true;
253+
if (mLinkUp) {
254+
mTeardownRequested.set(false);
255+
runDhcp();
256+
}
257+
return mLinkUp;
253258
}
254259

255260
/**

core/java/android/net/NetworkInfo.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,18 @@ public void setDetailedState(DetailedState detailedState, String reason, String
350350
}
351351
}
352352

353+
/**
354+
* Set the extraInfo field.
355+
* @param extraInfo an optional {@code String} providing addditional network state
356+
* information passed up from the lower networking layers.
357+
* @hide
358+
*/
359+
public void setExtraInfo(String extraInfo) {
360+
synchronized (this) {
361+
this.mExtraInfo = extraInfo;
362+
}
363+
}
364+
353365
/**
354366
* Report the reason an attempt to establish connectivity failed,
355367
* if one is available.

core/java/android/view/VolumePanel.java

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
9191
private static final int MSG_VIBRATE = 4;
9292
private static final int MSG_TIMEOUT = 5;
9393
private static final int MSG_RINGER_MODE_CHANGED = 6;
94+
private static final int MSG_MUTE_CHANGED = 7;
9495

9596
// Pseudo stream type for master volume
96-
private static final int STREAM_MASTER = -1;
97+
private static final int STREAM_MASTER = -100;
9798

9899
protected Context mContext;
99100
private AudioManager mAudioManager;
@@ -295,45 +296,39 @@ public void onReceive(Context context, Intent intent) {
295296

296297
private boolean isMuted(int streamType) {
297298
if (streamType == STREAM_MASTER) {
298-
// master volume mute not yet supported
299-
return false;
299+
return mAudioService.isMasterMute();
300300
} else {
301301
return mAudioService.isStreamMute(streamType);
302302
}
303303
}
304304

305305
private int getStreamMaxVolume(int streamType) {
306-
// master volume is 0.0f - 1.0f, but we will use 0 - 100 internally
307306
if (streamType == STREAM_MASTER) {
308-
return 100;
307+
return mAudioService.getMasterMaxVolume();
309308
} else {
310309
return mAudioService.getStreamMaxVolume(streamType);
311310
}
312311
}
313312

314313
private int getStreamVolume(int streamType) {
315-
// master volume is 0.0f - 1.0f, but we will use 0 - 100 internally
316314
if (streamType == STREAM_MASTER) {
317-
return Math.round(mAudioService.getMasterVolume() * 100);
315+
return mAudioService.getMasterVolume();
318316
} else {
319317
return mAudioService.getStreamVolume(streamType);
320318
}
321319
}
322320

323321
private void setStreamVolume(int streamType, int index, int flags) {
324-
// master volume is 0.0f - 1.0f, but we will use 0 - 100 internally
325322
if (streamType == STREAM_MASTER) {
326-
mAudioService.setMasterVolume((float)index / 100.0f);
323+
mAudioService.setMasterVolume(index, flags);
327324
} else {
328325
mAudioService.setStreamVolume(streamType, index, flags);
329326
}
330327
}
331328

332329
private int getLastAudibleStreamVolume(int streamType) {
333-
// master volume is 0.0f - 1.0f, but we will use 0 - 100 internally
334330
if (streamType == STREAM_MASTER) {
335-
// master volume mute not yet supported
336-
return getStreamVolume(STREAM_MASTER);
331+
return mAudioService.getLastAudibleMasterVolume();
337332
} else {
338333
return mAudioService.getLastAudibleStreamVolume(streamType);
339334
}
@@ -456,6 +451,19 @@ public void postMasterVolumeChanged(int flags) {
456451
postVolumeChanged(STREAM_MASTER, flags);
457452
}
458453

454+
public void postMuteChanged(int streamType, int flags) {
455+
if (hasMessages(MSG_VOLUME_CHANGED)) return;
456+
if (mStreamControls == null) {
457+
createSliders();
458+
}
459+
removeMessages(MSG_FREE_RESOURCES);
460+
obtainMessage(MSG_MUTE_CHANGED, streamType, flags).sendToTarget();
461+
}
462+
463+
public void postMasterMuteChanged(int flags) {
464+
postMuteChanged(STREAM_MASTER, flags);
465+
}
466+
459467
/**
460468
* Override this if you have other work to do when the volume changes (for
461469
* example, vibrating, playing a sound, etc.). Make sure to call through to
@@ -489,6 +497,18 @@ protected void onVolumeChanged(int streamType, int flags) {
489497
resetTimeout();
490498
}
491499

500+
protected void onMuteChanged(int streamType, int flags) {
501+
502+
if (LOGD) Log.d(TAG, "onMuteChanged(streamType: " + streamType + ", flags: " + flags + ")");
503+
504+
StreamControl sc = mStreamControls.get(streamType);
505+
if (sc != null) {
506+
sc.icon.setImageResource(isMuted(sc.streamType) ? sc.iconMuteRes : sc.iconRes);
507+
}
508+
509+
onVolumeChanged(streamType, flags);
510+
}
511+
492512
protected void onShowVolumeChanged(int streamType, int flags) {
493513
int index = isMuted(streamType) ?
494514
getLastAudibleStreamVolume(streamType)
@@ -687,6 +707,11 @@ public void handleMessage(Message msg) {
687707
break;
688708
}
689709

710+
case MSG_MUTE_CHANGED: {
711+
onMuteChanged(msg.arg1, msg.arg2);
712+
break;
713+
}
714+
690715
case MSG_FREE_RESOURCES: {
691716
onFreeResources();
692717
break;

core/res/res/values/config.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
master volume stream and nothing else . -->
6666
<bool name="config_useMasterVolume">false</bool>
6767

68+
<!-- Flag indicating whether the AUDIO_BECOMING_NOISY notification should
69+
be sent during an change to the audio output device. -->
70+
<bool name="config_sendAudioBecomingNoisy">true</bool>
71+
6872
<!-- The duration (in milliseconds) of a short animation. -->
6973
<integer name="config_shortAnimTime">200</integer>
7074

core/res/res/values/public.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@
236236
<java-symbol type="bool" name="split_action_bar_is_narrow" />
237237
<java-symbol type="bool" name="config_useMasterVolume" />
238238
<java-symbol type="bool" name="config_enableWallpaperService" />
239+
<java-symbol type="bool" name="config_sendAudioBecomingNoisy" />
239240

240241
<java-symbol type="integer" name="config_cursorWindowSize" />
241242
<java-symbol type="integer" name="config_longPressOnPowerBehavior" />

0 commit comments

Comments
 (0)