Loading core/java/android/net/INetworkScoreService.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.net; import android.net.INetworkScoreCache; import android.net.NetworkKey; import android.net.NetworkScorerAppManager; import android.net.RecommendationRequest; import android.net.RecommendationResult; import android.net.ScoredNetwork; Loading Loading @@ -130,4 +131,6 @@ interface INetworkScoreService */ oneway void requestRecommendationAsync(in RecommendationRequest request, in RemoteCallback remoteCallback); NetworkScorerAppManager.NetworkScorerAppData getActiveScorer(); } core/java/android/net/NetworkScoreManager.java +14 −0 Original line number Diff line number Diff line Loading @@ -185,6 +185,20 @@ public class NetworkScoreManager { } } /** * Returns metadata about the active scorer or <code>null</code> if there is no active scorer. * * @hide */ @Nullable public NetworkScorerAppData getActiveScorer() { try { return mService.getActiveScorer(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Update network scores. * Loading core/java/android/net/NetworkScorerAppManager.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /** * Copyright (c) 2017, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.net; parcelable NetworkScorerAppManager.NetworkScorerAppData; core/java/android/net/NetworkScorerAppManager.java +32 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Parcel; import android.os.Parcelable; import android.os.UserHandle; import android.provider.Settings; import android.text.TextUtils; Loading Loading @@ -54,7 +56,7 @@ public class NetworkScorerAppManager { /** * Holds metadata about a discovered network scorer/recommendation application. */ public static class NetworkScorerAppData { public static final class NetworkScorerAppData implements Parcelable { /** UID of the scorer app. */ public final int packageUid; private final ComponentName mRecommendationService; Loading @@ -64,6 +66,35 @@ public class NetworkScorerAppManager { this.mRecommendationService = recommendationServiceComp; } protected NetworkScorerAppData(Parcel in) { packageUid = in.readInt(); mRecommendationService = ComponentName.readFromParcel(in); } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(packageUid); ComponentName.writeToParcel(mRecommendationService, dest); } @Override public int describeContents() { return 0; } public static final Creator<NetworkScorerAppData> CREATOR = new Creator<NetworkScorerAppData>() { @Override public NetworkScorerAppData createFromParcel(Parcel in) { return new NetworkScorerAppData(in); } @Override public NetworkScorerAppData[] newArray(int size) { return new NetworkScorerAppData[size]; } }; public String getRecommendationServicePackageName() { return mRecommendationService.getPackageName(); } Loading services/core/java/com/android/server/NetworkScoreService.java +26 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.os.IBinder; import android.os.IRemoteCallback; import android.os.Looper; import android.os.Message; import android.os.Process; import android.os.RemoteCallback; import android.os.RemoteCallbackList; import android.os.RemoteException; Loading Loading @@ -676,6 +677,10 @@ public class NetworkScoreService extends INetworkScoreService.Stub { } } private boolean isCallerSystemProcess(int callingUid) { return callingUid == Process.SYSTEM_UID; } /** * Obtain the package name of the current active network scorer. * Loading @@ -692,6 +697,27 @@ public class NetworkScoreService extends INetworkScoreService.Stub { return null; } /** * Returns metadata about the active scorer or <code>null</code> if there is no active scorer. */ @Override public NetworkScorerAppData getActiveScorer() { // Only the system can access this data. if (isCallerSystemProcess(getCallingUid()) || callerCanRequestScores()) { synchronized (mServiceConnectionLock) { if (mServiceConnection != null) { return mServiceConnection.mAppData; } } } else { throw new SecurityException( "Caller is neither the system process nor a score requester."); } return null; } @Override public void disableScoring() { // Only the active scorer or the system should be allowed to disable scoring. Loading Loading
core/java/android/net/INetworkScoreService.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.net; import android.net.INetworkScoreCache; import android.net.NetworkKey; import android.net.NetworkScorerAppManager; import android.net.RecommendationRequest; import android.net.RecommendationResult; import android.net.ScoredNetwork; Loading Loading @@ -130,4 +131,6 @@ interface INetworkScoreService */ oneway void requestRecommendationAsync(in RecommendationRequest request, in RemoteCallback remoteCallback); NetworkScorerAppManager.NetworkScorerAppData getActiveScorer(); }
core/java/android/net/NetworkScoreManager.java +14 −0 Original line number Diff line number Diff line Loading @@ -185,6 +185,20 @@ public class NetworkScoreManager { } } /** * Returns metadata about the active scorer or <code>null</code> if there is no active scorer. * * @hide */ @Nullable public NetworkScorerAppData getActiveScorer() { try { return mService.getActiveScorer(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Update network scores. * Loading
core/java/android/net/NetworkScorerAppManager.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /** * Copyright (c) 2017, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.net; parcelable NetworkScorerAppManager.NetworkScorerAppData;
core/java/android/net/NetworkScorerAppManager.java +32 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Parcel; import android.os.Parcelable; import android.os.UserHandle; import android.provider.Settings; import android.text.TextUtils; Loading Loading @@ -54,7 +56,7 @@ public class NetworkScorerAppManager { /** * Holds metadata about a discovered network scorer/recommendation application. */ public static class NetworkScorerAppData { public static final class NetworkScorerAppData implements Parcelable { /** UID of the scorer app. */ public final int packageUid; private final ComponentName mRecommendationService; Loading @@ -64,6 +66,35 @@ public class NetworkScorerAppManager { this.mRecommendationService = recommendationServiceComp; } protected NetworkScorerAppData(Parcel in) { packageUid = in.readInt(); mRecommendationService = ComponentName.readFromParcel(in); } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(packageUid); ComponentName.writeToParcel(mRecommendationService, dest); } @Override public int describeContents() { return 0; } public static final Creator<NetworkScorerAppData> CREATOR = new Creator<NetworkScorerAppData>() { @Override public NetworkScorerAppData createFromParcel(Parcel in) { return new NetworkScorerAppData(in); } @Override public NetworkScorerAppData[] newArray(int size) { return new NetworkScorerAppData[size]; } }; public String getRecommendationServicePackageName() { return mRecommendationService.getPackageName(); } Loading
services/core/java/com/android/server/NetworkScoreService.java +26 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.os.IBinder; import android.os.IRemoteCallback; import android.os.Looper; import android.os.Message; import android.os.Process; import android.os.RemoteCallback; import android.os.RemoteCallbackList; import android.os.RemoteException; Loading Loading @@ -676,6 +677,10 @@ public class NetworkScoreService extends INetworkScoreService.Stub { } } private boolean isCallerSystemProcess(int callingUid) { return callingUid == Process.SYSTEM_UID; } /** * Obtain the package name of the current active network scorer. * Loading @@ -692,6 +697,27 @@ public class NetworkScoreService extends INetworkScoreService.Stub { return null; } /** * Returns metadata about the active scorer or <code>null</code> if there is no active scorer. */ @Override public NetworkScorerAppData getActiveScorer() { // Only the system can access this data. if (isCallerSystemProcess(getCallingUid()) || callerCanRequestScores()) { synchronized (mServiceConnectionLock) { if (mServiceConnection != null) { return mServiceConnection.mAppData; } } } else { throw new SecurityException( "Caller is neither the system process nor a score requester."); } return null; } @Override public void disableScoring() { // Only the active scorer or the system should be allowed to disable scoring. Loading