Merge "Rename BROADCAST_SCORE_NETWORKS to BROADCAST_NETWORK_PRIVILEGED." into lmp-mr1-dev

This commit is contained in:
Jeff Davidson
2014-11-05 21:33:14 +00:00
committed by Android (Google) Code Review
6 changed files with 29 additions and 28 deletions

View File

@@ -41,10 +41,10 @@ import android.os.UserHandle;
* <ul> * <ul>
* <li>Declares the {@link android.Manifest.permission#SCORE_NETWORKS} permission. * <li>Declares the {@link android.Manifest.permission#SCORE_NETWORKS} permission.
* <li>Includes a receiver for {@link #ACTION_SCORE_NETWORKS} guarded by the * <li>Includes a receiver for {@link #ACTION_SCORE_NETWORKS} guarded by the
* {@link android.Manifest.permission#BROADCAST_SCORE_NETWORKS} permission which scores networks * {@link android.Manifest.permission#BROADCAST_NETWORK_PRIVILEGED} permission which scores
* and (eventually) calls {@link #updateScores} with the results. If this receiver specifies an * networks and (eventually) calls {@link #updateScores} with the results. If this receiver
* android:label attribute, this label will be used when referring to the application throughout * specifies an android:label attribute, this label will be used when referring to the
* system settings; otherwise, the application label will be used. * application throughout system settings; otherwise, the application label will be used.
* </ul> * </ul>
* *
* <p>The system keeps track of an active scorer application; at any time, only this application * <p>The system keeps track of an active scorer application; at any time, only this application
@@ -194,8 +194,8 @@ public class NetworkScoreManager {
* *
* @return true if the operation succeeded, or false if the new package is not a valid scorer. * @return true if the operation succeeded, or false if the new package is not a valid scorer.
* @throws SecurityException if the caller does not hold the * @throws SecurityException if the caller does not hold the
* {@link android.Manifest.permission#BROADCAST_SCORE_NETWORKS} permission indicating * {@link android.Manifest.permission#BROADCAST_NETWORK_PRIVILEGED} permission
* that it can manage scorer applications. * indicating that it can manage scorer applications.
* @hide * @hide
*/ */
public boolean setActiveScorer(String packageName) throws SecurityException { public boolean setActiveScorer(String packageName) throws SecurityException {
@@ -228,7 +228,7 @@ public class NetworkScoreManager {
* *
* @return true if the broadcast was sent, or false if there is no active scorer. * @return true if the broadcast was sent, or false if there is no active scorer.
* @throws SecurityException if the caller does not hold the * @throws SecurityException if the caller does not hold the
* {@link android.Manifest.permission#BROADCAST_SCORE_NETWORKS} permission. * {@link android.Manifest.permission#BROADCAST_NETWORK_PRIVILEGED} permission.
* @hide * @hide
*/ */
public boolean requestScores(NetworkKey[] networks) throws SecurityException { public boolean requestScores(NetworkKey[] networks) throws SecurityException {
@@ -252,7 +252,7 @@ public class NetworkScoreManager {
* @param networkType the type of network this cache can handle. See {@link NetworkKey#type}. * @param networkType the type of network this cache can handle. See {@link NetworkKey#type}.
* @param scoreCache implementation of {@link INetworkScoreCache} to store the scores. * @param scoreCache implementation of {@link INetworkScoreCache} to store the scores.
* @throws SecurityException if the caller does not hold the * @throws SecurityException if the caller does not hold the
* {@link android.Manifest.permission#BROADCAST_SCORE_NETWORKS} permission. * {@link android.Manifest.permission#BROADCAST_NETWORK_PRIVILEGED} permission.
* @throws IllegalArgumentException if a score cache is already registered for this type. * @throws IllegalArgumentException if a score cache is already registered for this type.
* @hide * @hide
*/ */

View File

@@ -79,7 +79,7 @@ public final class NetworkScorerAppManager {
* <ul> * <ul>
* <li>Declares the {@link android.Manifest.permission#SCORE_NETWORKS} permission. * <li>Declares the {@link android.Manifest.permission#SCORE_NETWORKS} permission.
* <li>Includes a receiver for {@link NetworkScoreManager#ACTION_SCORE_NETWORKS} guarded by the * <li>Includes a receiver for {@link NetworkScoreManager#ACTION_SCORE_NETWORKS} guarded by the
* {@link android.Manifest.permission#BROADCAST_SCORE_NETWORKS} permission. * {@link android.Manifest.permission#BROADCAST_NETWORK_PRIVILEGED} permission.
* </ul> * </ul>
* *
* @return the list of scorers, or the empty list if there are no valid scorers. * @return the list of scorers, or the empty list if there are no valid scorers.
@@ -98,8 +98,8 @@ public final class NetworkScorerAppManager {
// Should never happen with queryBroadcastReceivers, but invalid nonetheless. // Should never happen with queryBroadcastReceivers, but invalid nonetheless.
continue; continue;
} }
if (!permission.BROADCAST_SCORE_NETWORKS.equals(receiverInfo.permission)) { if (!permission.BROADCAST_NETWORK_PRIVILEGED.equals(receiverInfo.permission)) {
// Receiver doesn't require the BROADCAST_SCORE_NETWORKS permission, which means // Receiver doesn't require the BROADCAST_NETWORK_PRIVILEGED permission, which means
// anyone could trigger network scoring and flood the framework with score requests. // anyone could trigger network scoring and flood the framework with score requests.
continue; continue;
} }

View File

@@ -2511,11 +2511,12 @@
android:description="@string/permdesc_broadcastWapPush" android:description="@string/permdesc_broadcastWapPush"
android:protectionLevel="signature" /> android:protectionLevel="signature" />
<!-- @SystemApi Allows an application to broadcast a SCORE_NETWORKS request. <!-- @SystemApi Allows an application to broadcast privileged networking requests.
<p>Not for use by third-party applications. @hide --> <p>Not for use by third-party applications. @hide -->
<permission android:name="android.permission.BROADCAST_SCORE_NETWORKS" <permission android:name="android.permission.BROADCAST_NETWORK_PRIVILEGED"
android:label="@string/permlab_broadcastScoreNetworks" android:permissionGroup="android.permission-group.NETWORK"
android:description="@string/permdesc_broadcastScoreNetworks" android:label="@string/permlab_broadcastNetworkPrivileged"
android:description="@string/permdesc_broadcastNetworkPrivileged"
android:protectionLevel="signature|system" /> android:protectionLevel="signature|system" />
<!-- @SystemApi Not for use by third-party applications. --> <!-- @SystemApi Not for use by third-party applications. -->

View File

@@ -977,10 +977,10 @@
<!-- TODO: Mark these as translatable when API is finalized. --> <!-- TODO: Mark these as translatable when API is finalized. -->
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_broadcastScoreNetworks" translatable="false">send score networks broadcast</string> <string name="permlab_broadcastNetworkPrivileged" translatable="false">send privileged network broadcasts</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permdesc_broadcastScoreNetworks" translatable="false">Allows the app <string name="permdesc_broadcastNetworkPrivileged" translatable="false">Allows the app
to broadcast a notification that networks need to be scored. to send privileged network broadcasts.
Never needed for normal apps. Never needed for normal apps.
</string> </string>

View File

@@ -59,7 +59,7 @@ public class NetworkScorerAppManagerTest extends InstrumentationTestCase {
// Package 1 - Valid scorer. // Package 1 - Valid scorer.
Pair<ResolveInfo, ResolveInfo> package1 = buildResolveInfo("package1", true, true, false); Pair<ResolveInfo, ResolveInfo> package1 = buildResolveInfo("package1", true, true, false);
// Package 2 - Receiver does not have BROADCAST_SCORE_NETWORKS permission. // Package 2 - Receiver does not have BROADCAST_NETWORK_PRIVILEGED permission.
Pair<ResolveInfo, ResolveInfo> package2 = buildResolveInfo("package2", false, true, false); Pair<ResolveInfo, ResolveInfo> package2 = buildResolveInfo("package2", false, true, false);
// Package 3 - App does not have SCORE_NETWORKS permission. // Package 3 - App does not have SCORE_NETWORKS permission.
@@ -134,7 +134,7 @@ public class NetworkScorerAppManagerTest extends InstrumentationTestCase {
resolveInfo.activityInfo.packageName = packageName; resolveInfo.activityInfo.packageName = packageName;
resolveInfo.activityInfo.applicationInfo = new ApplicationInfo(); resolveInfo.activityInfo.applicationInfo = new ApplicationInfo();
if (hasReceiverPermission) { if (hasReceiverPermission) {
resolveInfo.activityInfo.permission = permission.BROADCAST_SCORE_NETWORKS; resolveInfo.activityInfo.permission = permission.BROADCAST_NETWORK_PRIVILEGED;
} }
ResolveInfo configActivityInfo = null; ResolveInfo configActivityInfo = null;

View File

@@ -115,10 +115,10 @@ public class NetworkScoreService extends INetworkScoreService.Stub {
@Override @Override
public boolean clearScores() { public boolean clearScores() {
// Only the active scorer or the system (who can broadcast BROADCAST_SCORE_NETWORKS) should // Only the active scorer or the system (who can broadcast BROADCAST_NETWORK_PRIVILEGED)
// be allowed to flush all scores. // should be allowed to flush all scores.
if (NetworkScorerAppManager.isCallerActiveScorer(mContext, getCallingUid()) || if (NetworkScorerAppManager.isCallerActiveScorer(mContext, getCallingUid()) ||
mContext.checkCallingOrSelfPermission(permission.BROADCAST_SCORE_NETWORKS) == mContext.checkCallingOrSelfPermission(permission.BROADCAST_NETWORK_PRIVILEGED) ==
PackageManager.PERMISSION_GRANTED) { PackageManager.PERMISSION_GRANTED) {
clearInternal(); clearInternal();
return true; return true;
@@ -130,16 +130,16 @@ public class NetworkScoreService extends INetworkScoreService.Stub {
@Override @Override
public boolean setActiveScorer(String packageName) { public boolean setActiveScorer(String packageName) {
mContext.enforceCallingOrSelfPermission(permission.BROADCAST_SCORE_NETWORKS, TAG); mContext.enforceCallingOrSelfPermission(permission.BROADCAST_NETWORK_PRIVILEGED, TAG);
return setScorerInternal(packageName); return setScorerInternal(packageName);
} }
@Override @Override
public void disableScoring() { public void disableScoring() {
// Only the active scorer or the system (who can broadcast BROADCAST_SCORE_NETOWRKS) should // Only the active scorer or the system (who can broadcast BROADCAST_NETWORK_PRIVILEGED)
// be allowed to disable scoring. // should be allowed to disable scoring.
if (NetworkScorerAppManager.isCallerActiveScorer(mContext, getCallingUid()) || if (NetworkScorerAppManager.isCallerActiveScorer(mContext, getCallingUid()) ||
mContext.checkCallingOrSelfPermission(permission.BROADCAST_SCORE_NETWORKS) == mContext.checkCallingOrSelfPermission(permission.BROADCAST_NETWORK_PRIVILEGED) ==
PackageManager.PERMISSION_GRANTED) { PackageManager.PERMISSION_GRANTED) {
// The return value is discarded here because at this point, the call should always // The return value is discarded here because at this point, the call should always
// succeed. The only reason for failure is if the new package is not a valid scorer, but // succeed. The only reason for failure is if the new package is not a valid scorer, but
@@ -188,7 +188,7 @@ public class NetworkScoreService extends INetworkScoreService.Stub {
@Override @Override
public void registerNetworkScoreCache(int networkType, INetworkScoreCache scoreCache) { public void registerNetworkScoreCache(int networkType, INetworkScoreCache scoreCache) {
mContext.enforceCallingOrSelfPermission(permission.BROADCAST_SCORE_NETWORKS, TAG); mContext.enforceCallingOrSelfPermission(permission.BROADCAST_NETWORK_PRIVILEGED, TAG);
synchronized (mScoreCaches) { synchronized (mScoreCaches) {
if (mScoreCaches.containsKey(networkType)) { if (mScoreCaches.containsKey(networkType)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(