Loading core/java/android/net/NetworkScoreManager.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -105,7 +105,8 @@ public class NetworkScoreManager { /** /** * Broadcast action: the active scorer has been changed. Scorer apps may listen to this to * Broadcast action: the active scorer has been changed. Scorer apps may listen to this to * perform initialization once selected as the active scorer, or clean up unneeded resources * perform initialization once selected as the active scorer, or clean up unneeded resources * if another scorer has been selected. Note that it is unnecessary to clear existing scores as * if another scorer has been selected. This is an explicit broadcast only sent to the * previous scorer and new scorer. Note that it is unnecessary to clear existing scores as * this is handled by the system. * this is handled by the system. * * * <p>The new scorer will be specified in {@link #EXTRA_NEW_SCORER}. * <p>The new scorer will be specified in {@link #EXTRA_NEW_SCORER}. Loading services/core/java/com/android/server/NetworkScoreService.java +15 −3 Original line number Original line Diff line number Diff line Loading @@ -234,12 +234,24 @@ public class NetworkScoreService extends INetworkScoreService.Stub { // safety as scores should never be compared across apps; in practice, Settings should // safety as scores should never be compared across apps; in practice, Settings should // only be allowing valid apps to be set as scorers, so failure here should be rare. // only be allowing valid apps to be set as scorers, so failure here should be rare. clearInternal(); clearInternal(); // Get the scorer that is about to be replaced, if any, so we can notify it directly. NetworkScorerAppData prevScorer = NetworkScorerAppManager.getActiveScorer(mContext); boolean result = NetworkScorerAppManager.setActiveScorer(mContext, packageName); boolean result = NetworkScorerAppManager.setActiveScorer(mContext, packageName); if (result) { if (result) { // new scorer successfully set registerPackageReceiverIfNeeded(); registerPackageReceiverIfNeeded(); Intent intent = new Intent(NetworkScoreManager.ACTION_SCORER_CHANGED); Intent intent = new Intent(NetworkScoreManager.ACTION_SCORER_CHANGED); if (prevScorer != null) { // Directly notify the old scorer. intent.setPackage(prevScorer.mPackageName); // TODO: Need to update when we support per-user scorers. http://b/23422763 mContext.sendBroadcastAsUser(intent, UserHandle.SYSTEM); } if (packageName != null) { // Then notify the new scorer intent.putExtra(NetworkScoreManager.EXTRA_NEW_SCORER, packageName); intent.putExtra(NetworkScoreManager.EXTRA_NEW_SCORER, packageName); mContext.sendBroadcastAsUser(intent, UserHandle.ALL); intent.setPackage(packageName); // TODO: Need to update when we support per-user scorers. http://b/23422763 mContext.sendBroadcastAsUser(intent, UserHandle.SYSTEM); } } } return result; return result; } finally { } finally { Loading Loading
core/java/android/net/NetworkScoreManager.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -105,7 +105,8 @@ public class NetworkScoreManager { /** /** * Broadcast action: the active scorer has been changed. Scorer apps may listen to this to * Broadcast action: the active scorer has been changed. Scorer apps may listen to this to * perform initialization once selected as the active scorer, or clean up unneeded resources * perform initialization once selected as the active scorer, or clean up unneeded resources * if another scorer has been selected. Note that it is unnecessary to clear existing scores as * if another scorer has been selected. This is an explicit broadcast only sent to the * previous scorer and new scorer. Note that it is unnecessary to clear existing scores as * this is handled by the system. * this is handled by the system. * * * <p>The new scorer will be specified in {@link #EXTRA_NEW_SCORER}. * <p>The new scorer will be specified in {@link #EXTRA_NEW_SCORER}. Loading
services/core/java/com/android/server/NetworkScoreService.java +15 −3 Original line number Original line Diff line number Diff line Loading @@ -234,12 +234,24 @@ public class NetworkScoreService extends INetworkScoreService.Stub { // safety as scores should never be compared across apps; in practice, Settings should // safety as scores should never be compared across apps; in practice, Settings should // only be allowing valid apps to be set as scorers, so failure here should be rare. // only be allowing valid apps to be set as scorers, so failure here should be rare. clearInternal(); clearInternal(); // Get the scorer that is about to be replaced, if any, so we can notify it directly. NetworkScorerAppData prevScorer = NetworkScorerAppManager.getActiveScorer(mContext); boolean result = NetworkScorerAppManager.setActiveScorer(mContext, packageName); boolean result = NetworkScorerAppManager.setActiveScorer(mContext, packageName); if (result) { if (result) { // new scorer successfully set registerPackageReceiverIfNeeded(); registerPackageReceiverIfNeeded(); Intent intent = new Intent(NetworkScoreManager.ACTION_SCORER_CHANGED); Intent intent = new Intent(NetworkScoreManager.ACTION_SCORER_CHANGED); if (prevScorer != null) { // Directly notify the old scorer. intent.setPackage(prevScorer.mPackageName); // TODO: Need to update when we support per-user scorers. http://b/23422763 mContext.sendBroadcastAsUser(intent, UserHandle.SYSTEM); } if (packageName != null) { // Then notify the new scorer intent.putExtra(NetworkScoreManager.EXTRA_NEW_SCORER, packageName); intent.putExtra(NetworkScoreManager.EXTRA_NEW_SCORER, packageName); mContext.sendBroadcastAsUser(intent, UserHandle.ALL); intent.setPackage(packageName); // TODO: Need to update when we support per-user scorers. http://b/23422763 mContext.sendBroadcastAsUser(intent, UserHandle.SYSTEM); } } } return result; return result; } finally { } finally { Loading