Loading core/java/android/net/NetworkScorerAppManager.java +1 −7 Original line number Diff line number Diff line Loading @@ -231,13 +231,7 @@ public class NetworkScorerAppManager { if (defaultApp == null) { return false; } if (callingUid != defaultApp.packageUid) { return false; } // To be extra safe, ensure the caller holds the SCORE_NETWORKS permission. It always // should, since it couldn't become the active scorer otherwise, but this can't hurt. return mContext.checkCallingPermission(Manifest.permission.SCORE_NETWORKS) == PackageManager.PERMISSION_GRANTED; return callingUid == defaultApp.packageUid; } private boolean isNetworkRecommendationsDisabled() { Loading core/tests/coretests/src/android/net/NetworkScorerAppManagerTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,25 @@ public class NetworkScorerAppManagerTest extends InstrumentationTestCase { assertNull(activeScorer); } public void testIsCallerActiveScorer_providerNotAvailable() throws Exception { ContentResolver cr = mTargetContext.getContentResolver(); Settings.Global.putInt(cr, Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 1); assertFalse(mNetworkScorerAppManager.isCallerActiveScorer(924)); } public void testIsCallerActiveScorer_providerAvailable() throws Exception { setNetworkRecommendationPackageNames("package1"); mockScoreNetworksGranted("package1"); mockRecommendationServiceAvailable("package1", 924 /* packageUid */); ContentResolver cr = mTargetContext.getContentResolver(); Settings.Global.putInt(cr, Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 1); assertTrue(mNetworkScorerAppManager.isCallerActiveScorer(924)); assertFalse(mNetworkScorerAppManager.isCallerActiveScorer(925)); } private void setNetworkRecommendationPackageNames(String... names) { if (names == null) { names = new String[0]; Loading Loading
core/java/android/net/NetworkScorerAppManager.java +1 −7 Original line number Diff line number Diff line Loading @@ -231,13 +231,7 @@ public class NetworkScorerAppManager { if (defaultApp == null) { return false; } if (callingUid != defaultApp.packageUid) { return false; } // To be extra safe, ensure the caller holds the SCORE_NETWORKS permission. It always // should, since it couldn't become the active scorer otherwise, but this can't hurt. return mContext.checkCallingPermission(Manifest.permission.SCORE_NETWORKS) == PackageManager.PERMISSION_GRANTED; return callingUid == defaultApp.packageUid; } private boolean isNetworkRecommendationsDisabled() { Loading
core/tests/coretests/src/android/net/NetworkScorerAppManagerTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,25 @@ public class NetworkScorerAppManagerTest extends InstrumentationTestCase { assertNull(activeScorer); } public void testIsCallerActiveScorer_providerNotAvailable() throws Exception { ContentResolver cr = mTargetContext.getContentResolver(); Settings.Global.putInt(cr, Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 1); assertFalse(mNetworkScorerAppManager.isCallerActiveScorer(924)); } public void testIsCallerActiveScorer_providerAvailable() throws Exception { setNetworkRecommendationPackageNames("package1"); mockScoreNetworksGranted("package1"); mockRecommendationServiceAvailable("package1", 924 /* packageUid */); ContentResolver cr = mTargetContext.getContentResolver(); Settings.Global.putInt(cr, Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 1); assertTrue(mNetworkScorerAppManager.isCallerActiveScorer(924)); assertFalse(mNetworkScorerAppManager.isCallerActiveScorer(925)); } private void setNetworkRecommendationPackageNames(String... names) { if (names == null) { names = new String[0]; Loading