Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a844fcf authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Background data notification, API clean up.

When restricting background data, show ongoing notification to give
easy access to re-enable. Deprecate getBackgroundDataSetting() API
to always return true, since NetworkInfo.isConnected() is new source
of truth. Handle upgrade path by reading from existing secure value,
and kick one last broadcast when changing value. Remove background
data code from ConnectivityService.

Remove warning alerts, since they push ifaces into restricted list;
should only happen when iface has limit.

Bug: 5163559, 5129421
Change-Id: I0064d9d643656a4d32aaae51d4a58bce49fe295f
parent b51645ee
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -11400,7 +11400,7 @@ package android.net {
    method public android.net.NetworkInfo getActiveNetworkInfo();
    method public android.net.NetworkQuotaInfo getActiveNetworkQuotaInfo();
    method public android.net.NetworkInfo[] getAllNetworkInfo();
    method public boolean getBackgroundDataSetting();
    method public deprecated boolean getBackgroundDataSetting();
    method public android.net.NetworkInfo getNetworkInfo(int);
    method public int getNetworkPreference();
    method public static boolean isNetworkTypeValid(int);
@@ -17049,7 +17049,7 @@ package android.provider {
    field public static final java.lang.String ALLOWED_GEOLOCATION_ORIGINS = "allowed_geolocation_origins";
    field public static final java.lang.String ALLOW_MOCK_LOCATION = "mock_location";
    field public static final java.lang.String ANDROID_ID = "android_id";
    field public static final java.lang.String BACKGROUND_DATA = "background_data";
    field public static final deprecated java.lang.String BACKGROUND_DATA = "background_data";
    field public static final java.lang.String BLUETOOTH_ON = "bluetooth_on";
    field public static final android.net.Uri CONTENT_URI;
    field public static final java.lang.String DATA_ROAMING = "data_roaming";
+12 −10
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.internal.util.Preconditions.checkNotNull;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.os.Binder;
import android.os.Build.VERSION_CODES;
import android.os.RemoteException;

import java.net.InetAddress;
@@ -494,16 +495,19 @@ public class ConnectivityManager {
     * <p>
     * All applications that have background services that use the network
     * should listen to {@link #ACTION_BACKGROUND_DATA_SETTING_CHANGED}.
     * <p>
     * As of {@link VERSION_CODES#ICE_CREAM_SANDWICH}, availability of
     * background data depends on several combined factors, and this method will
     * always return {@code true}. Instead, when background data is unavailable,
     * {@link #getActiveNetworkInfo()} will now appear disconnected.
     *
     * @return Whether background data usage is allowed.
     */
    @Deprecated
    public boolean getBackgroundDataSetting() {
        try {
            return mService.getBackgroundDataSetting();
        } catch (RemoteException e) {
            // Err on the side of safety
            return false;
        }
        // assume that background data is allowed; final authority is
        // NetworkInfo which may be blocked.
        return true;
    }

    /**
@@ -516,11 +520,9 @@ public class ConnectivityManager {
     * @see #getBackgroundDataSetting()
     * @hide
     */
    @Deprecated
    public void setBackgroundDataSetting(boolean allowBackgroundData) {
        try {
            mService.setBackgroundDataSetting(allowBackgroundData);
        } catch (RemoteException e) {
        }
        // ignored
    }

    /**
+0 −4
Original line number Diff line number Diff line
@@ -63,10 +63,6 @@ interface IConnectivityManager

    boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress);

    boolean getBackgroundDataSetting();

    void setBackgroundDataSetting(boolean allowBackgroundData);

    boolean getMobileDataEnabled();

    void setMobileDataEnabled(boolean enabled);
+1 −0
Original line number Diff line number Diff line
@@ -3081,6 +3081,7 @@ public final class Settings {
         * Whether background data usage is allowed by the user. See
         * ConnectivityManager for more info.
         */
        @Deprecated
        public static final String BACKGROUND_DATA = "background_data";

        /**
+6 −1
Original line number Diff line number Diff line
@@ -3073,7 +3073,7 @@
    <!-- Notification title when mobile data usage has exceeded limit threshold, and has been disabled. [CHAR LIMIT=32] -->
    <string name="data_usage_mobile_limit_title">Mobile data disabled</string>
    <!-- Notification body when data usage has exceeded limit threshold, and has been disabled. [CHAR LIMIT=32] -->
    <string name="data_usage_limit_body">tap to enable</string>
    <string name="data_usage_limit_body">Touch to enable</string>

    <!-- Notification title when 2G-3G data usage has exceeded limit threshold. [CHAR LIMIT=32] -->
    <string name="data_usage_3g_limit_snoozed_title">2G-3G data limit exceeded</string>
@@ -3084,6 +3084,11 @@
    <!-- Notification body when data usage has exceeded limit threshold. [CHAR LIMIT=32] -->
    <string name="data_usage_limit_snoozed_body"><xliff:g id="size" example="3.8GB">%s</xliff:g> over specified limit</string>

    <!-- Notification title when background data usage is limited. [CHAR LIMIT=32] -->
    <string name="data_usage_restricted_title">Background data restricted</string>
    <!-- Notification body when background data usage is limited. [CHAR LIMIT=32] -->
    <string name="data_usage_restricted_body">Touch to remove restriction</string>

    <!-- SSL Certificate dialogs -->
    <!-- Title for an SSL Certificate dialog -->
    <string name="ssl_certificate">Security certificate</string>
Loading