Loading Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -1756,6 +1756,7 @@ droidstubs { last_released: { api_file: ":last-released-public-api", removed_api_file: "api/removed.txt", baseline_file: ":public-api-incompatibilities-with-last-released", }, }, jdiff_enabled: true, Loading @@ -1781,6 +1782,7 @@ droidstubs { last_released: { api_file: ":last-released-system-api", removed_api_file: "api/system-removed.txt", baseline_file: ":system-api-incompatibilities-with-last-released" }, }, jdiff_enabled: true, Loading core/java/android/app/SystemServiceRegistry.java +2 −1 Original line number Diff line number Diff line Loading @@ -1162,7 +1162,8 @@ final class SystemServiceRegistry { @Override public AppPredictionManager createService(ContextImpl ctx) throws ServiceNotFoundException { return new AppPredictionManager(ctx); IBinder b = ServiceManager.getService(Context.APP_PREDICTION_SERVICE); return b == null ? null : new AppPredictionManager(ctx); } }); Loading core/java/android/content/Context.java +3 −0 Original line number Diff line number Diff line Loading @@ -4106,6 +4106,9 @@ public abstract class Context { /** * Official published name of the app prediction service. * * <p><b>NOTE: </b> this service is optional; callers of * {@code Context.getSystemServiceName(APP_PREDICTION_SERVICE)} should check for {@code null}. * * @hide * @see #getSystemService(String) */ Loading core/java/android/net/util/MultinetworkPolicyTracker.java +26 −9 Original line number Diff line number Diff line Loading @@ -16,28 +16,31 @@ package android.net.util; import static android.provider.Settings.Global.NETWORK_AVOID_BAD_WIFI; import static android.provider.Settings.Global.NETWORK_METERED_MULTIPATH_PREFERENCE; import android.annotation.NonNull; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Resources; import android.database.ContentObserver; import android.net.ConnectivityManager; import android.net.Uri; import android.os.Handler; import android.os.Message; import android.os.UserHandle; import android.provider.Settings; import android.telephony.PhoneStateListener; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.util.Slog; import java.util.Arrays; import java.util.List; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import static android.provider.Settings.Global.NETWORK_AVOID_BAD_WIFI; import static android.provider.Settings.Global.NETWORK_METERED_MULTIPATH_PREFERENCE; import java.util.Arrays; import java.util.List; /** * A class to encapsulate management of the "Smart Networking" capability of Loading Loading @@ -69,6 +72,7 @@ public class MultinetworkPolicyTracker { private volatile boolean mAvoidBadWifi = true; private volatile int mMeteredMultipathPreference; private int mActiveSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; public MultinetworkPolicyTracker(Context ctx, Handler handler) { this(ctx, handler, null); Loading @@ -95,6 +99,14 @@ public class MultinetworkPolicyTracker { } }; TelephonyManager.from(ctx).listen(new PhoneStateListener() { @Override public void onActiveDataSubscriptionIdChanged(int subId) { mActiveSubId = subId; reevaluate(); } }, PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE); updateAvoidBadWifi(); updateMeteredMultipathPreference(); } Loading Loading @@ -131,7 +143,12 @@ public class MultinetworkPolicyTracker { * Whether the device or carrier configuration disables avoiding bad wifi by default. */ public boolean configRestrictsAvoidBadWifi() { return (mContext.getResources().getInteger(R.integer.config_networkAvoidBadWifi) == 0); return (getResourcesForActiveSubId().getInteger(R.integer.config_networkAvoidBadWifi) == 0); } @NonNull private Resources getResourcesForActiveSubId() { return SubscriptionManager.getResourcesForSubId(mContext, mActiveSubId); } /** Loading core/java/com/android/internal/app/ChooserActivity.java +34 −0 Original line number Diff line number Diff line Loading @@ -164,6 +164,8 @@ public class ChooserActivity extends ResolverActivity { public static final String LAUNCH_LOCATON_DIRECT_SHARE = "direct_share"; private static final int APP_PREDICTION_SHARE_TARGET_QUERY_PACKAGE_LIMIT = 20; public static final String APP_PREDICTION_INTENT_FILTER_KEY = "intent_filter"; private boolean mIsAppPredictorComponentAvailable; private AppPredictor mAppPredictor; private AppPredictor.Callback mAppPredictorCallback; private Map<ChooserTarget, AppTarget> mDirectShareAppTargetCache; Loading Loading @@ -617,6 +619,9 @@ public class ChooserActivity extends ResolverActivity { .addTaggedData(MetricsEvent.FIELD_SHARESHEET_MIMETYPE, target.getType()) .addTaggedData(MetricsEvent.FIELD_TIME_TO_APP_TARGETS, systemCost)); // This is the only place this value is being set. Effectively final. mIsAppPredictorComponentAvailable = isAppPredictionServiceAvailable(); AppPredictor appPredictor = getAppPredictorForDirectShareIfEnabled(); if (appPredictor != null) { mDirectShareAppTargetCache = new HashMap<>(); Loading Loading @@ -706,6 +711,32 @@ public class ChooserActivity extends ResolverActivity { } } /** * Returns true if app prediction service is defined and the component exists on device. */ private boolean isAppPredictionServiceAvailable() { final String appPredictionServiceName = getString(R.string.config_defaultAppPredictionService); if (appPredictionServiceName == null) { return false; } final ComponentName appPredictionComponentName = ComponentName.unflattenFromString(appPredictionServiceName); if (appPredictionComponentName == null) { return false; } // Check if the app prediction component actually exists on the device. Intent intent = new Intent(); intent.setComponent(appPredictionComponentName); if (getPackageManager().resolveService(intent, PackageManager.MATCH_ALL) == null) { Log.e(TAG, "App prediction service is defined, but does not exist: " + appPredictionServiceName); return false; } return true; } /** * Check if the profile currently used is a work profile. * @return true if it is work profile, false if it is parent profile (or no work profile is Loading Loading @@ -1693,6 +1724,9 @@ public class ChooserActivity extends ResolverActivity { @Nullable private AppPredictor getAppPredictor() { if (!mIsAppPredictorComponentAvailable) { return null; } if (mAppPredictor == null && getPackageManager().getAppPredictionServicePackageName() != null) { final IntentFilter filter = getTargetIntentFilter(); Loading Loading
Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -1756,6 +1756,7 @@ droidstubs { last_released: { api_file: ":last-released-public-api", removed_api_file: "api/removed.txt", baseline_file: ":public-api-incompatibilities-with-last-released", }, }, jdiff_enabled: true, Loading @@ -1781,6 +1782,7 @@ droidstubs { last_released: { api_file: ":last-released-system-api", removed_api_file: "api/system-removed.txt", baseline_file: ":system-api-incompatibilities-with-last-released" }, }, jdiff_enabled: true, Loading
core/java/android/app/SystemServiceRegistry.java +2 −1 Original line number Diff line number Diff line Loading @@ -1162,7 +1162,8 @@ final class SystemServiceRegistry { @Override public AppPredictionManager createService(ContextImpl ctx) throws ServiceNotFoundException { return new AppPredictionManager(ctx); IBinder b = ServiceManager.getService(Context.APP_PREDICTION_SERVICE); return b == null ? null : new AppPredictionManager(ctx); } }); Loading
core/java/android/content/Context.java +3 −0 Original line number Diff line number Diff line Loading @@ -4106,6 +4106,9 @@ public abstract class Context { /** * Official published name of the app prediction service. * * <p><b>NOTE: </b> this service is optional; callers of * {@code Context.getSystemServiceName(APP_PREDICTION_SERVICE)} should check for {@code null}. * * @hide * @see #getSystemService(String) */ Loading
core/java/android/net/util/MultinetworkPolicyTracker.java +26 −9 Original line number Diff line number Diff line Loading @@ -16,28 +16,31 @@ package android.net.util; import static android.provider.Settings.Global.NETWORK_AVOID_BAD_WIFI; import static android.provider.Settings.Global.NETWORK_METERED_MULTIPATH_PREFERENCE; import android.annotation.NonNull; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Resources; import android.database.ContentObserver; import android.net.ConnectivityManager; import android.net.Uri; import android.os.Handler; import android.os.Message; import android.os.UserHandle; import android.provider.Settings; import android.telephony.PhoneStateListener; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.util.Slog; import java.util.Arrays; import java.util.List; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import static android.provider.Settings.Global.NETWORK_AVOID_BAD_WIFI; import static android.provider.Settings.Global.NETWORK_METERED_MULTIPATH_PREFERENCE; import java.util.Arrays; import java.util.List; /** * A class to encapsulate management of the "Smart Networking" capability of Loading Loading @@ -69,6 +72,7 @@ public class MultinetworkPolicyTracker { private volatile boolean mAvoidBadWifi = true; private volatile int mMeteredMultipathPreference; private int mActiveSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; public MultinetworkPolicyTracker(Context ctx, Handler handler) { this(ctx, handler, null); Loading @@ -95,6 +99,14 @@ public class MultinetworkPolicyTracker { } }; TelephonyManager.from(ctx).listen(new PhoneStateListener() { @Override public void onActiveDataSubscriptionIdChanged(int subId) { mActiveSubId = subId; reevaluate(); } }, PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE); updateAvoidBadWifi(); updateMeteredMultipathPreference(); } Loading Loading @@ -131,7 +143,12 @@ public class MultinetworkPolicyTracker { * Whether the device or carrier configuration disables avoiding bad wifi by default. */ public boolean configRestrictsAvoidBadWifi() { return (mContext.getResources().getInteger(R.integer.config_networkAvoidBadWifi) == 0); return (getResourcesForActiveSubId().getInteger(R.integer.config_networkAvoidBadWifi) == 0); } @NonNull private Resources getResourcesForActiveSubId() { return SubscriptionManager.getResourcesForSubId(mContext, mActiveSubId); } /** Loading
core/java/com/android/internal/app/ChooserActivity.java +34 −0 Original line number Diff line number Diff line Loading @@ -164,6 +164,8 @@ public class ChooserActivity extends ResolverActivity { public static final String LAUNCH_LOCATON_DIRECT_SHARE = "direct_share"; private static final int APP_PREDICTION_SHARE_TARGET_QUERY_PACKAGE_LIMIT = 20; public static final String APP_PREDICTION_INTENT_FILTER_KEY = "intent_filter"; private boolean mIsAppPredictorComponentAvailable; private AppPredictor mAppPredictor; private AppPredictor.Callback mAppPredictorCallback; private Map<ChooserTarget, AppTarget> mDirectShareAppTargetCache; Loading Loading @@ -617,6 +619,9 @@ public class ChooserActivity extends ResolverActivity { .addTaggedData(MetricsEvent.FIELD_SHARESHEET_MIMETYPE, target.getType()) .addTaggedData(MetricsEvent.FIELD_TIME_TO_APP_TARGETS, systemCost)); // This is the only place this value is being set. Effectively final. mIsAppPredictorComponentAvailable = isAppPredictionServiceAvailable(); AppPredictor appPredictor = getAppPredictorForDirectShareIfEnabled(); if (appPredictor != null) { mDirectShareAppTargetCache = new HashMap<>(); Loading Loading @@ -706,6 +711,32 @@ public class ChooserActivity extends ResolverActivity { } } /** * Returns true if app prediction service is defined and the component exists on device. */ private boolean isAppPredictionServiceAvailable() { final String appPredictionServiceName = getString(R.string.config_defaultAppPredictionService); if (appPredictionServiceName == null) { return false; } final ComponentName appPredictionComponentName = ComponentName.unflattenFromString(appPredictionServiceName); if (appPredictionComponentName == null) { return false; } // Check if the app prediction component actually exists on the device. Intent intent = new Intent(); intent.setComponent(appPredictionComponentName); if (getPackageManager().resolveService(intent, PackageManager.MATCH_ALL) == null) { Log.e(TAG, "App prediction service is defined, but does not exist: " + appPredictionServiceName); return false; } return true; } /** * Check if the profile currently used is a work profile. * @return true if it is work profile, false if it is parent profile (or no work profile is Loading Loading @@ -1693,6 +1724,9 @@ public class ChooserActivity extends ResolverActivity { @Nullable private AppPredictor getAppPredictor() { if (!mIsAppPredictorComponentAvailable) { return null; } if (mAppPredictor == null && getPackageManager().getAppPredictionServicePackageName() != null) { final IntentFilter filter = getTargetIntentFilter(); Loading