diff options
| -rw-r--r-- | cmds/hid/jni/com_android_commands_hid_Device.cpp | 4 | ||||
| -rw-r--r-- | core/java/android/security/OWNERS | 4 | ||||
| -rw-r--r-- | core/java/android/security/net/config/OWNERS | 3 | ||||
| -rw-r--r-- | core/jni/com_android_internal_os_Zygote.cpp | 8 | ||||
| -rw-r--r-- | core/res/res/values/strings.xml | 7 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 2 | ||||
| -rw-r--r-- | libs/hwui/hwui/Canvas.h | 2 | ||||
| -rw-r--r-- | services/core/java/com/android/server/connectivity/Tethering.java | 63 | ||||
| -rw-r--r-- | services/core/jni/com_android_server_ConsumerIrService.cpp | 4 | ||||
| -rw-r--r-- | services/core/jni/com_android_server_location_GnssLocationProvider.cpp | 2 | ||||
| -rw-r--r-- | services/core/jni/com_android_server_power_PowerManagerService.cpp | 2 | ||||
| -rw-r--r-- | services/java/com/android/server/SystemServer.java | 9 | ||||
| -rw-r--r-- | tests/net/java/com/android/server/connectivity/TetheringTest.java | 86 |
13 files changed, 179 insertions, 17 deletions
diff --git a/cmds/hid/jni/com_android_commands_hid_Device.cpp b/cmds/hid/jni/com_android_commands_hid_Device.cpp index 1ea33ced7bbf..f9458a7e89fd 100644 --- a/cmds/hid/jni/com_android_commands_hid_Device.cpp +++ b/cmds/hid/jni/com_android_commands_hid_Device.cpp @@ -31,8 +31,8 @@ #include <android_os_MessageQueue.h> #include <core_jni_helpers.h> #include <jni.h> -#include <JNIHelp.h> -#include <ScopedPrimitiveArray.h> +#include <nativehelper/JNIHelp.h> +#include <nativehelper/ScopedPrimitiveArray.h> #include <ScopedUtfChars.h> #include <utils/Log.h> #include <utils/Looper.h> diff --git a/core/java/android/security/OWNERS b/core/java/android/security/OWNERS new file mode 100644 index 000000000000..7120376e31d2 --- /dev/null +++ b/core/java/android/security/OWNERS @@ -0,0 +1,4 @@ +per-file NetworkSecurityPolicy.java = cbrubaker@google.com +per-file NetworkSecurityPolicy.java = klyubin@google.com +per-file FrameworkNetworkSecurityPolicy.java = cbrubaker@google.com +per-file FrameworkNetworkSecurityPolicy.java = klyubin@google.com diff --git a/core/java/android/security/net/config/OWNERS b/core/java/android/security/net/config/OWNERS new file mode 100644 index 000000000000..53503734e0a7 --- /dev/null +++ b/core/java/android/security/net/config/OWNERS @@ -0,0 +1,3 @@ +set noparent +cbrubaker@google.com +klyubin@google.com diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 3887c76419cc..dba819480805 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -108,13 +108,9 @@ static void SigChldHandler(int /*signal_number*/) { // changes its locking strategy or its use of syscalls within the // lazy-init critical section, its use here may become unsafe. if (WIFEXITED(status)) { - if (WEXITSTATUS(status)) { - ALOGI("Process %d exited cleanly (%d)", pid, WEXITSTATUS(status)); - } + ALOGI("Process %d exited cleanly (%d)", pid, WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { - if (WTERMSIG(status) != SIGKILL) { - ALOGI("Process %d exited due to signal (%d)", pid, WTERMSIG(status)); - } + ALOGI("Process %d exited due to signal (%d)", pid, WTERMSIG(status)); if (WCOREDUMP(status)) { ALOGI("Process %d dumped core.", pid); } diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 05142673ff70..3ddf6e997b35 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -3380,6 +3380,13 @@ <string name="tethered_notification_title">Tethering or hotspot active</string> <string name="tethered_notification_message">Tap to set up.</string> + <!-- Strings for tether disabling notification --> + <!-- This notification is shown when tethering has been disabled on a user's device. + The device is managed by the user's employer. Tethering can't be turned on unless the + IT administrator allows it. The noun "admin" is another reference for "IT administrator." --> + <string name="disable_tether_notification_title">Tethering is disabled</string> + <string name="disable_tether_notification_message">Contact your admin for details</string> + <!-- Strings for possible PreferenceActivity Back/Next buttons --> <string name="back_button_label">Back</string> <string name="next_button_label">Next</string> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 34d4d6314080..c53093f20781 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1907,6 +1907,8 @@ <java-symbol type="string" name="smv_process" /> <java-symbol type="string" name="tethered_notification_message" /> <java-symbol type="string" name="tethered_notification_title" /> + <java-symbol type="string" name="disable_tether_notification_message" /> + <java-symbol type="string" name="disable_tether_notification_title" /> <java-symbol type="string" name="usb_accessory_notification_title" /> <java-symbol type="string" name="usb_mtp_notification_title" /> <java-symbol type="string" name="usb_charging_notification_title" /> diff --git a/libs/hwui/hwui/Canvas.h b/libs/hwui/hwui/Canvas.h index 55af33e80256..7b3199ce11a4 100644 --- a/libs/hwui/hwui/Canvas.h +++ b/libs/hwui/hwui/Canvas.h @@ -220,7 +220,7 @@ public: /** * Draws a VectorDrawable onto the canvas. */ - virtual void drawVectorDrawable(VectorDrawableRoot* tree); + virtual void drawVectorDrawable(VectorDrawableRoot* tree) = 0; /** * Converts utf16 text to glyphs, calculating position and boundary, diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java index 5ea6636db861..4574fba76624 100644 --- a/services/core/java/com/android/server/connectivity/Tethering.java +++ b/services/core/java/com/android/server/connectivity/Tethering.java @@ -70,6 +70,9 @@ import android.os.Parcel; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.UserHandle; +import android.os.UserManager; +import android.os.UserManagerInternal; +import android.os.UserManagerInternal.UserRestrictionsListener; import android.provider.Settings; import android.telephony.CarrierConfigManager; import android.telephony.TelephonyManager; @@ -86,6 +89,7 @@ import com.android.internal.util.MessageUtils; import com.android.internal.util.Protocol; import com.android.internal.util.State; import com.android.internal.util.StateMachine; +import com.android.server.LocalServices; import com.android.server.connectivity.tethering.IControlsTethering; import com.android.server.connectivity.tethering.IPv6TetheringCoordinator; import com.android.server.connectivity.tethering.OffloadController; @@ -233,6 +237,12 @@ public class Tethering extends BaseNetworkObserver { filter.addDataScheme("file"); mContext.registerReceiver(mStateReceiver, filter, null, smHandler); + UserManagerInternal userManager = LocalServices.getService(UserManagerInternal.class); + + // this check is useful only for some unit tests; example: ConnectivityServiceTest + if (userManager != null) { + userManager.addUserRestrictionsListener(new TetheringUserRestrictionListener(this)); + } // load device config info updateConfiguration(); } @@ -707,6 +717,11 @@ public class Tethering extends BaseNetworkObserver { } private void showTetheredNotification(int icon) { + showTetheredNotification(icon, true); + } + + @VisibleForTesting + protected void showTetheredNotification(int icon, boolean tetheringOn) { NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager == null) { @@ -730,9 +745,16 @@ public class Tethering extends BaseNetworkObserver { null, UserHandle.CURRENT); Resources r = Resources.getSystem(); - CharSequence title = r.getText(com.android.internal.R.string.tethered_notification_title); - CharSequence message = r.getText(com.android.internal.R.string. - tethered_notification_message); + final CharSequence title; + final CharSequence message; + + if (tetheringOn) { + title = r.getText(com.android.internal.R.string.tethered_notification_title); + message = r.getText(com.android.internal.R.string.tethered_notification_message); + } else { + title = r.getText(com.android.internal.R.string.disable_tether_notification_title); + message = r.getText(com.android.internal.R.string.disable_tether_notification_message); + } if (mTetheredNotificationBuilder == null) { mTetheredNotificationBuilder = new Notification.Builder(mContext); @@ -753,7 +775,8 @@ public class Tethering extends BaseNetworkObserver { mTetheredNotificationBuilder.buildInto(new Notification()), UserHandle.ALL); } - private void clearTetheredNotification() { + @VisibleForTesting + protected void clearTetheredNotification() { NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager != null && mLastNotificationId != 0) { @@ -857,6 +880,38 @@ public class Tethering extends BaseNetworkObserver { } } + @VisibleForTesting + protected static class TetheringUserRestrictionListener implements UserRestrictionsListener { + private final Tethering mWrapper; + + public TetheringUserRestrictionListener(Tethering wrapper) { + mWrapper = wrapper; + } + + public void onUserRestrictionsChanged(int userId, + Bundle newRestrictions, + Bundle prevRestrictions) { + final boolean newlyDisallowed = + newRestrictions.getBoolean(UserManager.DISALLOW_CONFIG_TETHERING); + final boolean previouslyDisallowed = + prevRestrictions.getBoolean(UserManager.DISALLOW_CONFIG_TETHERING); + final boolean tetheringDisallowedChanged = (newlyDisallowed != previouslyDisallowed); + + if (!tetheringDisallowedChanged) { + return; + } + + mWrapper.clearTetheredNotification(); + final boolean isTetheringActiveOnDevice = (mWrapper.getTetheredIfaces().length != 0); + + if (newlyDisallowed && isTetheringActiveOnDevice) { + mWrapper.showTetheredNotification( + com.android.internal.R.drawable.stat_sys_tether_general, false); + mWrapper.untetherAll(); + } + } + } + private void disableWifiIpServingLocked(String ifname, int apState) { mLog.log("Canceling WiFi tethering request - AP_STATE=" + apState); diff --git a/services/core/jni/com_android_server_ConsumerIrService.cpp b/services/core/jni/com_android_server_ConsumerIrService.cpp index 7104870349b5..4bad9dd43058 100644 --- a/services/core/jni/com_android_server_ConsumerIrService.cpp +++ b/services/core/jni/com_android_server_ConsumerIrService.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "ConsumerIrService" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" #include <stdlib.h> @@ -25,7 +25,7 @@ #include <utils/Log.h> #include <hardware/hardware.h> #include <hardware/consumerir.h> -#include <ScopedPrimitiveArray.h> +#include <nativehelper/ScopedPrimitiveArray.h> namespace android { diff --git a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp index 25e819c2c1dc..b09cba6a6a8f 100644 --- a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp +++ b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp @@ -18,7 +18,7 @@ #define LOG_NDEBUG 0 -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include "hardware/hardware.h" #include "hardware/gps_internal.h" diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp index 4bd7b63f8a27..2593f12567b8 100644 --- a/services/core/jni/com_android_server_power_PowerManagerService.cpp +++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp @@ -21,7 +21,7 @@ #include "JNIHelp.h" #include "jni.h" -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> #include <limits.h> diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 1a1d31e6ed6a..ed429881a4f8 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -241,6 +241,15 @@ public final class SystemServer { SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME); } + // + // Default the timezone property to GMT if not set. + // + String timezoneProperty = SystemProperties.get("persist.sys.timezone"); + if (timezoneProperty == null || timezoneProperty.isEmpty()) { + Slog.w(TAG, "Timezone not set; setting to GMT."); + SystemProperties.set("persist.sys.timezone", "GMT"); + } + // If the system has "persist.sys.language" and friends set, replace them with // "persist.sys.locale". Note that the default locale at this point is calculated // using the "-Duser.locale" command line flag. That flag is usually populated by diff --git a/tests/net/java/com/android/server/connectivity/TetheringTest.java b/tests/net/java/com/android/server/connectivity/TetheringTest.java index 6f048e2ccd2f..56cc1dce0599 100644 --- a/tests/net/java/com/android/server/connectivity/TetheringTest.java +++ b/tests/net/java/com/android/server/connectivity/TetheringTest.java @@ -40,6 +40,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; +import static org.mockito.Mockito.mock; import android.content.BroadcastReceiver; import android.content.ContentResolver; @@ -59,12 +60,14 @@ import android.net.NetworkRequest; import android.net.util.SharedLog; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiManager; +import android.os.Bundle; import android.os.Handler; import android.os.INetworkManagementService; import android.os.PersistableBundle; import android.os.RemoteException; import android.os.test.TestLooper; import android.os.UserHandle; +import android.os.UserManager; import android.provider.Settings; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; @@ -520,6 +523,89 @@ public class TetheringTest { verifyNoMoreInteractions(mNMService); } + private void userRestrictionsListenerBehaviour( + boolean currentDisallow, boolean nextDisallow, String[] activeTetheringIfacesList, + int expectedInteractionsWithShowNotification) throws Exception { + final int userId = 0; + final Bundle currRestrictions = new Bundle(); + final Bundle newRestrictions = new Bundle(); + Tethering tethering = mock(Tethering.class); + Tethering.TetheringUserRestrictionListener turl = + new Tethering.TetheringUserRestrictionListener(tethering); + + currRestrictions.putBoolean(UserManager.DISALLOW_CONFIG_TETHERING, currentDisallow); + newRestrictions.putBoolean(UserManager.DISALLOW_CONFIG_TETHERING, nextDisallow); + when(tethering.getTetheredIfaces()).thenReturn(activeTetheringIfacesList); + + turl.onUserRestrictionsChanged(userId, newRestrictions, currRestrictions); + + verify(tethering, times(expectedInteractionsWithShowNotification)) + .showTetheredNotification(anyInt(), eq(false)); + + verify(tethering, times(expectedInteractionsWithShowNotification)).untetherAll(); + } + + @Test + public void testDisallowTetheringWhenNoTetheringInterfaceIsActive() throws Exception { + final String[] emptyActiveIfacesList = new String[]{}; + final boolean currDisallow = false; + final boolean nextDisallow = true; + final int expectedInteractionsWithShowNotification = 0; + + userRestrictionsListenerBehaviour(currDisallow, nextDisallow, emptyActiveIfacesList, + expectedInteractionsWithShowNotification); + } + + @Test + public void testDisallowTetheringWhenAtLeastOneTetheringInterfaceIsActive() throws Exception { + final String[] nonEmptyActiveIfacesList = new String[]{mTestIfname}; + final boolean currDisallow = false; + final boolean nextDisallow = true; + final int expectedInteractionsWithShowNotification = 1; + + userRestrictionsListenerBehaviour(currDisallow, nextDisallow, nonEmptyActiveIfacesList, + expectedInteractionsWithShowNotification); + } + + @Test + public void testAllowTetheringWhenNoTetheringInterfaceIsActive() throws Exception { + final String[] nonEmptyActiveIfacesList = new String[]{}; + final boolean currDisallow = true; + final boolean nextDisallow = false; + final int expectedInteractionsWithShowNotification = 0; + + userRestrictionsListenerBehaviour(currDisallow, nextDisallow, nonEmptyActiveIfacesList, + expectedInteractionsWithShowNotification); + } + + @Test + public void testAllowTetheringWhenAtLeastOneTetheringInterfaceIsActive() throws Exception { + final String[] nonEmptyActiveIfacesList = new String[]{mTestIfname}; + final boolean currDisallow = true; + final boolean nextDisallow = false; + final int expectedInteractionsWithShowNotification = 0; + + userRestrictionsListenerBehaviour(currDisallow, nextDisallow, nonEmptyActiveIfacesList, + expectedInteractionsWithShowNotification); + } + + @Test + public void testDisallowTetheringUnchanged() throws Exception { + final String[] nonEmptyActiveIfacesList = new String[]{mTestIfname}; + final int expectedInteractionsWithShowNotification = 0; + boolean currDisallow = true; + boolean nextDisallow = true; + + userRestrictionsListenerBehaviour(currDisallow, nextDisallow, nonEmptyActiveIfacesList, + expectedInteractionsWithShowNotification); + + currDisallow = false; + nextDisallow = false; + + userRestrictionsListenerBehaviour(currDisallow, nextDisallow, nonEmptyActiveIfacesList, + expectedInteractionsWithShowNotification); + } + // TODO: Test that a request for hotspot mode doesn't interfere with an // already operating tethering mode interface. } |