diff options
author | Prerepa Viswanadham <dham@google.com> | 2015-05-05 01:05:57 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-05 01:06:38 +0000 |
commit | d1808401ca3bfd6b6b9a975c1e739b194d18f849 (patch) | |
tree | 50c16a5c966772fd3b3ac4f7d2e79c97252935c7 /media | |
parent | 44b60be189183138437a3faf9a73388af0efcf44 (diff) | |
parent | 059ded5a7b7389b7eefc2502bd712228931ed107 (diff) | |
download | frameworks_base-d1808401ca3bfd6b6b9a975c1e739b194d18f849.zip frameworks_base-d1808401ca3bfd6b6b9a975c1e739b194d18f849.tar.gz frameworks_base-d1808401ca3bfd6b6b9a975c1e739b194d18f849.tar.bz2 |
Merge changes from topic 'mwd-merge-050415' into mnc-dev
* changes:
Merge commit 'b6f59f4' into master_merge
Merge commit 'f6db0ce' into master_merge
Merge commit '17455a3' into master_merge
Merge commit 'b4d5b32' into master_merge
Merge commit 'a1a2fa7' into master_merge
Merge commit '8dfdb98' into master_merge
Merge commit 'eba66c3' into master_merge
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/AudioManager.java | 76 | ||||
-rw-r--r-- | media/java/android/media/tv/TvContentRating.java | 87 |
2 files changed, 135 insertions, 28 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index eeac69a..6eaf812 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -57,7 +57,8 @@ import java.util.Iterator; */ public class AudioManager { - private final Context mApplicationContext; + private Context mOriginalContext; + private Context mApplicationContext; private long mVolumeKeyUpTime; private final boolean mUseVolumeKeySounds; private final boolean mUseFixedVolume; @@ -621,14 +622,33 @@ public class AudioManager { * @hide */ public AudioManager(Context context) { - mApplicationContext = context; - mUseVolumeKeySounds = mApplicationContext.getResources().getBoolean( + setContext(context); + mUseVolumeKeySounds = getContext().getResources().getBoolean( com.android.internal.R.bool.config_useVolumeKeySounds); - mUseFixedVolume = mApplicationContext.getResources().getBoolean( + mUseFixedVolume = getContext().getResources().getBoolean( com.android.internal.R.bool.config_useFixedVolume); sAudioPortEventHandler.init(); } + private Context getContext() { + if (mApplicationContext == null) { + setContext(mOriginalContext); + } + if (mApplicationContext != null) { + return mApplicationContext; + } + return mOriginalContext; + } + + private void setContext(Context context) { + mApplicationContext = context.getApplicationContext(); + if (mApplicationContext != null) { + mOriginalContext = null; + } else { + mOriginalContext = context; + } + } + private static IAudioService getService() { if (sService != null) { @@ -663,7 +683,7 @@ public class AudioManager { * or {@link KeyEvent#KEYCODE_MEDIA_AUDIO_TRACK}. */ public void dispatchMediaKeyEvent(KeyEvent keyEvent) { - MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mApplicationContext); + MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(getContext()); helper.sendMediaButtonEvent(keyEvent, false); } @@ -709,7 +729,7 @@ public class AudioManager { break; case KeyEvent.KEYCODE_VOLUME_MUTE: if (event.getRepeatCount() == 0) { - MediaSessionLegacyHelper.getHelper(mApplicationContext) + MediaSessionLegacyHelper.getHelper(getContext()) .sendVolumeKeyEvent(event, false); } break; @@ -737,7 +757,7 @@ public class AudioManager { mVolumeKeyUpTime = SystemClock.uptimeMillis(); break; case KeyEvent.KEYCODE_VOLUME_MUTE: - MediaSessionLegacyHelper.getHelper(mApplicationContext) + MediaSessionLegacyHelper.getHelper(getContext()) .sendVolumeKeyEvent(event, false); break; } @@ -783,7 +803,7 @@ public class AudioManager { IAudioService service = getService(); try { service.adjustStreamVolume(streamType, direction, flags, - mApplicationContext.getOpPackageName()); + getContext().getOpPackageName()); } catch (RemoteException e) { Log.e(TAG, "Dead object in adjustStreamVolume", e); } @@ -813,7 +833,7 @@ public class AudioManager { * @see #isVolumeFixed() */ public void adjustVolume(int direction, int flags) { - MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mApplicationContext); + MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(getContext()); helper.sendAdjustVolumeBy(USE_DEFAULT_STREAM_TYPE, direction, flags); } @@ -842,7 +862,7 @@ public class AudioManager { * @see #isVolumeFixed() */ public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags) { - MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mApplicationContext); + MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(getContext()); helper.sendAdjustVolumeBy(suggestedStreamType, direction, flags); } @@ -850,7 +870,7 @@ public class AudioManager { public void setMasterMute(boolean mute, int flags) { IAudioService service = getService(); try { - service.setMasterMute(mute, flags, mApplicationContext.getOpPackageName()); + service.setMasterMute(mute, flags, getContext().getOpPackageName()); } catch (RemoteException e) { Log.e(TAG, "Dead object in setMasterMute", e); } @@ -997,7 +1017,7 @@ public class AudioManager { } IAudioService service = getService(); try { - service.setRingerModeExternal(ringerMode, mApplicationContext.getOpPackageName()); + service.setRingerModeExternal(ringerMode, getContext().getOpPackageName()); } catch (RemoteException e) { Log.e(TAG, "Dead object in setRingerMode", e); } @@ -1018,7 +1038,7 @@ public class AudioManager { public void setStreamVolume(int streamType, int index, int flags) { IAudioService service = getService(); try { - service.setStreamVolume(streamType, index, flags, mApplicationContext.getOpPackageName()); + service.setStreamVolume(streamType, index, flags, getContext().getOpPackageName()); } catch (RemoteException e) { Log.e(TAG, "Dead object in setStreamVolume", e); } @@ -1331,7 +1351,7 @@ public class AudioManager { * @see #startBluetoothSco() */ public boolean isBluetoothScoAvailableOffCall() { - return mApplicationContext.getResources().getBoolean( + return getContext().getResources().getBoolean( com.android.internal.R.bool.config_bluetooth_sco_off_call); } @@ -1384,7 +1404,7 @@ public class AudioManager { IAudioService service = getService(); try { service.startBluetoothSco(mICallBack, - mApplicationContext.getApplicationInfo().targetSdkVersion); + getContext().getApplicationInfo().targetSdkVersion); } catch (RemoteException e) { Log.e(TAG, "Dead object in startBluetoothSco", e); } @@ -1532,7 +1552,7 @@ public class AudioManager { public void setMicrophoneMute(boolean on){ IAudioService service = getService(); try { - service.setMicrophoneMute(on, mApplicationContext.getOpPackageName()); + service.setMicrophoneMute(on, getContext().getOpPackageName()); } catch (RemoteException e) { Log.e(TAG, "Dead object in setMicrophoneMute", e); } @@ -1963,7 +1983,7 @@ public class AudioManager { * Settings has an in memory cache, so this is fast. */ private boolean querySoundEffectsEnabled(int user) { - return Settings.System.getIntForUser(mApplicationContext.getContentResolver(), + return Settings.System.getIntForUser(getContext().getContentResolver(), Settings.System.SOUND_EFFECTS_ENABLED, 0, user) != 0; } @@ -2375,7 +2395,7 @@ public class AudioManager { try { status = service.requestAudioFocus(requestAttributes, durationHint, mICallBack, mAudioFocusDispatcher, getIdForAudioFocusListener(l), - mApplicationContext.getOpPackageName() /* package name */, flags, + getContext().getOpPackageName() /* package name */, flags, ap != null ? ap.cb() : null); } catch (RemoteException e) { Log.e(TAG, "Can't call requestAudioFocus() on AudioService:", e); @@ -2400,7 +2420,7 @@ public class AudioManager { .setInternalLegacyStreamType(streamType).build(), durationHint, mICallBack, null, AudioSystem.IN_VOICE_COMM_FOCUS_ID, - mApplicationContext.getOpPackageName(), + getContext().getOpPackageName(), AUDIOFOCUS_FLAG_LOCK, null /* policy token */); } catch (RemoteException e) { @@ -2469,7 +2489,7 @@ public class AudioManager { if (eventReceiver == null) { return; } - if (!eventReceiver.getPackageName().equals(mApplicationContext.getPackageName())) { + if (!eventReceiver.getPackageName().equals(getContext().getPackageName())) { Log.e(TAG, "registerMediaButtonEventReceiver() error: " + "receiver and context package names don't match"); return; @@ -2478,7 +2498,7 @@ public class AudioManager { Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); // the associated intent will be handled by the component being registered mediaButtonIntent.setComponent(eventReceiver); - PendingIntent pi = PendingIntent.getBroadcast(mApplicationContext, + PendingIntent pi = PendingIntent.getBroadcast(getContext(), 0/*requestCode, ignored*/, mediaButtonIntent, 0/*flags*/); registerMediaButtonIntent(pi, eventReceiver); } @@ -2512,8 +2532,8 @@ public class AudioManager { Log.e(TAG, "Cannot call registerMediaButtonIntent() with a null parameter"); return; } - MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mApplicationContext); - helper.addMediaButtonListener(pi, eventReceiver, mApplicationContext); + MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(getContext()); + helper.addMediaButtonListener(pi, eventReceiver, getContext()); } /** @@ -2531,7 +2551,7 @@ public class AudioManager { Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); // the associated intent will be handled by the component being registered mediaButtonIntent.setComponent(eventReceiver); - PendingIntent pi = PendingIntent.getBroadcast(mApplicationContext, + PendingIntent pi = PendingIntent.getBroadcast(getContext(), 0/*requestCode, ignored*/, mediaButtonIntent, 0/*flags*/); unregisterMediaButtonIntent(pi); } @@ -2554,7 +2574,7 @@ public class AudioManager { * @hide */ public void unregisterMediaButtonIntent(PendingIntent pi) { - MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(mApplicationContext); + MediaSessionLegacyHelper helper = MediaSessionLegacyHelper.getHelper(getContext()); helper.removeMediaButtonListener(pi); } @@ -2571,7 +2591,7 @@ public class AudioManager { if ((rcClient == null) || (rcClient.getRcMediaIntent() == null)) { return; } - rcClient.registerWithSession(MediaSessionLegacyHelper.getHelper(mApplicationContext)); + rcClient.registerWithSession(MediaSessionLegacyHelper.getHelper(getContext())); } /** @@ -2586,7 +2606,7 @@ public class AudioManager { if ((rcClient == null) || (rcClient.getRcMediaIntent() == null)) { return; } - rcClient.unregisterWithSession(MediaSessionLegacyHelper.getHelper(mApplicationContext)); + rcClient.unregisterWithSession(MediaSessionLegacyHelper.getHelper(getContext())); } /** @@ -3280,7 +3300,7 @@ public class AudioManager { */ public void setRingerModeInternal(int ringerMode) { try { - getService().setRingerModeInternal(ringerMode, mApplicationContext.getOpPackageName()); + getService().setRingerModeInternal(ringerMode, getContext().getOpPackageName()); } catch (RemoteException e) { Log.w(TAG, "Error calling setRingerModeInternal", e); } diff --git a/media/java/android/media/tv/TvContentRating.java b/media/java/android/media/tv/TvContentRating.java index 966e41a..daeb1cc 100644 --- a/media/java/android/media/tv/TvContentRating.java +++ b/media/java/android/media/tv/TvContentRating.java @@ -171,6 +171,14 @@ import java.util.Objects; * <td>TV content rating system for Brazil</td> * </tr> * <tr> + * <td>CA_TV_EN</td> + * <td>TV content rating system for Canada (English)</td> + * </tr> + * <tr> + * <td>CA_TV_FR</td> + * <td>TV content rating system for Canada (French)</td> + * </tr> + * <tr> * <td>DVB</td> * <td>DVB content rating system</td> * </tr> @@ -195,6 +203,10 @@ import java.util.Objects; * <td>TV content rating system for Singapore</td> * </tr> * <tr> + * <td>US_MV</td> + * <td>Movie content rating system for the United States</td> + * </tr> + * <tr> * <td>US_TV</td> * <td>TV content rating system for the United States</td> * </tr> @@ -290,6 +302,60 @@ import java.util.Objects; * <td>Content suitable for viewers over the age of 18</td> * </tr> * <tr> + * <td valign="top" rowspan="7">CA_TV_EN</td> + * <td>CA_TV_EN_EXEMPT</td> + * <td>Exempt from ratings</td> + * </tr> + * <tr> + * <td>CA_TV_EN_C</td> + * <td>Suitable for children ages 2–7</td> + * </tr> + * <tr> + * <td>CA_TV_EN_C8</td> + * <td>Suitable for children ages 8 and older</td> + * </tr> + * <tr> + * <td>CA_TV_EN_G</td> + * <td>Suitable for the entire family</td> + * </tr> + * <tr> + * <td>CA_TV_EN_PG</td> + * <td>May contain moderate violence, profanity, nudity, and sexual references</td> + * </tr> + * <tr> + * <td>CA_TV_EN_14</td> + * <td>Intended for viewers ages 14 and older</td> + * </tr> + * <tr> + * <td>CA_TV_EN_18</td> + * <td>Intended for viewers ages 18 and older</td> + * </tr> + * <tr> + * <td valign="top" rowspan="6">CA_TV_FR</td> + * <td>CA_TV_FR_E</td> + * <td>Exempt from ratings</td> + * </tr> + * <tr> + * <td>CA_TV_FR_G</td> + * <td>Appropriate for all ages</td> + * </tr> + * <tr> + * <td>CA_TV_FR_8</td> + * <td>Appropriate for children 8</td> + * </tr> + * <tr> + * <td>CA_TV_FR_13</td> + * <td>Suitable for children 13</td> + * </tr> + * <tr> + * <td>CA_TV_FR_16</td> + * <td>Recommended for children over the age of 16</td> + * </tr> + * <tr> + * <td>CA_TV_FR_18</td> + * <td>Only to be viewed by adults</td> + * </tr> + * <tr> * <td valign="top" rowspan="15">DVB</td> * <td>DVB_4</td> * <td>Recommended for ages 4 and over</td> @@ -608,6 +674,27 @@ import java.util.Objects; * <td>Suitable for adults aged 21 and above</td> * </tr> * <tr> + * <td valign="top" rowspan="5">US_MV</td> + * <td>US_MV_G</td> + * <td>General audiences</td> + * </tr> + * <tr> + * <td>US_MV_PG</td> + * <td>Parental guidance suggested</td> + * </tr> + * <tr> + * <td>US_MV_PG13</td> + * <td>Parents strongly cautioned</td> + * </tr> + * <tr> + * <td>US_MV_R</td> + * <td>Restricted, under 17 requires accompanying parent or adult guardian</td> + * </tr> + * <tr> + * <td>US_MV_NC17</td> + * <td>No one 17 and under admitted</td> + * </tr> + * <tr> * <td valign="top" rowspan="6">US_TV</td> * <td>US_TV_Y</td> * <td>This program is designed to be appropriate for all children</td> |