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

Commit c0997b0e authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Improve notification UI for lockdown VPN."

parents 8a64b1a7 4fa63b2d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ public class ConnectivityManager {
     * For a disconnect event, the boolean extra EXTRA_NO_CONNECTIVITY
     * is set to {@code true} if there are no connected networks at all.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";

    /**
@@ -78,6 +79,7 @@ public class ConnectivityManager {
     *
     * @hide
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String CONNECTIVITY_ACTION_IMMEDIATE =
            "android.net.conn.CONNECTIVITY_CHANGE_IMMEDIATE";

@@ -198,6 +200,7 @@ public class ConnectivityManager {
     * the network and it's condition.
     * @hide
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String INET_CONDITION_ACTION =
            "android.net.conn.INET_CONDITION_ACTION";

@@ -206,6 +209,7 @@ public class ConnectivityManager {
     * TODO - finish the doc
     * @hide
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_TETHER_STATE_CHANGED =
            "android.net.conn.TETHER_STATE_CHANGED";

@@ -233,6 +237,7 @@ public class ConnectivityManager {
     * notification.
     * @hide
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_CAPTIVE_PORTAL_TEST_COMPLETED =
            "android.net.conn.CAPTIVE_PORTAL_TEST_COMPLETED";
    /**
+2 −2
Original line number Diff line number Diff line
@@ -3512,8 +3512,8 @@
    <string name="vpn_lockdown_connected">Always-on VPN connected</string>
    <!-- Notification title when error connecting to lockdown VPN. -->
    <string name="vpn_lockdown_error">Always-on VPN error</string>
    <!-- Notification body that indicates user can touch to cycle lockdown VPN connection. -->
    <string name="vpn_lockdown_reset">Touch to reset connection</string>
    <!-- Notification body that indicates user can touch to configure lockdown VPN connection. -->
    <string name="vpn_lockdown_config">Touch to configure</string>

    <!-- Localized strings for WebView -->
    <!-- Label for button in a WebView that will open a chooser to choose a file to upload -->
+2 −1
Original line number Diff line number Diff line
@@ -1516,6 +1516,7 @@
  <java-symbol type="color" name="config_defaultNotificationColor" />
  <java-symbol type="drawable" name="ic_notification_ime_default" />
  <java-symbol type="drawable" name="ic_notify_wifidisplay" />
  <java-symbol type="drawable" name="ic_menu_refresh" />
  <java-symbol type="drawable" name="stat_notify_car_mode" />
  <java-symbol type="drawable" name="stat_notify_disabled" />
  <java-symbol type="drawable" name="stat_notify_disk_full" />
@@ -1649,7 +1650,7 @@
  <java-symbol type="string" name="vpn_lockdown_connecting" />
  <java-symbol type="string" name="vpn_lockdown_connected" />
  <java-symbol type="string" name="vpn_lockdown_error" />
  <java-symbol type="string" name="vpn_lockdown_reset" />
  <java-symbol type="string" name="vpn_lockdown_config" />
  <java-symbol type="string" name="wallpaper_binding_label" />
  <java-symbol type="string" name="wifi_display_notification_title" />
  <java-symbol type="string" name="wifi_display_notification_message" />
+13 −3
Original line number Diff line number Diff line
@@ -56,7 +56,9 @@ public class LockdownVpnTracker {
    private static final int MAX_ERROR_COUNT = 4;

    private static final String ACTION_LOCKDOWN_RESET = "com.android.server.action.LOCKDOWN_RESET";

    private static final String ACTION_VPN_SETTINGS = "android.net.vpn.SETTINGS";
    private static final String EXTRA_PICK_LOCKDOWN = "android.net.vpn.PICK_LOCKDOWN";

    private final Context mContext;
    private final INetworkManagementService mNetService;
@@ -66,7 +68,8 @@ public class LockdownVpnTracker {

    private final Object mStateLock = new Object();

    private PendingIntent mResetIntent;
    private final PendingIntent mConfigIntent;
    private final PendingIntent mResetIntent;

    private String mAcceptedEgressIface;
    private String mAcceptedIface;
@@ -86,6 +89,10 @@ public class LockdownVpnTracker {
        mVpn = Preconditions.checkNotNull(vpn);
        mProfile = Preconditions.checkNotNull(profile);

        final Intent configIntent = new Intent(ACTION_VPN_SETTINGS);
        configIntent.putExtra(EXTRA_PICK_LOCKDOWN, true);
        mConfigIntent = PendingIntent.getActivity(mContext, 0, configIntent, 0);

        final Intent resetIntent = new Intent(ACTION_LOCKDOWN_RESET);
        resetIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
        mResetIntent = PendingIntent.getBroadcast(mContext, 0, resetIntent, 0);
@@ -281,10 +288,13 @@ public class LockdownVpnTracker {
        builder.setWhen(0);
        builder.setSmallIcon(iconRes);
        builder.setContentTitle(mContext.getString(titleRes));
        builder.setContentText(mContext.getString(R.string.vpn_lockdown_reset));
        builder.setContentIntent(mResetIntent);
        builder.setContentText(mContext.getString(R.string.vpn_lockdown_config));
        builder.setContentIntent(mConfigIntent);
        builder.setPriority(Notification.PRIORITY_LOW);
        builder.setOngoing(true);
        builder.addAction(
                R.drawable.ic_menu_refresh, mContext.getString(R.string.reset), mResetIntent);

        NotificationManager.from(mContext).notify(TAG, 0, builder.build());
    }