diff options
221 files changed, 1798 insertions, 464 deletions
diff --git a/Android.mk b/Android.mk index 9d644d444db8..d05feb5eb88b 100644 --- a/Android.mk +++ b/Android.mk @@ -221,6 +221,7 @@ LOCAL_SRC_FILES += \ core/java/android/net/INetworkScoreService.aidl \ core/java/android/net/INetworkStatsService.aidl \ core/java/android/net/INetworkStatsSession.aidl \ + core/java/android/net/ITetheringStatsProvider.aidl \ core/java/android/net/nsd/INsdManager.aidl \ core/java/android/nfc/IAppCallback.aidl \ core/java/android/nfc/INfcAdapter.aidl \ @@ -437,7 +438,7 @@ LOCAL_SRC_FILES += \ telecomm/java/com/android/internal/telecom/RemoteServiceCallback.aidl \ telephony/java/android/telephony/mbms/IMbmsDownloadManagerCallback.aidl \ telephony/java/android/telephony/mbms/IMbmsStreamingManagerCallback.aidl \ - telephony/java/android/telephony/mbms/IDownloadCallback.aidl \ + telephony/java/android/telephony/mbms/IDownloadProgressListener.aidl \ telephony/java/android/telephony/mbms/IStreamingServiceCallback.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl \ telephony/java/android/telephony/mbms/vendor/IMbmsStreamingService.aidl \ diff --git a/api/current.txt b/api/current.txt index e48aad3cc49d..9c2aba7e2a95 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24009,6 +24009,7 @@ package android.net { field public static final int TRANSPORT_BLUETOOTH = 2; // 0x2 field public static final int TRANSPORT_CELLULAR = 0; // 0x0 field public static final int TRANSPORT_ETHERNET = 3; // 0x3 + field public static final int TRANSPORT_LOWPAN = 6; // 0x6 field public static final int TRANSPORT_VPN = 4; // 0x4 field public static final int TRANSPORT_WIFI = 1; // 0x1 field public static final int TRANSPORT_WIFI_AWARE = 5; // 0x5 @@ -36685,14 +36686,18 @@ package android.system { public final class StructStat { ctor public StructStat(long, long, int, long, int, int, long, long, long, long, long, long, long); + ctor public StructStat(long, long, int, long, int, int, long, long, android.system.StructTimespec, android.system.StructTimespec, android.system.StructTimespec, long, long); + field public final android.system.StructTimespec st_atim; field public final long st_atime; field public final long st_blksize; field public final long st_blocks; + field public final android.system.StructTimespec st_ctim; field public final long st_ctime; field public final long st_dev; field public final int st_gid; field public final long st_ino; field public final int st_mode; + field public final android.system.StructTimespec st_mtim; field public final long st_mtime; field public final long st_nlink; field public final long st_rdev; @@ -36715,6 +36720,13 @@ package android.system { field public final long f_namemax; } + public final class StructTimespec implements java.lang.Comparable { + ctor public StructTimespec(long, long); + method public int compareTo(android.system.StructTimespec); + field public final long tv_nsec; + field public final long tv_sec; + } + public final class StructUtsname { ctor public StructUtsname(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String); field public final java.lang.String machine; diff --git a/api/system-current.txt b/api/system-current.txt index ae772dd03f60..05b1a4214812 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -25847,6 +25847,7 @@ package android.net { field public static final int TRANSPORT_BLUETOOTH = 2; // 0x2 field public static final int TRANSPORT_CELLULAR = 0; // 0x0 field public static final int TRANSPORT_ETHERNET = 3; // 0x3 + field public static final int TRANSPORT_LOWPAN = 6; // 0x6 field public static final int TRANSPORT_VPN = 4; // 0x4 field public static final int TRANSPORT_WIFI = 1; // 0x1 field public static final int TRANSPORT_WIFI_AWARE = 5; // 0x5 @@ -39636,14 +39637,18 @@ package android.system { public final class StructStat { ctor public StructStat(long, long, int, long, int, int, long, long, long, long, long, long, long); + ctor public StructStat(long, long, int, long, int, int, long, long, android.system.StructTimespec, android.system.StructTimespec, android.system.StructTimespec, long, long); + field public final android.system.StructTimespec st_atim; field public final long st_atime; field public final long st_blksize; field public final long st_blocks; + field public final android.system.StructTimespec st_ctim; field public final long st_ctime; field public final long st_dev; field public final int st_gid; field public final long st_ino; field public final int st_mode; + field public final android.system.StructTimespec st_mtim; field public final long st_mtime; field public final long st_nlink; field public final long st_rdev; @@ -39666,6 +39671,13 @@ package android.system { field public final long f_namemax; } + public final class StructTimespec implements java.lang.Comparable { + ctor public StructTimespec(long, long); + method public int compareTo(android.system.StructTimespec); + field public final long tv_nsec; + field public final long tv_sec; + } + public final class StructUtsname { ctor public StructUtsname(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String); field public final java.lang.String machine; diff --git a/api/test-current.txt b/api/test-current.txt index 63322af883c7..1d9a2d841f18 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -24083,6 +24083,7 @@ package android.net { field public static final int TRANSPORT_BLUETOOTH = 2; // 0x2 field public static final int TRANSPORT_CELLULAR = 0; // 0x0 field public static final int TRANSPORT_ETHERNET = 3; // 0x3 + field public static final int TRANSPORT_LOWPAN = 6; // 0x6 field public static final int TRANSPORT_VPN = 4; // 0x4 field public static final int TRANSPORT_WIFI = 1; // 0x1 field public static final int TRANSPORT_WIFI_AWARE = 5; // 0x5 @@ -36768,14 +36769,18 @@ package android.system { public final class StructStat { ctor public StructStat(long, long, int, long, int, int, long, long, long, long, long, long, long); + ctor public StructStat(long, long, int, long, int, int, long, long, android.system.StructTimespec, android.system.StructTimespec, android.system.StructTimespec, long, long); + field public final android.system.StructTimespec st_atim; field public final long st_atime; field public final long st_blksize; field public final long st_blocks; + field public final android.system.StructTimespec st_ctim; field public final long st_ctime; field public final long st_dev; field public final int st_gid; field public final long st_ino; field public final int st_mode; + field public final android.system.StructTimespec st_mtim; field public final long st_mtime; field public final long st_nlink; field public final long st_rdev; @@ -36798,6 +36803,13 @@ package android.system { field public final long f_namemax; } + public final class StructTimespec implements java.lang.Comparable { + ctor public StructTimespec(long, long); + method public int compareTo(android.system.StructTimespec); + field public final long tv_nsec; + field public final long tv_sec; + } + public final class StructUtsname { ctor public StructUtsname(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String); field public final java.lang.String machine; diff --git a/core/java/android/app/timezone/Callback.java b/core/java/android/app/timezone/Callback.java index b51e5bad0f69..aea8038056ab 100644 --- a/core/java/android/app/timezone/Callback.java +++ b/core/java/android/app/timezone/Callback.java @@ -27,7 +27,6 @@ import java.lang.annotation.RetentionPolicy; * * @hide */ -// TODO(nfuller): Expose necessary APIs for OEMs with @SystemApi. http://b/31008728 public abstract class Callback { @Retention(RetentionPolicy.SOURCE) diff --git a/core/java/android/app/timezone/DistroFormatVersion.java b/core/java/android/app/timezone/DistroFormatVersion.java index e879e8f8adbc..be732e4c0188 100644 --- a/core/java/android/app/timezone/DistroFormatVersion.java +++ b/core/java/android/app/timezone/DistroFormatVersion.java @@ -35,7 +35,6 @@ import android.os.Parcelable; * * @hide */ -// TODO(nfuller): Expose necessary APIs for OEMs with @SystemApi. http://b/31008728 public final class DistroFormatVersion implements Parcelable { private final int mMajorVersion; diff --git a/core/java/android/app/timezone/DistroRulesVersion.java b/core/java/android/app/timezone/DistroRulesVersion.java index 1eb9f45f48f1..a680594657ae 100644 --- a/core/java/android/app/timezone/DistroRulesVersion.java +++ b/core/java/android/app/timezone/DistroRulesVersion.java @@ -36,7 +36,6 @@ import android.os.Parcelable; * * @hide */ -// TODO(nfuller): Expose necessary APIs for OEMs with @SystemApi. http://b/31008728 public final class DistroRulesVersion implements Parcelable { private final String mRulesVersion; diff --git a/core/java/android/app/timezone/RulesManager.java b/core/java/android/app/timezone/RulesManager.java index 649d894ca685..ad9b698a8fd7 100644 --- a/core/java/android/app/timezone/RulesManager.java +++ b/core/java/android/app/timezone/RulesManager.java @@ -64,7 +64,6 @@ import java.util.Arrays; * {@link Context#TIME_ZONE_RULES_MANAGER_SERVICE}. * @hide */ -// TODO(nfuller): Expose necessary APIs for OEMs with @SystemApi. http://b/31008728 public final class RulesManager { private static final String TAG = "timezone.RulesManager"; private static final boolean DEBUG = false; diff --git a/core/java/android/app/timezone/RulesState.java b/core/java/android/app/timezone/RulesState.java index 7d6ad2119fb7..ec247ebf502f 100644 --- a/core/java/android/app/timezone/RulesState.java +++ b/core/java/android/app/timezone/RulesState.java @@ -60,7 +60,6 @@ import java.lang.annotation.RetentionPolicy; * * @hide */ -// TODO(nfuller): Expose necessary APIs for OEMs with @SystemApi. http://b/31008728 public final class RulesState implements Parcelable { @Retention(RetentionPolicy.SOURCE) diff --git a/core/java/android/app/timezone/RulesUpdaterContract.java b/core/java/android/app/timezone/RulesUpdaterContract.java index 07b2f33ef5e0..9c62f46b6e36 100644 --- a/core/java/android/app/timezone/RulesUpdaterContract.java +++ b/core/java/android/app/timezone/RulesUpdaterContract.java @@ -27,7 +27,6 @@ import android.os.UserHandle; * * @hide */ -// TODO(nfuller): Expose necessary APIs for OEMs with @SystemApi. http://b/31008728 public final class RulesUpdaterContract { /** diff --git a/core/java/android/bluetooth/IBluetoothStateChangeCallback.aidl b/core/java/android/bluetooth/IBluetoothStateChangeCallback.aidl index feccdce57b98..0da4e8843282 100644 --- a/core/java/android/bluetooth/IBluetoothStateChangeCallback.aidl +++ b/core/java/android/bluetooth/IBluetoothStateChangeCallback.aidl @@ -21,7 +21,7 @@ package android.bluetooth; * * {@hide} */ -interface IBluetoothStateChangeCallback +oneway interface IBluetoothStateChangeCallback { void onBluetoothStateChange(boolean on); } diff --git a/core/java/android/net/ITetheringStatsProvider.aidl b/core/java/android/net/ITetheringStatsProvider.aidl new file mode 100644 index 000000000000..769086da42b4 --- /dev/null +++ b/core/java/android/net/ITetheringStatsProvider.aidl @@ -0,0 +1,33 @@ +/* + * 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; + +import android.net.NetworkStats; + +/** + * Interface that allows NetworkManagementService to query for tethering statistics. + * + * TODO: this does not really need to be an interface since Tethering runs in the same process + * as NetworkManagementService. Consider refactoring Tethering to use direct access to + * NetworkManagementService instead of using INetworkManagementService, and then deleting this + * interface. + * + * @hide + */ +interface ITetheringStatsProvider { + NetworkStats getTetherStats(); +} diff --git a/core/java/android/net/IpSecTransform.java b/core/java/android/net/IpSecTransform.java index e65f534f3dc6..8e3a61297078 100644 --- a/core/java/android/net/IpSecTransform.java +++ b/core/java/android/net/IpSecTransform.java @@ -26,6 +26,7 @@ import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.util.Log; +import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.Preconditions; import dalvik.system.CloseGuard; import java.io.IOException; @@ -487,5 +488,14 @@ public final class IpSecTransform implements AutoCloseable { mContext = context; mConfig = new IpSecConfig(); } + + /** + * Return an {@link IpSecConfig} object for testing purposes. + * @hide + */ + @VisibleForTesting + public IpSecConfig getIpSecConfig() { + return mConfig; + } } } diff --git a/core/java/android/net/NetworkCapabilities.java b/core/java/android/net/NetworkCapabilities.java index 76646b8939c4..305cf7695e5e 100644 --- a/core/java/android/net/NetworkCapabilities.java +++ b/core/java/android/net/NetworkCapabilities.java @@ -421,7 +421,6 @@ public final class NetworkCapabilities implements Parcelable { /** * Indicates this network uses a LoWPAN transport. - * @hide */ public static final int TRANSPORT_LOWPAN = 6; diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java index e05bd89079af..55b6dc817e5c 100644 --- a/core/java/android/os/Debug.java +++ b/core/java/android/os/Debug.java @@ -221,28 +221,69 @@ public final class Debug /** @hide */ public static final int OTHER_OTHER_MEMTRACK = 16; + // Needs to be declared here for the DVK_STAT ranges below. + /** @hide */ + public static final int NUM_OTHER_STATS = 17; + + // Dalvik subsections. /** @hide */ public static final int OTHER_DALVIK_NORMAL = 17; /** @hide */ public static final int OTHER_DALVIK_LARGE = 18; /** @hide */ - public static final int OTHER_DALVIK_LINEARALLOC = 19; + public static final int OTHER_DALVIK_ZYGOTE = 19; + /** @hide */ + public static final int OTHER_DALVIK_NON_MOVING = 20; + // Section begins and ends for dumpsys, relative to the DALVIK categories. + /** @hide */ + public static final int OTHER_DVK_STAT_DALVIK_START = + OTHER_DALVIK_NORMAL - NUM_OTHER_STATS; /** @hide */ - public static final int OTHER_DALVIK_ACCOUNTING = 20; + public static final int OTHER_DVK_STAT_DALVIK_END = + OTHER_DALVIK_NON_MOVING - NUM_OTHER_STATS; + + // Dalvik Other subsections. + /** @hide */ + public static final int OTHER_DALVIK_OTHER_LINEARALLOC = 21; + /** @hide */ + public static final int OTHER_DALVIK_OTHER_ACCOUNTING = 22; /** @hide */ - public static final int OTHER_DALVIK_CODE_CACHE = 21; + public static final int OTHER_DALVIK_OTHER_CODE_CACHE = 23; /** @hide */ - public static final int OTHER_DALVIK_ZYGOTE = 22; + public static final int OTHER_DALVIK_OTHER_COMPILER_METADATA = 24; /** @hide */ - public static final int OTHER_DALVIK_NON_MOVING = 23; + public static final int OTHER_DALVIK_OTHER_INDIRECT_REFERENCE_TABLE = 25; /** @hide */ - public static final int OTHER_DALVIK_INDIRECT_REFERENCE_TABLE = 24; + public static final int OTHER_DVK_STAT_DALVIK_OTHER_START = + OTHER_DALVIK_OTHER_LINEARALLOC - NUM_OTHER_STATS; + /** @hide */ + public static final int OTHER_DVK_STAT_DALVIK_OTHER_END = + OTHER_DALVIK_OTHER_INDIRECT_REFERENCE_TABLE - NUM_OTHER_STATS; + // Dex subsections (Boot vdex, App dex, and App vdex). /** @hide */ - public static final int NUM_OTHER_STATS = 17; + public static final int OTHER_DEX_BOOT_VDEX = 26; + /** @hide */ + public static final int OTHER_DEX_APP_DEX = 27; + /** @hide */ + public static final int OTHER_DEX_APP_VDEX = 28; + /** @hide */ + public static final int OTHER_DVK_STAT_DEX_START = OTHER_DEX_BOOT_VDEX - NUM_OTHER_STATS; + /** @hide */ + public static final int OTHER_DVK_STAT_DEX_END = OTHER_DEX_APP_VDEX - NUM_OTHER_STATS; + + // Art subsections (App image, boot image). + /** @hide */ + public static final int OTHER_ART_APP = 29; + /** @hide */ + public static final int OTHER_ART_BOOT = 30; + /** @hide */ + public static final int OTHER_DVK_STAT_ART_START = OTHER_ART_APP - NUM_OTHER_STATS; + /** @hide */ + public static final int OTHER_DVK_STAT_ART_END = OTHER_ART_BOOT - NUM_OTHER_STATS; /** @hide */ - public static final int NUM_DVK_STATS = 8; + public static final int NUM_DVK_STATS = 14; /** @hide */ public static final int NUM_CATEGORIES = 8; @@ -406,12 +447,18 @@ public final class Debug case OTHER_OTHER_MEMTRACK: return "Other mtrack"; case OTHER_DALVIK_NORMAL: return ".Heap"; case OTHER_DALVIK_LARGE: return ".LOS"; - case OTHER_DALVIK_LINEARALLOC: return ".LinearAlloc"; - case OTHER_DALVIK_ACCOUNTING: return ".GC"; - case OTHER_DALVIK_CODE_CACHE: return ".JITCache"; case OTHER_DALVIK_ZYGOTE: return ".Zygote"; case OTHER_DALVIK_NON_MOVING: return ".NonMoving"; - case OTHER_DALVIK_INDIRECT_REFERENCE_TABLE: return ".IndirectRef"; + case OTHER_DALVIK_OTHER_LINEARALLOC: return ".LinearAlloc"; + case OTHER_DALVIK_OTHER_ACCOUNTING: return ".GC"; + case OTHER_DALVIK_OTHER_CODE_CACHE: return ".JITCache"; + case OTHER_DALVIK_OTHER_COMPILER_METADATA: return ".CompilerMetadata"; + case OTHER_DALVIK_OTHER_INDIRECT_REFERENCE_TABLE: return ".IndirectRef"; + case OTHER_DEX_BOOT_VDEX: return ".Boot vdex"; + case OTHER_DEX_APP_DEX: return ".App dex"; + case OTHER_DEX_APP_VDEX: return ".App vdex"; + case OTHER_ART_APP: return ".App art"; + case OTHER_ART_BOOT: return ".Boot art"; default: return "????"; } } diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl index 92e78bc8d977..3de217494ac5 100644 --- a/core/java/android/os/INetworkManagementService.aidl +++ b/core/java/android/os/INetworkManagementService.aidl @@ -20,6 +20,7 @@ package android.os; import android.net.InterfaceConfiguration; import android.net.INetd; import android.net.INetworkManagementEventObserver; +import android.net.ITetheringStatsProvider; import android.net.Network; import android.net.NetworkStats; import android.net.RouteInfo; @@ -207,6 +208,18 @@ interface INetworkManagementService void disableNat(String internalInterface, String externalInterface); /** + * Registers a {@code ITetheringStatsProvider} to provide tethering statistics. + * All registered providers will be called in order, and their results will be added together. + * Netd is always registered as a tethering stats provider. + */ + void registerTetheringStatsProvider(ITetheringStatsProvider provider, String name); + + /** + * Unregisters a previously-registered {@code ITetheringStatsProvider}. + */ + void unregisterTetheringStatsProvider(ITetheringStatsProvider provider); + + /** ** PPPD **/ diff --git a/core/java/android/provider/TimeZoneRulesDataContract.java b/core/java/android/provider/TimeZoneRulesDataContract.java index a60756312310..789638523905 100644 --- a/core/java/android/provider/TimeZoneRulesDataContract.java +++ b/core/java/android/provider/TimeZoneRulesDataContract.java @@ -24,7 +24,6 @@ import android.net.Uri; * * @hide */ -// TODO(nfuller): Expose necessary APIs for OEMs with @SystemApi. http://b/31008728 public final class TimeZoneRulesDataContract { private TimeZoneRulesDataContract() {} diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java index 91429a609288..941ded3af8fe 100644 --- a/core/java/com/android/internal/os/ZygoteConnection.java +++ b/core/java/com/android/internal/os/ZygoteConnection.java @@ -18,6 +18,7 @@ package com.android.internal.os; import static android.system.OsConstants.F_SETFD; import static android.system.OsConstants.O_CLOEXEC; +import static android.system.OsConstants.POLLIN; import static android.system.OsConstants.STDERR_FILENO; import static android.system.OsConstants.STDIN_FILENO; import static android.system.OsConstants.STDOUT_FILENO; @@ -31,13 +32,14 @@ import android.os.SystemProperties; import android.os.Trace; import android.system.ErrnoException; import android.system.Os; +import android.system.StructPollfd; import android.util.Log; import dalvik.system.VMRuntime; import java.io.BufferedReader; +import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.FileDescriptor; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; @@ -807,17 +809,63 @@ class ZygoteConnection { boolean usingWrapper = false; if (pipeFd != null && pid > 0) { - DataInputStream is = new DataInputStream(new FileInputStream(pipeFd)); int innerPid = -1; try { - innerPid = is.readInt(); - } catch (IOException ex) { - Log.w(TAG, "Error reading pid from wrapped process, child may have died", ex); - } finally { - try { - is.close(); - } catch (IOException ex) { + // Do a busy loop here. We can't guarantee that a failure (and thus an exception + // bail) happens in a timely manner. + // + // We'll wait up to five seconds. This should give enough time for the fork to go + // through, but not to trigger the watchdog in the system server. + final int SLEEP_IN_MS = 5000; + final int BYTES_REQUIRED = 4; // Bytes in an int. + + StructPollfd fds[] = new StructPollfd[] { + new StructPollfd() + }; + + byte data[] = new byte[BYTES_REQUIRED]; + + int remainingSleepTime = SLEEP_IN_MS; + int dataIndex = 0; + long startTime = System.nanoTime(); + + while (dataIndex < data.length && remainingSleepTime > 0) { + fds[0].fd = pipeFd; + fds[0].events = (short) POLLIN; + fds[0].revents = 0; + fds[0].userData = null; + + int res = android.system.Os.poll(fds, remainingSleepTime); + long endTime = System.nanoTime(); + remainingSleepTime = SLEEP_IN_MS - (int)((endTime - startTime) / 1000000l); + + if (res > 0) { + if ((fds[0].revents & POLLIN) != 0) { + // Only read one byte, so as not to block. + int readBytes = android.system.Os.read(pipeFd, data, dataIndex, 1); + if (readBytes < 0) { + throw new RuntimeException("Some error"); + } + dataIndex += readBytes; + } else { + // Error case. revents should contain one of the error bits. + break; + } + } else if (res == 0) { + Log.w(TAG, "Timed out waiting for child."); + } + } + + if (dataIndex == data.length) { + DataInputStream is = new DataInputStream(new ByteArrayInputStream(data)); + innerPid = is.readInt(); } + + if (innerPid == -1) { + Log.w(TAG, "Error reading pid from wrapped process, child may have died"); + } + } catch (Exception ex) { + Log.w(TAG, "Error reading pid from wrapped process, child may have died", ex); } // Ensure that the pid reported by the wrapped process is either the diff --git a/core/java/com/android/server/BootReceiver.java b/core/java/com/android/server/BootReceiver.java index 5a50fbfd5277..9151cee84986 100644 --- a/core/java/com/android/server/BootReceiver.java +++ b/core/java/com/android/server/BootReceiver.java @@ -195,6 +195,8 @@ public class BootReceiver extends BroadcastReceiver { "/proc/last_kmsg", -LOG_SIZE, "SYSTEM_LAST_KMSG"); addFileWithFootersToDropBox(db, timestamps, headers, lastKmsgFooter, "/sys/fs/pstore/console-ramoops", -LOG_SIZE, "SYSTEM_LAST_KMSG"); + addFileWithFootersToDropBox(db, timestamps, headers, lastKmsgFooter, + "/sys/fs/pstore/console-ramoops-0", -LOG_SIZE, "SYSTEM_LAST_KMSG"); addFileToDropBox(db, timestamps, headers, "/cache/recovery/log", -LOG_SIZE, "SYSTEM_RECOVERY_LOG"); addFileToDropBox(db, timestamps, headers, "/cache/recovery/last_kmsg", @@ -276,6 +278,10 @@ public class BootReceiver extends BroadcastReceiver { if (fileTime <= 0) { file = new File("/sys/fs/pstore/console-ramoops"); fileTime = file.lastModified(); + if (fileTime <= 0) { + file = new File("/sys/fs/pstore/console-ramoops-0"); + fileTime = file.lastModified(); + } } if (fileTime <= 0) return; // File does not exist diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index facc0f998bda..9ef6052c8e62 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -33,8 +33,8 @@ #include <SkImageDecoder.h> #include "jni.h" -#include "JNIHelp.h" -#include "JniInvocation.h" +#include <nativehelper/JNIHelp.h> +#include <nativehelper/JniInvocation.h> #include "android_util_Binder.h" #include <stdio.h> @@ -1094,7 +1094,7 @@ void AndroidRuntime::start(const char* className, const Vector<String8>& options * Start VM. This thread becomes the main thread of the VM, and will * not return until the VM exits. */ - char* slashClassName = toSlashClassName(className); + char* slashClassName = toSlashClassName(className != NULL ? className : ""); jclass startClass = env->FindClass(slashClassName); if (startClass == NULL) { ALOGE("JavaVM unable to locate class '%s'\n", slashClassName); diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp index 4001283c4c66..3866c84baf2f 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -15,7 +15,7 @@ #include "Utils.h" #include "core_jni_helpers.h" -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <androidfw/Asset.h> #include <androidfw/ResourceTypes.h> #include <cutils/compiler.h> diff --git a/core/jni/android/graphics/BitmapRegionDecoder.cpp b/core/jni/android/graphics/BitmapRegionDecoder.cpp index a1ba42e7ab72..7d12f44ef4de 100644 --- a/core/jni/android/graphics/BitmapRegionDecoder.cpp +++ b/core/jni/android/graphics/BitmapRegionDecoder.cpp @@ -33,7 +33,7 @@ #include "android_util_Binder.h" #include "core_jni_helpers.h" -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <androidfw/Asset.h> #include <binder/Parcel.h> #include <jni.h> diff --git a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp index 067489a547c0..0e907c349161 100644 --- a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp +++ b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp @@ -5,7 +5,7 @@ #include "SkTypes.h" #include "Utils.h" -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <memory> static jmethodID gInputStream_readMethodID; diff --git a/core/jni/android/graphics/FontFamily.cpp b/core/jni/android/graphics/FontFamily.cpp index 1c2d13d98acc..95bcbd688b7d 100644 --- a/core/jni/android/graphics/FontFamily.cpp +++ b/core/jni/android/graphics/FontFamily.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "Minikin" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <core_jni_helpers.h> #include "SkData.h" @@ -24,8 +24,8 @@ #include "SkRefCnt.h" #include "SkTypeface.h" #include "GraphicsJNI.h" -#include <ScopedPrimitiveArray.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedPrimitiveArray.h> +#include <nativehelper/ScopedUtfChars.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/android_util_AssetManager.h> #include <androidfw/AssetManager.h> diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp index 889a3db81e6f..19ca1eac1ef0 100644 --- a/core/jni/android/graphics/Graphics.cpp +++ b/core/jni/android/graphics/Graphics.cpp @@ -4,7 +4,7 @@ #include <sys/mman.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "GraphicsJNI.h" #include "SkCanvas.h" diff --git a/core/jni/android/graphics/Movie.cpp b/core/jni/android/graphics/Movie.cpp index 71988f9cf44d..c96552f5e002 100644 --- a/core/jni/android/graphics/Movie.cpp +++ b/core/jni/android/graphics/Movie.cpp @@ -1,6 +1,6 @@ #include "CreateJavaOutputStreamAdaptor.h" #include "GraphicsJNI.h" -#include "ScopedLocalRef.h" +#include <nativehelper/ScopedLocalRef.h> #include "SkFrontBufferedStream.h" #include "SkMovie.h" #include "SkStream.h" diff --git a/core/jni/android/graphics/NinePatch.cpp b/core/jni/android/graphics/NinePatch.cpp index 4f2f3897469c..fa9c9c759853 100644 --- a/core/jni/android/graphics/NinePatch.cpp +++ b/core/jni/android/graphics/NinePatch.cpp @@ -31,7 +31,7 @@ #include "utils/NinePatch.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" using namespace android; diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp index 85092ad4fdd4..fdd4b3cb24fa 100644 --- a/core/jni/android/graphics/Paint.cpp +++ b/core/jni/android/graphics/Paint.cpp @@ -22,8 +22,8 @@ #include "jni.h" #include "GraphicsJNI.h" #include "core_jni_helpers.h" -#include <ScopedStringChars.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedStringChars.h> +#include <nativehelper/ScopedUtfChars.h> #include "SkBlurDrawLooper.h" #include "SkColorFilter.h" diff --git a/core/jni/android/graphics/Typeface.cpp b/core/jni/android/graphics/Typeface.cpp index 9a53cadf355b..1799e015fa21 100644 --- a/core/jni/android/graphics/Typeface.cpp +++ b/core/jni/android/graphics/Typeface.cpp @@ -18,7 +18,7 @@ #include "core_jni_helpers.h" #include "GraphicsJNI.h" -#include "ScopedPrimitiveArray.h" +#include <nativehelper/ScopedPrimitiveArray.h> #include "SkTypeface.h" #include <android_runtime/android_util_AssetManager.h> #include <androidfw/AssetManager.h> diff --git a/core/jni/android/graphics/pdf/PdfEditor.cpp b/core/jni/android/graphics/pdf/PdfEditor.cpp index 59c5be66737d..8c9f8fa18aa6 100644 --- a/core/jni/android/graphics/pdf/PdfEditor.cpp +++ b/core/jni/android/graphics/pdf/PdfEditor.cpp @@ -24,7 +24,7 @@ #include <utils/Log.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor" diff --git a/core/jni/android/graphics/pdf/PdfRenderer.cpp b/core/jni/android/graphics/pdf/PdfRenderer.cpp index 43550ac9ed72..e8b2aa94b781 100644 --- a/core/jni/android/graphics/pdf/PdfRenderer.cpp +++ b/core/jni/android/graphics/pdf/PdfRenderer.cpp @@ -15,7 +15,7 @@ */ #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "GraphicsJNI.h" #include "SkBitmap.h" #include "SkMatrix.h" diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp index 41d911150d93..825c19f557f1 100644 --- a/core/jni/android/opengl/util.cpp +++ b/core/jni/android/opengl/util.cpp @@ -15,7 +15,7 @@ */ #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "GraphicsJNI.h" #include <math.h> diff --git a/core/jni/android_app_NativeActivity.cpp b/core/jni/android_app_NativeActivity.cpp index fd9e714618e5..6d0619f17b8c 100644 --- a/core/jni/android_app_NativeActivity.cpp +++ b/core/jni/android_app_NativeActivity.cpp @@ -35,7 +35,7 @@ #include <utils/Looper.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_os_MessageQueue.h" #include "android_view_InputChannel.h" #include "android_view_KeyEvent.h" @@ -45,7 +45,7 @@ #include "core_jni_helpers.h" -#include "ScopedUtfChars.h" +#include <nativehelper/ScopedUtfChars.h> #define LOG_TRACE(...) //#define LOG_TRACE(...) ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__) diff --git a/core/jni/android_app_admin_SecurityLog.cpp b/core/jni/android_app_admin_SecurityLog.cpp index e8ca79384f68..5c45b4b26a1b 100644 --- a/core/jni/android_app_admin_SecurityLog.cpp +++ b/core/jni/android_app_admin_SecurityLog.cpp @@ -16,7 +16,7 @@ #include <fcntl.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include "jni.h" #include <private/android_logger.h> diff --git a/core/jni/android_app_backup_FullBackup.cpp b/core/jni/android_app_backup_FullBackup.cpp index 63b2e2aaee12..3e399898ed55 100644 --- a/core/jni/android_app_backup_FullBackup.cpp +++ b/core/jni/android_app_backup_FullBackup.cpp @@ -20,7 +20,7 @@ #include <utils/Log.h> #include <utils/String8.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <androidfw/BackupHelpers.h> diff --git a/core/jni/android_backup_BackupDataInput.cpp b/core/jni/android_backup_BackupDataInput.cpp index 096a784b711b..aa8acc16bc3f 100644 --- a/core/jni/android_backup_BackupDataInput.cpp +++ b/core/jni/android_backup_BackupDataInput.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "FileBackupHelper_native" #include <utils/Log.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <androidfw/BackupHelpers.h> diff --git a/core/jni/android_backup_BackupDataOutput.cpp b/core/jni/android_backup_BackupDataOutput.cpp index a7894f487c55..4f5d1f80dffc 100644 --- a/core/jni/android_backup_BackupDataOutput.cpp +++ b/core/jni/android_backup_BackupDataOutput.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "FileBackupHelper_native" #include <utils/Log.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <androidfw/BackupHelpers.h> diff --git a/core/jni/android_backup_BackupHelperDispatcher.cpp b/core/jni/android_backup_BackupHelperDispatcher.cpp index 80bdaf84dca9..fac7eba4c0a2 100644 --- a/core/jni/android_backup_BackupHelperDispatcher.cpp +++ b/core/jni/android_backup_BackupHelperDispatcher.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "BackupHelperDispatcher_native" #include <utils/Log.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <sys/types.h> diff --git a/core/jni/android_backup_FileBackupHelperBase.cpp b/core/jni/android_backup_FileBackupHelperBase.cpp index 6d6ac1b47744..65840ee2c016 100644 --- a/core/jni/android_backup_FileBackupHelperBase.cpp +++ b/core/jni/android_backup_FileBackupHelperBase.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "FileBackupHelper_native" #include <utils/Log.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <androidfw/BackupHelpers.h> diff --git a/core/jni/android_content_res_ObbScanner.cpp b/core/jni/android_content_res_ObbScanner.cpp index 36d78cf3aca0..de429a07d0f6 100644 --- a/core/jni/android_content_res_ObbScanner.cpp +++ b/core/jni/android_content_res_ObbScanner.cpp @@ -21,7 +21,7 @@ #include <androidfw/ObbFile.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "utils/misc.h" #include "android_runtime/AndroidRuntime.h" diff --git a/core/jni/android_database_CursorWindow.cpp b/core/jni/android_database_CursorWindow.cpp index 3fc3aaf6c8f3..7c1d3136fc4f 100644 --- a/core/jni/android_database_CursorWindow.cpp +++ b/core/jni/android_database_CursorWindow.cpp @@ -20,7 +20,7 @@ #include <inttypes.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/Log.h> diff --git a/core/jni/android_database_SQLiteCommon.h b/core/jni/android_database_SQLiteCommon.h index 0cac176502e2..81164ef1f99d 100644 --- a/core/jni/android_database_SQLiteCommon.h +++ b/core/jni/android_database_SQLiteCommon.h @@ -18,7 +18,7 @@ #define _ANDROID_DATABASE_SQLITE_COMMON_H #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <sqlite3.h> diff --git a/core/jni/android_database_SQLiteConnection.cpp b/core/jni/android_database_SQLiteConnection.cpp index bcc3bb09b69d..cbf09bd08673 100644 --- a/core/jni/android_database_SQLiteConnection.cpp +++ b/core/jni/android_database_SQLiteConnection.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "SQLiteConnection" #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/Log.h> diff --git a/core/jni/android_database_SQLiteDebug.cpp b/core/jni/android_database_SQLiteDebug.cpp index 4e4c36cbb7e1..3ba9b91028bb 100644 --- a/core/jni/android_database_SQLiteDebug.cpp +++ b/core/jni/android_database_SQLiteDebug.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "SQLiteDebug" #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <stdio.h> diff --git a/core/jni/android_database_SQLiteGlobal.cpp b/core/jni/android_database_SQLiteGlobal.cpp index 03e2387f24bc..ec5dc4ae30c5 100644 --- a/core/jni/android_database_SQLiteGlobal.cpp +++ b/core/jni/android_database_SQLiteGlobal.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "SQLiteGlobal" #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <sqlite3.h> diff --git a/core/jni/android_ddm_DdmHandleNativeHeap.cpp b/core/jni/android_ddm_DdmHandleNativeHeap.cpp index 3e7a04efc536..2f25d8f2d3a4 100644 --- a/core/jni/android_ddm_DdmHandleNativeHeap.cpp +++ b/core/jni/android_ddm_DdmHandleNativeHeap.cpp @@ -18,7 +18,7 @@ #undef LOG_TAG #define LOG_TAG "DdmHandleNativeHeap" -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <jni.h> #include "core_jni_helpers.h" diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp index b92627010059..fb9494fcc266 100644 --- a/core/jni/android_hardware_Camera.cpp +++ b/core/jni/android_hardware_Camera.cpp @@ -20,7 +20,7 @@ #include <utils/Log.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <android_runtime/android_graphics_SurfaceTexture.h> #include <android_runtime/android_view_Surface.h> diff --git a/core/jni/android_hardware_SensorManager.cpp b/core/jni/android_hardware_SensorManager.cpp index 271f24b13052..7adcc9b98cb3 100644 --- a/core/jni/android_hardware_SensorManager.cpp +++ b/core/jni/android_hardware_SensorManager.cpp @@ -15,13 +15,13 @@ */ #define LOG_TAG "SensorManager" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_os_MessageQueue.h" #include "core_jni_helpers.h" #include "jni.h" -#include <ScopedUtfChars.h> -#include <ScopedLocalRef.h> +#include <nativehelper/ScopedUtfChars.h> +#include <nativehelper/ScopedLocalRef.h> #include <android_runtime/AndroidRuntime.h> #include <gui/Sensor.h> #include <gui/SensorEventQueue.h> diff --git a/core/jni/android_hardware_SerialPort.cpp b/core/jni/android_hardware_SerialPort.cpp index 393dc7b9f4fd..190ddced7312 100644 --- a/core/jni/android_hardware_SerialPort.cpp +++ b/core/jni/android_hardware_SerialPort.cpp @@ -19,7 +19,7 @@ #include "utils/Log.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <stdio.h> diff --git a/core/jni/android_hardware_SoundTrigger.cpp b/core/jni/android_hardware_SoundTrigger.cpp index 0c7f5a116561..9dbb8d757e15 100644 --- a/core/jni/android_hardware_SoundTrigger.cpp +++ b/core/jni/android_hardware_SoundTrigger.cpp @@ -20,7 +20,7 @@ #include <utils/Log.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <system/sound_trigger.h> #include <soundtrigger/SoundTriggerCallback.h> diff --git a/core/jni/android_hardware_UsbDevice.cpp b/core/jni/android_hardware_UsbDevice.cpp index 89d33e2ace1c..879d40924690 100644 --- a/core/jni/android_hardware_UsbDevice.cpp +++ b/core/jni/android_hardware_UsbDevice.cpp @@ -19,7 +19,7 @@ #include "utils/Log.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <usbhost/usbhost.h> diff --git a/core/jni/android_hardware_UsbDeviceConnection.cpp b/core/jni/android_hardware_UsbDeviceConnection.cpp index 1ba9fc58800c..c15cb83be326 100644 --- a/core/jni/android_hardware_UsbDeviceConnection.cpp +++ b/core/jni/android_hardware_UsbDeviceConnection.cpp @@ -19,7 +19,7 @@ #include "utils/Log.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <usbhost/usbhost.h> diff --git a/core/jni/android_hardware_UsbRequest.cpp b/core/jni/android_hardware_UsbRequest.cpp index 399e7b16f073..06cfd4c1ae92 100644 --- a/core/jni/android_hardware_UsbRequest.cpp +++ b/core/jni/android_hardware_UsbRequest.cpp @@ -19,7 +19,7 @@ #include "utils/Log.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <usbhost/usbhost.h> diff --git a/core/jni/android_hardware_camera2_CameraMetadata.cpp b/core/jni/android_hardware_camera2_CameraMetadata.cpp index 518f99e86434..45e7c07758a8 100644 --- a/core/jni/android_hardware_camera2_CameraMetadata.cpp +++ b/core/jni/android_hardware_camera2_CameraMetadata.cpp @@ -28,7 +28,7 @@ #include <vector> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_os_Parcel.h" #include "core_jni_helpers.h" #include "android_runtime/android_hardware_camera2_CameraMetadata.h" diff --git a/core/jni/android_hardware_camera2_DngCreator.cpp b/core/jni/android_hardware_camera2_DngCreator.cpp index d2932e43fe5b..09aaff6a3de4 100644 --- a/core/jni/android_hardware_camera2_DngCreator.cpp +++ b/core/jni/android_hardware_camera2_DngCreator.cpp @@ -45,7 +45,7 @@ #include "android_runtime/android_hardware_camera2_CameraMetadata.h" #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> using namespace android; using namespace img_utils; diff --git a/core/jni/android_hardware_camera2_legacy_LegacyCameraDevice.cpp b/core/jni/android_hardware_camera2_legacy_LegacyCameraDevice.cpp index 80f9d5750d8a..33ce3aa38091 100644 --- a/core/jni/android_hardware_camera2_legacy_LegacyCameraDevice.cpp +++ b/core/jni/android_hardware_camera2_legacy_LegacyCameraDevice.cpp @@ -22,7 +22,7 @@ #include <camera/CameraUtils.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include "android_runtime/android_view_Surface.h" #include "android_runtime/android_graphics_SurfaceTexture.h" diff --git a/core/jni/android_hardware_camera2_legacy_PerfMeasurement.cpp b/core/jni/android_hardware_camera2_legacy_PerfMeasurement.cpp index a08166568c9f..fac243a70415 100644 --- a/core/jni/android_hardware_camera2_legacy_PerfMeasurement.cpp +++ b/core/jni/android_hardware_camera2_legacy_PerfMeasurement.cpp @@ -21,7 +21,7 @@ #include <utils/Vector.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <ui/GraphicBuffer.h> diff --git a/core/jni/android_hardware_location_ActivityRecognitionHardware.cpp b/core/jni/android_hardware_location_ActivityRecognitionHardware.cpp index 44a3555bcce0..0e2b80e031c9 100644 --- a/core/jni/android_hardware_location_ActivityRecognitionHardware.cpp +++ b/core/jni/android_hardware_location_ActivityRecognitionHardware.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "ActivityRecognitionHardware" #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/Log.h> diff --git a/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp index 5e93fc97de3f..e4da3c6a6ac8 100644 --- a/core/jni/android_media_AudioRecord.cpp +++ b/core/jni/android_media_AudioRecord.cpp @@ -20,13 +20,13 @@ #include <inttypes.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <utils/Log.h> #include <media/AudioRecord.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> #include "android_media_AudioFormat.h" #include "android_media_AudioErrors.h" diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp index d30e6eba48e7..6c3d5f1fcd11 100644 --- a/core/jni/android_media_AudioSystem.cpp +++ b/core/jni/android_media_AudioSystem.cpp @@ -22,7 +22,7 @@ #include <sstream> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <media/AudioSystem.h> diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp index 86c4df758811..e1470c3fed43 100644 --- a/core/jni/android_media_AudioTrack.cpp +++ b/core/jni/android_media_AudioTrack.cpp @@ -19,11 +19,11 @@ #include "android_media_AudioTrack.h" -#include <JNIHelp.h> -#include <JniConstants.h> +#include <nativehelper/JNIHelp.h> +#include <nativehelper/JniConstants.h> #include "core_jni_helpers.h" -#include "ScopedBytes.h" +#include <nativehelper/ScopedBytes.h> #include <utils/Log.h> #include <media/AudioSystem.h> diff --git a/core/jni/android_media_DeviceCallback.cpp b/core/jni/android_media_DeviceCallback.cpp index e159373602c3..108fa00fe510 100644 --- a/core/jni/android_media_DeviceCallback.cpp +++ b/core/jni/android_media_DeviceCallback.cpp @@ -19,8 +19,8 @@ #define LOG_TAG "AudioDeviceCallback-JNI" #include <utils/Log.h> -#include <JNIHelp.h> -#include <JniConstants.h> +#include <nativehelper/JNIHelp.h> +#include <nativehelper/JniConstants.h> #include "core_jni_helpers.h" #include <media/AudioSystem.h> diff --git a/core/jni/android_media_JetPlayer.cpp b/core/jni/android_media_JetPlayer.cpp index 873c3f2e07e1..da116bf7c96a 100644 --- a/core/jni/android_media_JetPlayer.cpp +++ b/core/jni/android_media_JetPlayer.cpp @@ -23,7 +23,7 @@ #include <fcntl.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <utils/Log.h> diff --git a/core/jni/android_media_RemoteDisplay.cpp b/core/jni/android_media_RemoteDisplay.cpp index bd1a6ecaf95c..3b517f1eafe0 100644 --- a/core/jni/android_media_RemoteDisplay.cpp +++ b/core/jni/android_media_RemoteDisplay.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "RemoteDisplay" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_os_Parcel.h" #include "android_util_Binder.h" @@ -36,7 +36,7 @@ #include <utils/Log.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> namespace android { diff --git a/core/jni/android_media_ToneGenerator.cpp b/core/jni/android_media_ToneGenerator.cpp index aec62631c559..ecb3cd60c42f 100644 --- a/core/jni/android_media_ToneGenerator.cpp +++ b/core/jni/android_media_ToneGenerator.cpp @@ -22,7 +22,7 @@ #include <fcntl.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <utils/Log.h> diff --git a/core/jni/android_net_LocalSocketImpl.cpp b/core/jni/android_net_LocalSocketImpl.cpp index 37b6df1e3d2c..6df23f72bdd3 100644 --- a/core/jni/android_net_LocalSocketImpl.cpp +++ b/core/jni/android_net_LocalSocketImpl.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "LocalSocketImpl" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include "utils/Log.h" #include "utils/misc.h" @@ -35,7 +35,7 @@ #include <cutils/sockets.h> #include <netinet/tcp.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> namespace android { diff --git a/core/jni/android_net_NetUtils.cpp b/core/jni/android_net_NetUtils.cpp index 3e99521f8ad4..823f1cc36225 100644 --- a/core/jni/android_net_NetUtils.cpp +++ b/core/jni/android_net_NetUtils.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "NetUtils" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "NetdClient.h" #include <utils/misc.h> #include <android_runtime/AndroidRuntime.h> diff --git a/core/jni/android_net_TrafficStats.cpp b/core/jni/android_net_TrafficStats.cpp index 7b7d0cf498c3..d0c237da0777 100644 --- a/core/jni/android_net_TrafficStats.cpp +++ b/core/jni/android_net_TrafficStats.cpp @@ -25,7 +25,7 @@ #include "core_jni_helpers.h" #include <jni.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> #include <utils/misc.h> #include <utils/Log.h> diff --git a/core/jni/android_opengl_EGL14.cpp b/core/jni/android_opengl_EGL14.cpp index c8b178411251..616358866275 100644 --- a/core/jni/android_opengl_EGL14.cpp +++ b/core/jni/android_opengl_EGL14.cpp @@ -21,7 +21,7 @@ #pragma GCC diagnostic ignored "-Wunused-function" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/android_view_Surface.h> #include <android_runtime/android_graphics_SurfaceTexture.h> diff --git a/core/jni/android_opengl_EGLExt.cpp b/core/jni/android_opengl_EGLExt.cpp index 62ccad4d85f0..df1aa2025b98 100644 --- a/core/jni/android_opengl_EGLExt.cpp +++ b/core/jni/android_opengl_EGLExt.cpp @@ -21,7 +21,7 @@ #pragma GCC diagnostic ignored "-Wunused-function" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/android_view_Surface.h> #include <android_runtime/android_graphics_SurfaceTexture.h> diff --git a/core/jni/android_opengl_GLES10.cpp b/core/jni/android_opengl_GLES10.cpp index f4135c213e36..b93ae80b2920 100644 --- a/core/jni/android_opengl_GLES10.cpp +++ b/core/jni/android_opengl_GLES10.cpp @@ -25,7 +25,7 @@ #include <GLES/glext.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> #include <assert.h> diff --git a/core/jni/android_opengl_GLES10Ext.cpp b/core/jni/android_opengl_GLES10Ext.cpp index 4dc42339b6e5..26a01f2e7a1f 100644 --- a/core/jni/android_opengl_GLES10Ext.cpp +++ b/core/jni/android_opengl_GLES10Ext.cpp @@ -25,7 +25,7 @@ #include <GLES/glext.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> #include <assert.h> diff --git a/core/jni/android_opengl_GLES11.cpp b/core/jni/android_opengl_GLES11.cpp index 2625e03c962e..0762d6e2c08f 100644 --- a/core/jni/android_opengl_GLES11.cpp +++ b/core/jni/android_opengl_GLES11.cpp @@ -25,7 +25,7 @@ #include <GLES/glext.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> #include <assert.h> diff --git a/core/jni/android_opengl_GLES11Ext.cpp b/core/jni/android_opengl_GLES11Ext.cpp index fb85cb0f8d95..3006558371c0 100644 --- a/core/jni/android_opengl_GLES11Ext.cpp +++ b/core/jni/android_opengl_GLES11Ext.cpp @@ -25,7 +25,7 @@ #include <GLES/glext.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> #include <assert.h> diff --git a/core/jni/android_opengl_GLES20.cpp b/core/jni/android_opengl_GLES20.cpp index ac3bf7a5b735..c5787f400eac 100644 --- a/core/jni/android_opengl_GLES20.cpp +++ b/core/jni/android_opengl_GLES20.cpp @@ -25,7 +25,7 @@ #include <GLES2/gl2ext.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> #include <assert.h> diff --git a/core/jni/android_opengl_GLES30.cpp b/core/jni/android_opengl_GLES30.cpp index 59b8911487b9..d1e616153db5 100644 --- a/core/jni/android_opengl_GLES30.cpp +++ b/core/jni/android_opengl_GLES30.cpp @@ -25,7 +25,7 @@ #include <GLES3/gl3ext.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> #include <assert.h> diff --git a/core/jni/android_opengl_GLES31.cpp b/core/jni/android_opengl_GLES31.cpp index 156e7bdda5f2..ab6475714cc4 100644 --- a/core/jni/android_opengl_GLES31.cpp +++ b/core/jni/android_opengl_GLES31.cpp @@ -23,7 +23,7 @@ #include <stdint.h> #include <GLES3/gl31.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> #include <assert.h> diff --git a/core/jni/android_opengl_GLES31Ext.cpp b/core/jni/android_opengl_GLES31Ext.cpp index 5be7be04f581..da45fef6789e 100644 --- a/core/jni/android_opengl_GLES31Ext.cpp +++ b/core/jni/android_opengl_GLES31Ext.cpp @@ -24,7 +24,7 @@ #include <GLES2/gl2ext.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> #include <assert.h> diff --git a/core/jni/android_opengl_GLES32.cpp b/core/jni/android_opengl_GLES32.cpp index f9a1a8ea0d74..824a2e8c4fae 100644 --- a/core/jni/android_opengl_GLES32.cpp +++ b/core/jni/android_opengl_GLES32.cpp @@ -23,7 +23,7 @@ #include <stdint.h> #include <GLES3/gl32.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> #include <assert.h> diff --git a/core/jni/android_os_Debug.cpp b/core/jni/android_os_Debug.cpp index 821d0e515d09..120962390ef3 100644 --- a/core/jni/android_os_Debug.cpp +++ b/core/jni/android_os_Debug.cpp @@ -75,14 +75,27 @@ enum { HEAP_GL, HEAP_OTHER_MEMTRACK, + // Dalvik extra sections (heap). HEAP_DALVIK_NORMAL, HEAP_DALVIK_LARGE, - HEAP_DALVIK_LINEARALLOC, - HEAP_DALVIK_ACCOUNTING, - HEAP_DALVIK_CODE_CACHE, HEAP_DALVIK_ZYGOTE, HEAP_DALVIK_NON_MOVING, - HEAP_DALVIK_INDIRECT_REFERENCE_TABLE, + + // Dalvik other extra sections. + HEAP_DALVIK_OTHER_LINEARALLOC, + HEAP_DALVIK_OTHER_ACCOUNTING, + HEAP_DALVIK_OTHER_CODE_CACHE, + HEAP_DALVIK_OTHER_COMPILER_METADATA, + HEAP_DALVIK_OTHER_INDIRECT_REFERENCE_TABLE, + + // Boot vdex / app dex / app vdex + HEAP_DEX_BOOT_VDEX, + HEAP_DEX_APP_DEX, + HEAP_DEX_APP_VDEX, + + // App art, boot art. + HEAP_ART_APP, + HEAP_ART_BOOT, _NUM_HEAP, _NUM_EXCLUSIVE_HEAP = HEAP_OTHER_MEMTRACK+1, @@ -297,15 +310,30 @@ static void read_mapinfo(FILE *fp, stats_t* stats, bool* foundSwapPss) whichHeap = HEAP_TTF; is_swappable = true; } else if ((nameLen > 4 && strstr(name, ".dex") != NULL) || - (nameLen > 5 && strcmp(name+nameLen-5, ".odex") == 0) || - (nameLen > 5 && strcmp(name+nameLen-5, ".vdex") == 0)) { + (nameLen > 5 && strcmp(name+nameLen-5, ".odex") == 0)) { whichHeap = HEAP_DEX; + subHeap = HEAP_DEX_APP_DEX; + is_swappable = true; + } else if (nameLen > 5 && strcmp(name+nameLen-5, ".vdex") == 0) { + whichHeap = HEAP_DEX; + // Handle system@framework@boot* and system/framework/boot* + if (strstr(name, "@boot") != NULL || strstr(name, "/boot") != NULL) { + subHeap = HEAP_DEX_BOOT_VDEX; + } else { + subHeap = HEAP_DEX_APP_VDEX; + } is_swappable = true; } else if (nameLen > 4 && strcmp(name+nameLen-4, ".oat") == 0) { whichHeap = HEAP_OAT; is_swappable = true; } else if (nameLen > 4 && strcmp(name+nameLen-4, ".art") == 0) { whichHeap = HEAP_ART; + // Handle system@framework@boot* and system/framework/boot* + if (strstr(name, "@boot") != NULL || strstr(name, "/boot") != NULL) { + subHeap = HEAP_ART_BOOT; + } else { + subHeap = HEAP_ART_APP; + } is_swappable = true; } else if (strncmp(name, "/dev/", 5) == 0) { if (strncmp(name, "/dev/kgsl-3d0", 13) == 0) { @@ -314,7 +342,7 @@ static void read_mapinfo(FILE *fp, stats_t* stats, bool* foundSwapPss) if (strncmp(name, "/dev/ashmem/dalvik-", 19) == 0) { whichHeap = HEAP_DALVIK_OTHER; if (strstr(name, "/dev/ashmem/dalvik-LinearAlloc") == name) { - subHeap = HEAP_DALVIK_LINEARALLOC; + subHeap = HEAP_DALVIK_OTHER_LINEARALLOC; } else if ((strstr(name, "/dev/ashmem/dalvik-alloc space") == name) || (strstr(name, "/dev/ashmem/dalvik-main space") == name)) { // This is the regular Dalvik heap. @@ -332,13 +360,14 @@ static void read_mapinfo(FILE *fp, stats_t* stats, bool* foundSwapPss) whichHeap = HEAP_DALVIK; subHeap = HEAP_DALVIK_ZYGOTE; } else if (strstr(name, "/dev/ashmem/dalvik-indirect ref") == name) { - subHeap = HEAP_DALVIK_INDIRECT_REFERENCE_TABLE; + subHeap = HEAP_DALVIK_OTHER_INDIRECT_REFERENCE_TABLE; } else if (strstr(name, "/dev/ashmem/dalvik-jit-code-cache") == name || - strstr(name, "/dev/ashmem/dalvik-data-code-cache") == name || - strstr(name, "/dev/ashmem/dalvik-CompilerMetadata") == name) { - subHeap = HEAP_DALVIK_CODE_CACHE; + strstr(name, "/dev/ashmem/dalvik-data-code-cache") == name) { + subHeap = HEAP_DALVIK_OTHER_CODE_CACHE; + } else if (strstr(name, "/dev/ashmem/dalvik-CompilerMetadata") == name) { + subHeap = HEAP_DALVIK_OTHER_COMPILER_METADATA; } else { - subHeap = HEAP_DALVIK_ACCOUNTING; // Default to accounting. + subHeap = HEAP_DALVIK_OTHER_ACCOUNTING; // Default to accounting. } } else if (strncmp(name, "/dev/ashmem/CursorWindow", 24) == 0) { whichHeap = HEAP_CURSOR; @@ -423,7 +452,8 @@ static void read_mapinfo(FILE *fp, stats_t* stats, bool* foundSwapPss) stats[whichHeap].sharedClean += shared_clean; stats[whichHeap].swappedOut += swapped_out; stats[whichHeap].swappedOutPss += swapped_out_pss; - if (whichHeap == HEAP_DALVIK || whichHeap == HEAP_DALVIK_OTHER) { + if (whichHeap == HEAP_DALVIK || whichHeap == HEAP_DALVIK_OTHER || + whichHeap == HEAP_DEX || whichHeap == HEAP_ART) { stats[subHeap].pss += pss; stats[subHeap].swappablePss += swappable_pss; stats[subHeap].privateDirty += private_dirty; diff --git a/core/jni/android_os_HwBinder.cpp b/core/jni/android_os_HwBinder.cpp index dc16220e7f84..8fd31fca30ce 100644 --- a/core/jni/android_os_HwBinder.cpp +++ b/core/jni/android_os_HwBinder.cpp @@ -25,7 +25,7 @@ #include <cstring> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android/hidl/manager/1.0/IServiceManager.h> #include <android/hidl/base/1.0/IBase.h> #include <android/hidl/base/1.0/BpHwBase.h> diff --git a/core/jni/android_os_HwBlob.cpp b/core/jni/android_os_HwBlob.cpp index 8590ecf3bb19..0c23797b627b 100644 --- a/core/jni/android_os_HwBlob.cpp +++ b/core/jni/android_os_HwBlob.cpp @@ -22,7 +22,7 @@ #include "android_os_HwParcel.h" -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <hidl/Status.h> #include <nativehelper/ScopedLocalRef.h> diff --git a/core/jni/android_os_HwParcel.cpp b/core/jni/android_os_HwParcel.cpp index 6ea809aa95ad..b412b6a016b6 100644 --- a/core/jni/android_os_HwParcel.cpp +++ b/core/jni/android_os_HwParcel.cpp @@ -24,7 +24,7 @@ #include "android_os_HwBlob.h" #include "android_os_HwRemoteBinder.h" -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <hidl/HidlTransportSupport.h> #include <hidl/Status.h> diff --git a/core/jni/android_os_HwRemoteBinder.cpp b/core/jni/android_os_HwRemoteBinder.cpp index 9c2ee9cfec45..cf59a56a13dc 100644 --- a/core/jni/android_os_HwRemoteBinder.cpp +++ b/core/jni/android_os_HwRemoteBinder.cpp @@ -22,10 +22,10 @@ #include "android_os_HwParcel.h" -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <hidl/Status.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> #include <nativehelper/ScopedLocalRef.h> #include "core_jni_helpers.h" diff --git a/core/jni/android_os_MemoryFile.cpp b/core/jni/android_os_MemoryFile.cpp index c198a733103d..19926e2ac155 100644 --- a/core/jni/android_os_MemoryFile.cpp +++ b/core/jni/android_os_MemoryFile.cpp @@ -19,7 +19,7 @@ #include <cutils/ashmem.h> #include "core_jni_helpers.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <unistd.h> #include <sys/mman.h> diff --git a/core/jni/android_os_MessageQueue.cpp b/core/jni/android_os_MessageQueue.cpp index e57a7190cfce..f7a98d16f2e3 100644 --- a/core/jni/android_os_MessageQueue.cpp +++ b/core/jni/android_os_MessageQueue.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "MessageQueue-JNI" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/Looper.h> diff --git a/core/jni/android_os_Parcel.cpp b/core/jni/android_os_Parcel.cpp index 0a8ae2bdeecd..6af5b9624ebd 100644 --- a/core/jni/android_os_Parcel.cpp +++ b/core/jni/android_os_Parcel.cpp @@ -20,7 +20,7 @@ #include "android_os_Parcel.h" #include "android_util_Binder.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <fcntl.h> #include <stdio.h> @@ -41,8 +41,8 @@ #include <utils/threads.h> #include <utils/String8.h> -#include <ScopedUtfChars.h> -#include <ScopedLocalRef.h> +#include <nativehelper/ScopedUtfChars.h> +#include <nativehelper/ScopedLocalRef.h> #include <android_runtime/AndroidRuntime.h> diff --git a/core/jni/android_os_SELinux.cpp b/core/jni/android_os_SELinux.cpp index 4b68c0dad038..6778b294a93c 100644 --- a/core/jni/android_os_SELinux.cpp +++ b/core/jni/android_os_SELinux.cpp @@ -17,15 +17,15 @@ #define LOG_TAG "SELinuxJNI" #include <utils/Log.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include "core_jni_helpers.h" #include "selinux/selinux.h" #include "selinux/android.h" #include <errno.h> #include <memory> -#include <ScopedLocalRef.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedLocalRef.h> +#include <nativehelper/ScopedUtfChars.h> namespace android { diff --git a/core/jni/android_os_SystemClock.cpp b/core/jni/android_os_SystemClock.cpp index d98407deb7e7..27a40349ec69 100644 --- a/core/jni/android_os_SystemClock.cpp +++ b/core/jni/android_os_SystemClock.cpp @@ -25,7 +25,7 @@ #include <errno.h> #include <string.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include "core_jni_helpers.h" diff --git a/core/jni/android_os_Trace.cpp b/core/jni/android_os_Trace.cpp index dc5ce3912121..25182e1367e2 100644 --- a/core/jni/android_os_Trace.cpp +++ b/core/jni/android_os_Trace.cpp @@ -23,9 +23,9 @@ #include <utils/String8.h> #include <log/log.h> -#include <JNIHelp.h> -#include <ScopedUtfChars.h> -#include <ScopedStringChars.h> +#include <nativehelper/JNIHelp.h> +#include <nativehelper/ScopedUtfChars.h> +#include <nativehelper/ScopedStringChars.h> namespace android { diff --git a/core/jni/android_os_UEventObserver.cpp b/core/jni/android_os_UEventObserver.cpp index 30d40a2a08ad..2df74b05d97b 100644 --- a/core/jni/android_os_UEventObserver.cpp +++ b/core/jni/android_os_UEventObserver.cpp @@ -21,13 +21,13 @@ #include "hardware_legacy/uevent.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <utils/Mutex.h> #include <utils/Vector.h> #include <utils/String8.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> namespace android { diff --git a/core/jni/android_os_VintfObject.cpp b/core/jni/android_os_VintfObject.cpp index 8b4cc91565b6..7ec4b8ea0799 100644 --- a/core/jni/android_os_VintfObject.cpp +++ b/core/jni/android_os_VintfObject.cpp @@ -21,7 +21,7 @@ #include <vector> #include <string> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <vintf/VintfObject.h> #include <vintf/parse_string.h> #include <vintf/parse_xml.h> diff --git a/core/jni/android_os_VintfRuntimeInfo.cpp b/core/jni/android_os_VintfRuntimeInfo.cpp index ecb685435a97..19220cf05adb 100644 --- a/core/jni/android_os_VintfRuntimeInfo.cpp +++ b/core/jni/android_os_VintfRuntimeInfo.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "VintfRuntimeInfo" //#define LOG_NDEBUG 0 -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <vintf/VintfObject.h> #include <vintf/parse_string.h> #include <vintf/parse_xml.h> diff --git a/core/jni/android_os_seccomp.cpp b/core/jni/android_os_seccomp.cpp index 45023713ea85..06e2a167de0a 100644 --- a/core/jni/android_os_seccomp.cpp +++ b/core/jni/android_os_seccomp.cpp @@ -15,7 +15,7 @@ */ #include "core_jni_helpers.h" -#include "JniConstants.h" +#include <nativehelper/JniConstants.h> #include "utils/Log.h" #include <selinux/selinux.h> diff --git a/core/jni/android_server_NetworkManagementSocketTagger.cpp b/core/jni/android_server_NetworkManagementSocketTagger.cpp index 818bf53d97a4..58295af50135 100644 --- a/core/jni/android_server_NetworkManagementSocketTagger.cpp +++ b/core/jni/android_server_NetworkManagementSocketTagger.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "NMST_QTagUidNative" #include <utils/Log.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include <utils/misc.h> diff --git a/core/jni/android_server_Watchdog.cpp b/core/jni/android_server_Watchdog.cpp index d1f943458d90..01d565b26ddb 100644 --- a/core/jni/android_server_Watchdog.cpp +++ b/core/jni/android_server_Watchdog.cpp @@ -25,7 +25,7 @@ #include <errno.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" static void dumpOneStack(int tid, int outFd) { diff --git a/core/jni/android_text_AndroidBidi.cpp b/core/jni/android_text_AndroidBidi.cpp index 2a3f0361a9cd..6e9a339d2419 100644 --- a/core/jni/android_text_AndroidBidi.cpp +++ b/core/jni/android_text_AndroidBidi.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "AndroidUnicode" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include "utils/misc.h" #include "utils/Log.h" @@ -38,7 +38,7 @@ static jint runBidi(JNIEnv* env, jobject obj, jint dir, jcharArray chsArray, if (info != NULL) { UErrorCode status = U_ZERO_ERROR; UBiDi* bidi = ubidi_openSized(n, 0, &status); - ubidi_setPara(bidi, chs, n, dir, NULL, &status); + ubidi_setPara(bidi, reinterpret_cast<const UChar*>(chs), n, dir, NULL, &status); if (U_SUCCESS(status)) { for (int i = 0; i < n; ++i) { info[i] = ubidi_getLevelAt(bidi, i); diff --git a/core/jni/android_text_AndroidCharacter.cpp b/core/jni/android_text_AndroidCharacter.cpp index 474a74e8776c..8885aac49064 100644 --- a/core/jni/android_text_AndroidCharacter.cpp +++ b/core/jni/android_text_AndroidCharacter.cpp @@ -17,8 +17,8 @@ #define LOG_TAG "AndroidUnicode" -#include "JNIHelp.h" -#include "ScopedPrimitiveArray.h" +#include <nativehelper/JNIHelp.h> +#include <nativehelper/ScopedPrimitiveArray.h> #include "core_jni_helpers.h" #include "utils/misc.h" #include "utils/Log.h" diff --git a/core/jni/android_text_StaticLayout.cpp b/core/jni/android_text_StaticLayout.cpp index 13e4f1a59fd8..fd1067534f33 100644 --- a/core/jni/android_text_StaticLayout.cpp +++ b/core/jni/android_text_StaticLayout.cpp @@ -21,9 +21,9 @@ #include "unicode/brkiter.h" #include "utils/misc.h" #include "utils/Log.h" -#include "ScopedStringChars.h" -#include "ScopedPrimitiveArray.h" -#include "JNIHelp.h" +#include <nativehelper/ScopedStringChars.h> +#include <nativehelper/ScopedPrimitiveArray.h> +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <cstdint> #include <vector> diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index 171bd8907e59..15966adcd33c 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -37,9 +37,9 @@ #include "android_util_Binder.h" #include "core_jni_helpers.h" #include "jni.h" -#include "JNIHelp.h" -#include "ScopedStringChars.h" -#include "ScopedUtfChars.h" +#include <nativehelper/JNIHelp.h> +#include <nativehelper/ScopedStringChars.h> +#include <nativehelper/ScopedUtfChars.h> #include "utils/Log.h" #include "utils/misc.h" #include "utils/String8.h" diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index e2aa17b32d0b..5b0f7768c165 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -20,7 +20,7 @@ #include "android_os_Parcel.h" #include "android_util_Binder.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <fcntl.h> #include <inttypes.h> @@ -44,8 +44,8 @@ #include <utils/SystemClock.h> #include <utils/threads.h> -#include <ScopedUtfChars.h> -#include <ScopedLocalRef.h> +#include <nativehelper/ScopedUtfChars.h> +#include <nativehelper/ScopedLocalRef.h> #include "core_jni_helpers.h" diff --git a/core/jni/android_util_EventLog.cpp b/core/jni/android_util_EventLog.cpp index 0b4fbcc2e340..3d0577889854 100644 --- a/core/jni/android_util_EventLog.cpp +++ b/core/jni/android_util_EventLog.cpp @@ -20,7 +20,7 @@ #include <log/log.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include "jni.h" diff --git a/core/jni/android_util_FileObserver.cpp b/core/jni/android_util_FileObserver.cpp index 2b93b6d61905..6f975b23e5bd 100644 --- a/core/jni/android_util_FileObserver.cpp +++ b/core/jni/android_util_FileObserver.cpp @@ -15,7 +15,7 @@ ** limitations under the License. */ -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include "utils/Log.h" #include "utils/misc.h" diff --git a/core/jni/android_util_Log.cpp b/core/jni/android_util_Log.cpp index 56505afc78b2..a6adc88f53fb 100644 --- a/core/jni/android_util_Log.cpp +++ b/core/jni/android_util_Log.cpp @@ -26,7 +26,7 @@ #include <utils/String8.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "utils/misc.h" #include "core_jni_helpers.h" #include "android_util_Log.h" diff --git a/core/jni/android_util_Log.h b/core/jni/android_util_Log.h index 4804a8547422..8a32864ff872 100644 --- a/core/jni/android_util_Log.h +++ b/core/jni/android_util_Log.h @@ -18,7 +18,7 @@ #define _ANDROID_UTIL_LOG_H #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> namespace android { diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp index a03d3c503e1c..cd95432ebe9d 100644 --- a/core/jni/android_util_Process.cpp +++ b/core/jni/android_util_Process.cpp @@ -30,7 +30,7 @@ #include "core_jni_helpers.h" #include "android_util_Binder.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <dirent.h> #include <fcntl.h> diff --git a/core/jni/android_util_StringBlock.cpp b/core/jni/android_util_StringBlock.cpp index b396afe62dff..760f9e36ed3d 100644 --- a/core/jni/android_util_StringBlock.cpp +++ b/core/jni/android_util_StringBlock.cpp @@ -18,7 +18,7 @@ #define LOG_TAG "StringBlock" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <utils/misc.h> #include <core_jni_helpers.h> #include <utils/Log.h> diff --git a/core/jni/android_util_XmlBlock.cpp b/core/jni/android_util_XmlBlock.cpp index a15c23cd879a..87f88511ec1b 100644 --- a/core/jni/android_util_XmlBlock.cpp +++ b/core/jni/android_util_XmlBlock.cpp @@ -18,7 +18,7 @@ #define LOG_TAG "XmlBlock" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <core_jni_helpers.h> #include <androidfw/AssetManager.h> #include <androidfw/ResourceTypes.h> diff --git a/core/jni/android_util_jar_StrictJarFile.cpp b/core/jni/android_util_jar_StrictJarFile.cpp index 4f1f926c8a22..4ab8db4395f6 100644 --- a/core/jni/android_util_jar_StrictJarFile.cpp +++ b/core/jni/android_util_jar_StrictJarFile.cpp @@ -22,10 +22,10 @@ #include <log/log.h> -#include "JNIHelp.h" -#include "JniConstants.h" -#include "ScopedLocalRef.h" -#include "ScopedUtfChars.h" +#include <nativehelper/JNIHelp.h> +#include <nativehelper/JniConstants.h> +#include <nativehelper/ScopedLocalRef.h> +#include <nativehelper/ScopedUtfChars.h> #include "jni.h" #include "ziparchive/zip_archive.h" diff --git a/core/jni/android_view_DisplayEventReceiver.cpp b/core/jni/android_view_DisplayEventReceiver.cpp index ea5a760622d7..78bf1db8e127 100644 --- a/core/jni/android_view_DisplayEventReceiver.cpp +++ b/core/jni/android_view_DisplayEventReceiver.cpp @@ -18,7 +18,7 @@ //#define LOG_NDEBUG 0 -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <inttypes.h> @@ -30,7 +30,7 @@ #include <gui/DisplayEventReceiver.h> #include "android_os_MessageQueue.h" -#include <ScopedLocalRef.h> +#include <nativehelper/ScopedLocalRef.h> #include "core_jni_helpers.h" diff --git a/core/jni/android_view_InputChannel.cpp b/core/jni/android_view_InputChannel.cpp index 1c6ead0f1086..71742cbbb180 100644 --- a/core/jni/android_view_InputChannel.cpp +++ b/core/jni/android_view_InputChannel.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "InputChannel-JNI" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <binder/Parcel.h> diff --git a/core/jni/android_view_InputDevice.cpp b/core/jni/android_view_InputDevice.cpp index 9cf6a9d08890..494fad7900ef 100644 --- a/core/jni/android_view_InputDevice.cpp +++ b/core/jni/android_view_InputDevice.cpp @@ -17,10 +17,10 @@ #include <input/Input.h> #include <android_runtime/AndroidRuntime.h> -#include <nativehelper/jni.h> +#include <jni.h> #include <nativehelper/JNIHelp.h> -#include <ScopedLocalRef.h> +#include <nativehelper/ScopedLocalRef.h> #include "android_view_InputDevice.h" #include "android_view_KeyCharacterMap.h" diff --git a/core/jni/android_view_InputEventReceiver.cpp b/core/jni/android_view_InputEventReceiver.cpp index 8293cd8ff88d..31e954bf5b88 100644 --- a/core/jni/android_view_InputEventReceiver.cpp +++ b/core/jni/android_view_InputEventReceiver.cpp @@ -18,7 +18,7 @@ //#define LOG_NDEBUG 0 -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/Log.h> @@ -31,7 +31,7 @@ #include "android_view_KeyEvent.h" #include "android_view_MotionEvent.h" -#include <ScopedLocalRef.h> +#include <nativehelper/ScopedLocalRef.h> #include "core_jni_helpers.h" diff --git a/core/jni/android_view_InputEventSender.cpp b/core/jni/android_view_InputEventSender.cpp index 3bd6917aedfa..420ff2a46814 100644 --- a/core/jni/android_view_InputEventSender.cpp +++ b/core/jni/android_view_InputEventSender.cpp @@ -18,7 +18,7 @@ //#define LOG_NDEBUG 0 -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/Log.h> @@ -31,7 +31,7 @@ #include "android_view_KeyEvent.h" #include "android_view_MotionEvent.h" -#include <ScopedLocalRef.h> +#include <nativehelper/ScopedLocalRef.h> #include "core_jni_helpers.h" diff --git a/core/jni/android_view_InputQueue.cpp b/core/jni/android_view_InputQueue.cpp index 96ccdee20c7c..24c3ff80badd 100644 --- a/core/jni/android_view_InputQueue.cpp +++ b/core/jni/android_view_InputQueue.cpp @@ -26,9 +26,9 @@ #include <input/Input.h> #include <utils/Looper.h> #include <utils/TypeHelpers.h> -#include <ScopedLocalRef.h> +#include <nativehelper/ScopedLocalRef.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_os_MessageQueue.h" #include "android_view_KeyEvent.h" #include "android_view_MotionEvent.h" diff --git a/core/jni/android_view_KeyCharacterMap.cpp b/core/jni/android_view_KeyCharacterMap.cpp index e5519a752c39..586b26ef328f 100644 --- a/core/jni/android_view_KeyCharacterMap.cpp +++ b/core/jni/android_view_KeyCharacterMap.cpp @@ -20,7 +20,7 @@ #include <input/Input.h> #include <binder/Parcel.h> -#include <nativehelper/jni.h> +#include <jni.h> #include <nativehelper/JNIHelp.h> #include "android_os_Parcel.h" diff --git a/core/jni/android_view_KeyEvent.cpp b/core/jni/android_view_KeyEvent.cpp index 216e6f64a9f8..8a6e745b60a8 100644 --- a/core/jni/android_view_KeyEvent.cpp +++ b/core/jni/android_view_KeyEvent.cpp @@ -16,13 +16,13 @@ #define LOG_TAG "KeyEvent-JNI" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/Log.h> #include <utils/Log.h> #include <input/Input.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> #include "android_view_KeyEvent.h" #include "core_jni_helpers.h" diff --git a/core/jni/android_view_MotionEvent.cpp b/core/jni/android_view_MotionEvent.cpp index 0245d38144cb..f11b0dce684e 100644 --- a/core/jni/android_view_MotionEvent.cpp +++ b/core/jni/android_view_MotionEvent.cpp @@ -16,14 +16,14 @@ #define LOG_TAG "MotionEvent-JNI" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <SkMatrix.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/Log.h> #include <utils/Log.h> #include <input/Input.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> #include "android_os_Parcel.h" #include "android_view_MotionEvent.h" #include "android_util_Binder.h" @@ -345,8 +345,10 @@ static jlong android_view_MotionEvent_nativeInitialize(JNIEnv* env, jclass clazz return 0; } - MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); - if (!event) { + MotionEvent* event; + if (nativePtr) { + event = reinterpret_cast<MotionEvent*>(nativePtr); + } else { event = new MotionEvent(); } diff --git a/core/jni/android_view_PointerIcon.cpp b/core/jni/android_view_PointerIcon.cpp index 4150636cae12..4f79790dec51 100644 --- a/core/jni/android_view_PointerIcon.cpp +++ b/core/jni/android_view_PointerIcon.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "PointerIcon-JNI" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_view_PointerIcon.h" @@ -24,7 +24,7 @@ #include <android_runtime/Log.h> #include <utils/Log.h> #include <android/graphics/GraphicsJNI.h> -#include "ScopedLocalRef.h" +#include <nativehelper/ScopedLocalRef.h> #include "core_jni_helpers.h" diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp index a0c62c366285..cb96f613084d 100644 --- a/core/jni/android_view_Surface.cpp +++ b/core/jni/android_view_Surface.cpp @@ -19,7 +19,7 @@ #include <stdio.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_os_Parcel.h" #include "android/graphics/GraphicsJNI.h" @@ -45,7 +45,7 @@ #include <utils/misc.h> #include <utils/Log.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> #include <AnimationContext.h> #include <FrameInfo.h> diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index 73b3f52f078b..d18fc2dc8c29 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -23,8 +23,9 @@ #include "android/graphics/Region.h" #include "core_jni_helpers.h" -#include <JNIHelp.h> -#include <ScopedUtfChars.h> +#include <android-base/chrono_utils.h> +#include <nativehelper/JNIHelp.h> +#include <nativehelper/ScopedUtfChars.h> #include <android_runtime/android_view_Surface.h> #include <android_runtime/android_view_SurfaceSession.h> #include <gui/Surface.h> @@ -495,8 +496,9 @@ static void nativeSetDisplayPowerMode(JNIEnv* env, jclass clazz, jobject tokenOb sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return; - ALOGD_IF_SLOW(100, "Excessive delay in setPowerMode()"); + android::base::Timer t; SurfaceComposerClient::setDisplayPowerMode(token, mode); + if (t.duration() > 100ms) ALOGD("Excessive delay in setPowerMode()"); } static jboolean nativeClearContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject) { diff --git a/core/jni/android_view_SurfaceSession.cpp b/core/jni/android_view_SurfaceSession.cpp index dad6958560c0..99a445e33ff6 100644 --- a/core/jni/android_view_SurfaceSession.cpp +++ b/core/jni/android_view_SurfaceSession.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "SurfaceSession" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/android_view_SurfaceSession.h> diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp index 9c0a65a60606..094bf9a1d436 100644 --- a/core/jni/android_view_ThreadedRenderer.cpp +++ b/core/jni/android_view_ThreadedRenderer.cpp @@ -23,7 +23,7 @@ #include <nativehelper/JNIHelp.h> #include "core_jni_helpers.h" #include <GraphicsJNI.h> -#include <ScopedPrimitiveArray.h> +#include <nativehelper/ScopedPrimitiveArray.h> #include <EGL/egl.h> #include <EGL/eglext.h> diff --git a/core/jni/android_view_VelocityTracker.cpp b/core/jni/android_view_VelocityTracker.cpp index e1f2241bfd47..153789c7f933 100644 --- a/core/jni/android_view_VelocityTracker.cpp +++ b/core/jni/android_view_VelocityTracker.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "VelocityTracker-JNI" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/Log.h> @@ -24,7 +24,7 @@ #include <input/VelocityTracker.h> #include "android_view_MotionEvent.h" -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> #include "core_jni_helpers.h" diff --git a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp index f8f9efe2804f..fce5dd58d7f9 100644 --- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp +++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp @@ -19,7 +19,7 @@ #include "core_jni_helpers.h" -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> #include <androidfw/ZipFileRO.h> #include <androidfw/ZipUtils.h> #include <utils/Log.h> diff --git a/core/jni/com_android_internal_net_NetworkStatsFactory.cpp b/core/jni/com_android_internal_net_NetworkStatsFactory.cpp index 4a2b88142e78..0cb69359901d 100644 --- a/core/jni/com_android_internal_net_NetworkStatsFactory.cpp +++ b/core/jni/com_android_internal_net_NetworkStatsFactory.cpp @@ -24,9 +24,9 @@ #include <core_jni_helpers.h> #include <jni.h> -#include <ScopedUtfChars.h> -#include <ScopedLocalRef.h> -#include <ScopedPrimitiveArray.h> +#include <nativehelper/ScopedUtfChars.h> +#include <nativehelper/ScopedLocalRef.h> +#include <nativehelper/ScopedPrimitiveArray.h> #include <utils/Log.h> #include <utils/misc.h> diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index cb53106dbf28..3887c76419cc 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -54,10 +54,10 @@ #include <processgroup/processgroup.h> #include "core_jni_helpers.h" -#include "JNIHelp.h" -#include "ScopedLocalRef.h" -#include "ScopedPrimitiveArray.h" -#include "ScopedUtfChars.h" +#include <nativehelper/JNIHelp.h> +#include <nativehelper/ScopedLocalRef.h> +#include <nativehelper/ScopedPrimitiveArray.h> +#include <nativehelper/ScopedUtfChars.h> #include "fd_utils.h" #include "nativebridge/native_bridge.h" diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp index 3d63b013e9f1..18731187b8b4 100644 --- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp +++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp @@ -15,7 +15,7 @@ ** limitations under the License. */ -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/android_view_Surface.h> #include <android_runtime/android_graphics_SurfaceTexture.h> diff --git a/core/jni/com_google_android_gles_jni_GLImpl.cpp b/core/jni/com_google_android_gles_jni_GLImpl.cpp index 3e74d1c855b3..fe012d75c1f4 100644 --- a/core/jni/com_google_android_gles_jni_GLImpl.cpp +++ b/core/jni/com_google_android_gles_jni_GLImpl.cpp @@ -22,7 +22,7 @@ #pragma GCC diagnostic ignored "-Wunused-function" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> diff --git a/core/jni/core_jni_helpers.h b/core/jni/core_jni_helpers.h index 3f169c365ca4..1325b0ce1ea7 100644 --- a/core/jni/core_jni_helpers.h +++ b/core/jni/core_jni_helpers.h @@ -17,7 +17,7 @@ #ifndef CORE_JNI_HELPERS #define CORE_JNI_HELPERS -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> namespace android { diff --git a/core/jni/include/android_runtime/AndroidRuntime.h b/core/jni/include/android_runtime/AndroidRuntime.h index c2189d4af86d..3ec8b1fe903f 100644 --- a/core/jni/include/android_runtime/AndroidRuntime.h +++ b/core/jni/include/android_runtime/AndroidRuntime.h @@ -26,7 +26,7 @@ #include <utils/Vector.h> #include <utils/threads.h> #include <pthread.h> -#include <nativehelper/jni.h> +#include <jni.h> namespace android { diff --git a/core/jni/include/android_runtime/android_view_InputQueue.h b/core/jni/include/android_runtime/android_view_InputQueue.h index ed37b0aa5083..ac8da586eed9 100644 --- a/core/jni/include/android_runtime/android_view_InputQueue.h +++ b/core/jni/include/android_runtime/android_view_InputQueue.h @@ -22,7 +22,7 @@ #include <utils/TypeHelpers.h> #include <utils/Vector.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> /* * Declare a concrete type for the NDK's AInputQueue forward declaration diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index c783caa187fd..af786695d68f 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -288,6 +288,11 @@ <!-- Mask to use when checking skb mark defined in config_networkWakeupPacketMark above. --> <integer name="config_networkWakeupPacketMask">0</integer> + <!-- Whether the APF Filter in the device should filter out IEEE 802.3 Frames + Those frames are identified by the field Eth-type having values + less than 0x600 --> + <bool translatable="false" name="config_apfDrop802_3Frames">true</bool> + <!-- Default value for ConnectivityManager.getMultipathPreference() on metered networks. Actual device behaviour is controlled by Settings.Global.NETWORK_METERED_MULTIPATH_PREFERENCE. This is the default value of that setting. --> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 758ee4a28c07..34d4d6314080 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1790,6 +1790,7 @@ <java-symbol type="integer" name="config_networkAvoidBadWifi" /> <java-symbol type="integer" name="config_networkWakeupPacketMark" /> <java-symbol type="integer" name="config_networkWakeupPacketMask" /> + <java-symbol type="bool" name="config_apfDrop802_3Frames" /> <java-symbol type="integer" name="config_networkMeteredMultipathPreference" /> <java-symbol type="integer" name="config_notificationsBatteryFullARGB" /> <java-symbol type="integer" name="config_notificationsBatteryLedOff" /> diff --git a/core/res/res/xml/sms_short_codes.xml b/core/res/res/xml/sms_short_codes.xml index 644638d14daa..dbc9e517eef1 100644 --- a/core/res/res/xml/sms_short_codes.xml +++ b/core/res/res/xml/sms_short_codes.xml @@ -61,7 +61,7 @@ <shortcode country="bh" pattern="\\d{1,5}" free="81181" /> <!-- Brazil: 1-5 digits (standard system default, not country specific) --> - <shortcode country="br" pattern="\\d{1,5}" free="6000[012]\\d" /> + <shortcode country="br" pattern="\\d{1,5}" free="6000[012]\\d|876|5500|9963" /> <!-- Belarus: 4 digits --> <shortcode country="by" pattern="\\d{4}" premium="3336|4161|444[4689]|501[34]|7781" /> @@ -72,10 +72,16 @@ <!-- Switzerland: 3-5 digits: http://www.swisscom.ch/fxres/kmu/thirdpartybusiness_code_of_conduct_en.pdf --> <shortcode country="ch" pattern="[2-9]\\d{2,4}" premium="543|83111|30118" free="98765" /> + <!-- Chile: 4-5 digits (not confirmed), known premium codes listed --> + <shortcode country="cl" pattern="\\d{4,5}" free="9963" /> + <!-- China: premium shortcodes start with "1066", free shortcodes start with "1065": http://clients.txtnation.com/entries/197192-china-premium-sms-short-code-requirements --> <shortcode country="cn" premium="1066.*" free="1065.*" /> + <!-- Colombia: 1-6 digits (not confirmed) --> + <shortcode country="co" pattern="\\d{1,6}" free="890350" /> + <!-- Cyprus: 4-6 digits (not confirmed), known premium codes listed, plus EU --> <shortcode country="cy" pattern="\\d{4,6}" premium="7510" free="116\\d{3}" /> @@ -84,7 +90,7 @@ <shortcode country="cz" premium="9\\d{6,7}" free="116\\d{3}" /> <!-- Germany: 4-5 digits plus 1232xxx (premium codes from http://www.vodafone.de/infofaxe/537.pdf and http://premiumdienste.eplus.de/pdf/kodex.pdf), plus EU. To keep the premium regex from being too large, it only includes payment processors that have been used by SMS malware, with the regular pattern matching the other premium short codes. --> - <shortcode country="de" pattern="\\d{4,5}|1232\\d{3}" premium="11(?:111|833)|1232(?:013|021|060|075|286|358)|118(?:44|80|86)|20[25]00|220(?:21|22|88|99)|221(?:14|21)|223(?:44|53|77)|224[13]0|225(?:20|59|90)|226(?:06|10|20|26|30|40|56|70)|227(?:07|33|39|66|76|78|79|88|99)|228(?:08|11|66|77)|23300|30030|3[12347]000|330(?:33|55|66)|33(?:233|331|366|533)|34(?:34|567)|37000|40(?:040|123|444|[3568]00)|41(?:010|414)|44(?:000|044|344|44[24]|544)|50005|50100|50123|50555|51000|52(?:255|783)|54(?:100|2542)|55(?:077|[24]00|222|333|55|[12369]55)|56(?:789|886)|60800|6[13]000|66(?:[12348]66|566|766|777|88|999)|68888|70(?:07|123|777)|76766|77(?:007|070|222|444|[567]77)|80(?:008|123|888)|82(?:002|[378]00|323|444|472|474|488|727)|83(?:005|[169]00|333|830)|84(?:141|300|32[34]|343|488|499|777|888)|85888|86(?:188|566|640|644|650|677|868|888)|870[24]9|871(?:23|[49]9)|872(?:1[0-8]|49|99)|87499|875(?:49|55|99)|876(?:0[1367]|1[1245678]|54|99)|877(?:00|99)|878(?:15|25|3[567]|8[12])|87999|880(?:08|44|55|77|99)|88688|888(?:03|10|8|89)|8899|90(?:009|999)|99999" free="116\\d{3}|81214|81215|47529|70296|83782" /> + <shortcode country="de" pattern="\\d{4,5}|1232\\d{3}" premium="11(?:111|833)|1232(?:013|021|060|075|286|358)|118(?:44|80|86)|20[25]00|220(?:21|22|88|99)|221(?:14|21)|223(?:44|53|77)|224[13]0|225(?:20|59|90)|226(?:06|10|20|26|30|40|56|70)|227(?:07|33|39|66|76|78|79|88|99)|228(?:08|11|66|77)|23300|30030|3[12347]000|330(?:33|55|66)|33(?:233|331|366|533)|34(?:34|567)|37000|40(?:040|123|444|[3568]00)|41(?:010|414)|44(?:000|044|344|44[24]|544)|50005|50100|50123|50555|51000|52(?:255|783)|54(?:100|2542)|55(?:077|[24]00|222|333|55|[12369]55)|56(?:789|886)|60800|6[13]000|66(?:[12348]66|566|766|777|88|999)|68888|70(?:07|123|777)|76766|77(?:007|070|222|444|[567]77)|80(?:008|123|888)|82(?:002|[378]00|323|444|472|474|488|727)|83(?:005|[169]00|333|830)|84(?:141|300|32[34]|343|488|499|777|888)|85888|86(?:188|566|640|644|650|677|868|888)|870[24]9|871(?:23|[49]9)|872(?:1[0-8]|49|99)|87499|875(?:49|55|99)|876(?:0[1367]|1[1245678]|54|99)|877(?:00|99)|878(?:15|25|3[567]|8[12])|87999|880(?:08|44|55|77|99)|88688|888(?:03|10|8|89)|8899|90(?:009|999)|99999" free="116\\d{3}|81214|81215|47529|70296|83782|3011|73240" /> <!-- Denmark: see http://iprs.webspacecommerce.com/Denmark-Premium-Rate-Numbers --> <shortcode country="dk" pattern="\\d{4,5}" premium="1\\d{3}" free="116\\d{3}|4665" /> @@ -108,11 +114,14 @@ <!-- United Kingdom (Great Britain): 4-6 digits, common codes [5-8]xxxx, plus EU: http://www.short-codes.com/media/Co-regulatoryCodeofPracticeforcommonshortcodes170206.pdf, visual voicemail code for EE: 887 --> - <shortcode country="gb" pattern="\\d{4,6}" premium="[5-8]\\d{4}" free="116\\d{3}|2020|35890|61002|61202|887|83669|34664|40406|60174" /> + <shortcode country="gb" pattern="\\d{4,6}" premium="[5-8]\\d{4}" free="116\\d{3}|2020|35890|61002|61202|887|83669|34664|40406|60174|7726|37726" /> <!-- Georgia: 4 digits, known premium codes listed --> <shortcode country="ge" pattern="\\d{4}" premium="801[234]|888[239]" /> + <!-- Ghana: 4 digits, known premium codes listed --> + <shortcode country="gh" pattern="\\d{4}" free="5041" /> + <!-- Greece: 5 digits (54xxx, 19yxx, x=0-9, y=0-5): http://www.cmtelecom.com/premium-sms/greece --> <shortcode country="gr" pattern="\\d{5}" premium="54\\d{3}|19[0-5]\\d{2}" free="116\\d{3}|12115" /> @@ -143,6 +152,9 @@ <!-- Japan: 8083 used by SOFTBANK_DCB_2 --> <shortcode country="jp" free="8083" /> + <!-- Kenya: 5 digits, known premium codes listed --> + <shortcode country="ke" pattern="\\d{5}" free="21725" /> + <!-- Kyrgyzstan: 4 digits, known premium codes listed --> <shortcode country="kg" pattern="\\d{4}" premium="415[2367]|444[69]" /> @@ -160,13 +172,16 @@ <!-- Luxembourg: 5 digits, 6xxxx, plus EU: http://www.luxgsm.lu/assets/files/filepage/file_1253803400.pdf --> - <shortcode country="lu" premium="6\\d{4}" free="116\\d{3}|60231" /> + <shortcode country="lu" premium="6\\d{4}" free="116\\d{3}|60231|64085" /> <!-- Latvia: 4 digits, known premium codes listed, plus EU --> <shortcode country="lv" pattern="\\d{4}" premium="18(?:19|63|7[1-4])" free="116\\d{3}|1399" /> + <!-- Macedonia: 1-6 digits (not confirmed), known premium codes listed --> + <shortcode country="mk" pattern="\\d{1,6}" free="129005|122" /> + <!-- Mexico: 4-5 digits (not confirmed), known premium codes listed --> - <shortcode country="mx" pattern="\\d{4,5}" premium="53035|7766" free="46645|5050|26259|50025|50052" /> + <shortcode country="mx" pattern="\\d{4,5}" premium="53035|7766" free="46645|5050|26259|50025|50052|9963" /> <!-- Malaysia: 5 digits: http://www.skmm.gov.my/attachment/Consumer_Regulation/Mobile_Content_Services_FAQs.pdf --> <shortcode country="my" pattern="\\d{5}" premium="32298|33776" free="22099|28288" /> @@ -180,6 +195,9 @@ <!-- New Zealand: 3-4 digits, known premium codes listed --> <shortcode country="nz" pattern="\\d{3,4}" premium="3903|8995|4679" free="3067|3068|4053" /> + <!-- Peru: 4-5 digits (not confirmed), known premium codes listed --> + <shortcode country="pe" pattern="\\d{4,5}" free="9963" /> + <!-- Philippines --> <shortcode country="ph" free="2147|5495|5496" /> @@ -196,11 +214,14 @@ <!-- Qatar: 1-5 digits (standard system default, not country specific) --> <shortcode country="qa" pattern="\\d{1,5}" free="92451" /> + <!-- Reunion (French Territory): 1-5 digits (not confirmed) --> + <shortcode country="re" pattern="\\d{1,5}" free="38600,36300,36303,959" /> + <!-- Romania: 4 digits, plus EU: http://www.simplus.ro/en/resources/glossary-of-terms/ --> <shortcode country="ro" pattern="\\d{4}" premium="12(?:63|66|88)|13(?:14|80)" free="116\\d{3}|3654|8360" /> <!-- Russia: 4 digits, known premium codes listed: http://smscoin.net/info/pricing-russia/ --> - <shortcode country="ru" pattern="\\d{4}" premium="1(?:1[56]1|899)|2(?:09[57]|322|47[46]|880|990)|3[589]33|4161|44(?:4[3-9]|81)|77(?:33|81)|8424" /> + <shortcode country="ru" pattern="\\d{4}" premium="1(?:1[56]1|899)|2(?:09[57]|322|47[46]|880|990)|3[589]33|4161|44(?:4[3-9]|81)|77(?:33|81)|8424" free="6954,8501"/> <!-- Saudi Arabia --> <shortcode country="sa" free="8145" /> @@ -237,4 +258,7 @@ <!-- Vietnam: 1-5 digits (standard system default, not country specific) --> <shortcode country="vn" pattern="\\d{1,5}" free="5001|9055" /> + <!-- Mayotte (French Territory): 1-5 digits (not confirmed) --> + <shortcode country="yt" pattern="\\d{1,5}" free="38600,36300,36303,959" /> + </shortcodes> diff --git a/core/tests/coretests/src/android/app/timezone/DistroFormatVersionTest.java b/core/tests/coretests/src/android/app/timezone/DistroFormatVersionTest.java index 9bbcd3d2d2e9..70a0877beb5f 100644 --- a/core/tests/coretests/src/android/app/timezone/DistroFormatVersionTest.java +++ b/core/tests/coretests/src/android/app/timezone/DistroFormatVersionTest.java @@ -27,7 +27,6 @@ import org.junit.Test; /** * Tests for {@link DistroFormatVersion}. */ -// TODO(nfuller) Move to CTS once this class is part of the SystemApi. http://b/31008728 public class DistroFormatVersionTest { @Test diff --git a/core/tests/coretests/src/android/app/timezone/DistroRulesVersionTest.java b/core/tests/coretests/src/android/app/timezone/DistroRulesVersionTest.java index 2fbc9a1f8e7a..eecae46910fd 100644 --- a/core/tests/coretests/src/android/app/timezone/DistroRulesVersionTest.java +++ b/core/tests/coretests/src/android/app/timezone/DistroRulesVersionTest.java @@ -27,7 +27,6 @@ import org.junit.Test; /** * Tests for {@link DistroRulesVersion}. */ -// TODO(nfuller) Move to CTS once this class is part of the SystemApi. http://b/31008728 public class DistroRulesVersionTest { @Test diff --git a/core/tests/coretests/src/android/app/timezone/RulesStateTest.java b/core/tests/coretests/src/android/app/timezone/RulesStateTest.java index 7f4819bf63a1..99abe243556c 100644 --- a/core/tests/coretests/src/android/app/timezone/RulesStateTest.java +++ b/core/tests/coretests/src/android/app/timezone/RulesStateTest.java @@ -29,7 +29,6 @@ import org.junit.Test; /** * Tests for {@link RulesState}. */ -// TODO(nfuller) Move to CTS once this class is part of the SystemApi. http://b/31008728 public class RulesStateTest { @Test diff --git a/core/tests/coretests/src/android/app/timezone/RulesUpdaterContractTest.java b/core/tests/coretests/src/android/app/timezone/RulesUpdaterContractTest.java index e7a839c3e9fb..91f8ebc9ec1c 100644 --- a/core/tests/coretests/src/android/app/timezone/RulesUpdaterContractTest.java +++ b/core/tests/coretests/src/android/app/timezone/RulesUpdaterContractTest.java @@ -33,7 +33,6 @@ import org.junit.Test; /** * Tests for {@link RulesUpdaterContract}. */ -// TODO(nfuller) Move to CTS once this class is part of the SystemApi. http://b/31008728 public class RulesUpdaterContractTest { @Test diff --git a/drm/jni/android_drm_DrmManagerClient.cpp b/drm/jni/android_drm_DrmManagerClient.cpp index 63fe8acedd54..52ea8e3b161f 100644 --- a/drm/jni/android_drm_DrmManagerClient.cpp +++ b/drm/jni/android_drm_DrmManagerClient.cpp @@ -19,8 +19,8 @@ #include <utils/Log.h> #include <jni.h> -#include <JNIHelp.h> -#include <ScopedLocalRef.h> +#include <nativehelper/JNIHelp.h> +#include <nativehelper/ScopedLocalRef.h> #include <android_runtime/AndroidRuntime.h> #include <drm/DrmInfo.h> diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp index c655b7c3c5ee..fcc975c0975a 100644 --- a/media/jni/android_media_ImageReader.cpp +++ b/media/jni/android_media_ImageReader.cpp @@ -31,7 +31,7 @@ #include <android_runtime/android_view_Surface.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <stdint.h> #include <inttypes.h> diff --git a/media/jni/android_media_ImageWriter.cpp b/media/jni/android_media_ImageWriter.cpp index 56df32f79cb9..1cfb3cfd34cd 100644 --- a/media/jni/android_media_ImageWriter.cpp +++ b/media/jni/android_media_ImageWriter.cpp @@ -26,7 +26,7 @@ #include <android_runtime/AndroidRuntime.h> #include <android_runtime/android_view_Surface.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <stdint.h> #include <inttypes.h> diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp index 810996ec79a7..79d6c53fbbc5 100644 --- a/media/jni/android_media_MediaCodec.cpp +++ b/media/jni/android_media_MediaCodec.cpp @@ -25,7 +25,7 @@ #include "android_runtime/AndroidRuntime.h" #include "android_runtime/android_view_Surface.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <cutils/compiler.h> diff --git a/media/jni/android_media_MediaCodecList.cpp b/media/jni/android_media_MediaCodecList.cpp index de9bf1f528af..8de11caf7d7a 100644 --- a/media/jni/android_media_MediaCodecList.cpp +++ b/media/jni/android_media_MediaCodecList.cpp @@ -26,7 +26,7 @@ #include "android_runtime/AndroidRuntime.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_media_Utils.h" using namespace android; diff --git a/media/jni/android_media_MediaCrypto.cpp b/media/jni/android_media_MediaCrypto.cpp index 2adbfeefcd7e..a2abef59f95e 100644 --- a/media/jni/android_media_MediaCrypto.cpp +++ b/media/jni/android_media_MediaCrypto.cpp @@ -22,7 +22,7 @@ #include "android_runtime/AndroidRuntime.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <binder/IServiceManager.h> #include <cutils/properties.h> diff --git a/media/jni/android_media_MediaDataSource.cpp b/media/jni/android_media_MediaDataSource.cpp index 2ab7e39fad17..8c38d887f82b 100644 --- a/media/jni/android_media_MediaDataSource.cpp +++ b/media/jni/android_media_MediaDataSource.cpp @@ -23,7 +23,7 @@ #include "android_runtime/AndroidRuntime.h" #include "android_runtime/Log.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <binder/MemoryDealer.h> #include <drm/drm_framework_common.h> diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp index 7a98c954747f..31e227bea363 100644 --- a/media/jni/android_media_MediaDrm.cpp +++ b/media/jni/android_media_MediaDrm.cpp @@ -24,7 +24,7 @@ #include "android_runtime/Log.h" #include "android_os_Parcel.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <binder/IServiceManager.h> #include <binder/Parcel.h> diff --git a/media/jni/android_media_MediaHTTPConnection.cpp b/media/jni/android_media_MediaHTTPConnection.cpp index fa0b43fedcef..365e045689f0 100644 --- a/media/jni/android_media_MediaHTTPConnection.cpp +++ b/media/jni/android_media_MediaHTTPConnection.cpp @@ -27,7 +27,7 @@ #include "android_runtime/AndroidRuntime.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> namespace android { diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp index f4e940d6cb21..4f1a145b8709 100644 --- a/media/jni/android_media_MediaMetadataRetriever.cpp +++ b/media/jni/android_media_MediaMetadataRetriever.cpp @@ -28,7 +28,7 @@ #include <private/media/VideoFrame.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" #include "android_media_MediaDataSource.h" #include "android_media_Utils.h" diff --git a/media/jni/android_media_MediaMuxer.cpp b/media/jni/android_media_MediaMuxer.cpp index 216624e96ad2..8b67346b3bc3 100644 --- a/media/jni/android_media_MediaMuxer.cpp +++ b/media/jni/android_media_MediaMuxer.cpp @@ -21,7 +21,7 @@ #include "android_media_Utils.h" #include "android_runtime/AndroidRuntime.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/foundation/ADebug.h> diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index 8f14b79660be..8392b9e4b767 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -30,7 +30,7 @@ #include <fcntl.h> #include <utils/threads.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" #include "android_runtime/android_view_Surface.h" #include "android_runtime/Log.h" diff --git a/media/jni/android_media_MediaProfiles.cpp b/media/jni/android_media_MediaProfiles.cpp index 580004304170..5bc80925eca4 100644 --- a/media/jni/android_media_MediaProfiles.cpp +++ b/media/jni/android_media_MediaProfiles.cpp @@ -22,7 +22,7 @@ #include <utils/threads.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" #include <media/MediaProfiles.h> diff --git a/media/jni/android_media_MediaScanner.cpp b/media/jni/android_media_MediaScanner.cpp index 0f3c61f53a2c..3b475b2d70c8 100644 --- a/media/jni/android_media_MediaScanner.cpp +++ b/media/jni/android_media_MediaScanner.cpp @@ -24,7 +24,7 @@ #include <private/media/VideoFrame.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" #include "android_runtime/Log.h" diff --git a/media/jni/android_media_MediaSync.cpp b/media/jni/android_media_MediaSync.cpp index 6de5ea9e9f66..f75200868a0d 100644 --- a/media/jni/android_media_MediaSync.cpp +++ b/media/jni/android_media_MediaSync.cpp @@ -26,7 +26,7 @@ #include "android_runtime/AndroidRuntime.h" #include "android_runtime/android_view_Surface.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <gui/Surface.h> diff --git a/media/jni/android_media_ResampleInputStream.cpp b/media/jni/android_media_ResampleInputStream.cpp index fa755242a86b..3d8f517ca3a1 100644 --- a/media/jni/android_media_ResampleInputStream.cpp +++ b/media/jni/android_media_ResampleInputStream.cpp @@ -27,7 +27,7 @@ #include <utils/threads.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" diff --git a/media/jni/android_media_SyncParams.cpp b/media/jni/android_media_SyncParams.cpp index d9b2f1d7f43c..2d9738d8a34f 100644 --- a/media/jni/android_media_SyncParams.cpp +++ b/media/jni/android_media_SyncParams.cpp @@ -16,7 +16,7 @@ #include "android_media_SyncParams.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> namespace android { diff --git a/media/jni/android_media_Utils.h b/media/jni/android_media_Utils.h index af2f2d7bbe5d..821c6b25c333 100644 --- a/media/jni/android_media_Utils.h +++ b/media/jni/android_media_Utils.h @@ -23,7 +23,7 @@ #include <android_runtime/AndroidRuntime.h> #include <gui/CpuConsumer.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <utils/KeyedVector.h> #include <utils/String8.h> #include <SkStream.h> diff --git a/media/jni/android_mtp_MtpDatabase.cpp b/media/jni/android_mtp_MtpDatabase.cpp index f7f791696dd3..cf4458a6fd49 100644 --- a/media/jni/android_mtp_MtpDatabase.cpp +++ b/media/jni/android_mtp_MtpDatabase.cpp @@ -39,7 +39,7 @@ extern "C" { #include <android_runtime/AndroidRuntime.h> #include <android_runtime/Log.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <nativehelper/ScopedLocalRef.h> #include <assert.h> diff --git a/media/jni/android_mtp_MtpDevice.cpp b/media/jni/android_mtp_MtpDevice.cpp index 1faa0c472b2e..6b7e7bbcd6fc 100644 --- a/media/jni/android_mtp_MtpDevice.cpp +++ b/media/jni/android_mtp_MtpDevice.cpp @@ -29,8 +29,8 @@ #include <string> #include "jni.h" -#include "JNIHelp.h" -#include "ScopedPrimitiveArray.h" +#include <nativehelper/JNIHelp.h> +#include <nativehelper/ScopedPrimitiveArray.h> #include "android_runtime/AndroidRuntime.h" #include "android_runtime/Log.h" diff --git a/media/jni/android_mtp_MtpServer.cpp b/media/jni/android_mtp_MtpServer.cpp index c325f4ef078b..e9e93099c1e2 100644 --- a/media/jni/android_mtp_MtpServer.cpp +++ b/media/jni/android_mtp_MtpServer.cpp @@ -25,7 +25,7 @@ #include <utils/threads.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" #include "private/android_filesystem_config.h" diff --git a/media/jni/audioeffect/android_media_AudioEffect.cpp b/media/jni/audioeffect/android_media_AudioEffect.cpp index a9b7062509b2..17c18b7727a0 100644 --- a/media/jni/audioeffect/android_media_AudioEffect.cpp +++ b/media/jni/audioeffect/android_media_AudioEffect.cpp @@ -20,12 +20,12 @@ #define LOG_TAG "AudioEffects-JNI" #include <utils/Log.h> -#include <nativehelper/jni.h> +#include <jni.h> #include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include "media/AudioEffect.h" -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> using namespace android; diff --git a/media/jni/audioeffect/android_media_Visualizer.cpp b/media/jni/audioeffect/android_media_Visualizer.cpp index 0645543d4a74..b7d7b0339376 100644 --- a/media/jni/audioeffect/android_media_Visualizer.cpp +++ b/media/jni/audioeffect/android_media_Visualizer.cpp @@ -20,13 +20,13 @@ #define LOG_TAG "visualizers-JNI" #include <utils/Log.h> -#include <nativehelper/jni.h> +#include <jni.h> #include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/threads.h> #include "media/Visualizer.h" -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> using namespace android; diff --git a/media/jni/soundpool/android_media_SoundPool.cpp b/media/jni/soundpool/android_media_SoundPool.cpp index ab3e3408bcac..703a0158a13f 100644 --- a/media/jni/soundpool/android_media_SoundPool.cpp +++ b/media/jni/soundpool/android_media_SoundPool.cpp @@ -20,7 +20,7 @@ #define LOG_TAG "SoundPool-JNI" #include <utils/Log.h> -#include <nativehelper/jni.h> +#include <jni.h> #include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include "SoundPool.h" diff --git a/native/android/asset_manager.cpp b/native/android/asset_manager.cpp index 0e5e5c60d506..98e9a42d944d 100644 --- a/native/android/asset_manager.cpp +++ b/native/android/asset_manager.cpp @@ -24,7 +24,7 @@ #include <utils/threads.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> using namespace android; diff --git a/packages/DefaultContainerService/jni/com_android_defcontainer_MeasurementUtils.cpp b/packages/DefaultContainerService/jni/com_android_defcontainer_MeasurementUtils.cpp index 6be48491ef10..53cdc9d96b43 100644 --- a/packages/DefaultContainerService/jni/com_android_defcontainer_MeasurementUtils.cpp +++ b/packages/DefaultContainerService/jni/com_android_defcontainer_MeasurementUtils.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "DefContainer-JNI" -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <diskusage/dirsize.h> #include <utils/Log.h> diff --git a/packages/PrintSpooler/jni/com_android_printspooler_util_BitmapSerializeUtils.cpp b/packages/PrintSpooler/jni/com_android_printspooler_util_BitmapSerializeUtils.cpp index 1ce3949bbb81..7ff9cedab5f7 100644 --- a/packages/PrintSpooler/jni/com_android_printspooler_util_BitmapSerializeUtils.cpp +++ b/packages/PrintSpooler/jni/com_android_printspooler_util_BitmapSerializeUtils.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "BitmapSerializeUtils" #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <android/bitmap.h> #include <android/log.h> diff --git a/packages/services/PacProcessor/jni/com_android_pacprocessor_PacNative.cpp b/packages/services/PacProcessor/jni/com_android_pacprocessor_PacNative.cpp index 990d7707cdfb..846ff2517d12 100644 --- a/packages/services/PacProcessor/jni/com_android_pacprocessor_PacNative.cpp +++ b/packages/services/PacProcessor/jni/com_android_pacprocessor_PacNative.cpp @@ -21,7 +21,7 @@ #include "android_runtime/AndroidRuntime.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "proxy_resolver_v8.h" diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp index b4630efe80e8..d45d1678491d 100644 --- a/rs/jni/android_renderscript_RenderScript.cpp +++ b/rs/jni/android_renderscript_RenderScript.cpp @@ -29,7 +29,7 @@ #include <androidfw/ResourceTypes.h> #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" #include "android_runtime/android_view_Surface.h" #include "android_runtime/android_util_AssetManager.h" diff --git a/services/core/java/com/android/server/EventLogTags.logtags b/services/core/java/com/android/server/EventLogTags.logtags index 6296375525a4..cfd7242c0198 100644 --- a/services/core/java/com/android/server/EventLogTags.logtags +++ b/services/core/java/com/android/server/EventLogTags.logtags @@ -264,3 +264,16 @@ option java_package com.android.server # GestureLauncherService.java # --------------------------- 40100 camera_gesture_triggered (gesture_on_time|2|3), (sensor1_on_time|2|3), (sensor2_on_time|2|3), (event_extra|1|1) + +# --------------------------- +# timezone/RulesManagerService.java +# --------------------------- +51600 timezone_trigger_check (token|3) +51610 timezone_request_install (token|3) +51611 timezone_install_started (token|3) +51612 timezone_install_complete (token|3), (result|1) +51620 timezone_request_uninstall (token|3) +51621 timezone_uninstall_started (token|3) +51622 timezone_uninstall_complete (token|3), (result|1) +51630 timezone_request_nothing (token|3) +51631 timezone_nothing_complete (token|3) diff --git a/services/core/java/com/android/server/IpSecService.java b/services/core/java/com/android/server/IpSecService.java index b88bbc1bdd69..f72cbc9d68af 100644 --- a/services/core/java/com/android/server/IpSecService.java +++ b/services/core/java/com/android/server/IpSecService.java @@ -46,6 +46,7 @@ import android.util.Log; import android.util.Slog; import android.util.SparseArray; import com.android.internal.annotations.GuardedBy; +import com.android.internal.annotations.VisibleForTesting; import java.io.FileDescriptor; import java.io.IOException; import java.io.PrintWriter; @@ -64,7 +65,7 @@ public class IpSecService extends IIpSecService.Stub { private static final int[] DIRECTIONS = new int[] {IpSecTransform.DIRECTION_OUT, IpSecTransform.DIRECTION_IN}; - private static final int NETD_FETCH_TIMEOUT = 5000; //ms + private static final int NETD_FETCH_TIMEOUT_MS = 5000; // ms private static final int MAX_PORT_BIND_ATTEMPTS = 10; private static final InetAddress INADDR_ANY; @@ -96,6 +97,24 @@ public class IpSecService extends IIpSecService.Stub { private final ManagedResourceArray<UdpSocketRecord> mUdpSocketRecords = new ManagedResourceArray<>(); + interface IpSecServiceConfiguration { + INetd getNetdInstance() throws RemoteException; + + static IpSecServiceConfiguration GETSRVINSTANCE = + new IpSecServiceConfiguration() { + @Override + public INetd getNetdInstance() throws RemoteException { + final INetd netd = NetdService.getInstance(); + if (netd == null) { + throw new RemoteException("Failed to Get Netd Instance"); + } + return netd; + } + }; + } + + private final IpSecServiceConfiguration mSrvConfig; + /** * The ManagedResource class provides a facility to cleanly and reliably release system * resources. It relies on two things: an IBinder that allows ManagedResource to automatically @@ -198,15 +217,18 @@ public class IpSecService extends IIpSecService.Stub { }; /** - * Minimal wrapper around SparseArray that performs ownership - * validation on element accesses. + * Minimal wrapper around SparseArray that performs ownership validation on element accesses. */ private class ManagedResourceArray<T extends ManagedResource> { SparseArray<T> mArray = new SparseArray<>(); T get(int key) { T val = mArray.get(key); - val.checkOwnerOrSystemAndThrow(); + // The value should never be null unless the resource doesn't exist + // (since we do not allow null resources to be added). + if (val != null) { + val.checkOwnerOrSystemAndThrow(); + } return val; } @@ -260,7 +282,8 @@ public class IpSecService extends IIpSecService.Stub { for (int direction : DIRECTIONS) { int spi = mSpis[direction].getSpi(); try { - getNetdInstance() + mSrvConfig + .getNetdInstance() .ipSecDeleteSecurityAssociation( mResourceId, direction, @@ -324,7 +347,8 @@ public class IpSecService extends IIpSecService.Stub { } try { - getNetdInstance() + mSrvConfig + .getNetdInstance() .ipSecDeleteSecurityAssociation( mResourceId, mDirection, mLocalAddress, mRemoteAddress, mSpi); } catch (ServiceSpecificException e) { @@ -383,7 +407,7 @@ public class IpSecService extends IIpSecService.Stub { * @param context Binder context for this service */ private IpSecService(Context context) { - mContext = context; + this(context, IpSecServiceConfiguration.GETSRVINSTANCE); } static IpSecService create(Context context) throws InterruptedException { @@ -392,6 +416,13 @@ public class IpSecService extends IIpSecService.Stub { return service; } + /** @hide */ + @VisibleForTesting + public IpSecService(Context context, IpSecServiceConfiguration config) { + mContext = context; + mSrvConfig = config; + } + public void systemReady() { if (isNetdAlive()) { Slog.d(TAG, "IpSecService is ready"); @@ -402,30 +433,19 @@ public class IpSecService extends IIpSecService.Stub { private void connectNativeNetdService() { // Avoid blocking the system server to do this - Thread t = - new Thread( - new Runnable() { - @Override - public void run() { - synchronized (IpSecService.this) { - NetdService.get(NETD_FETCH_TIMEOUT); - } - } - }); - t.run(); - } - - INetd getNetdInstance() throws RemoteException { - final INetd netd = NetdService.getInstance(); - if (netd == null) { - throw new RemoteException("Failed to Get Netd Instance"); - } - return netd; + new Thread() { + @Override + public void run() { + synchronized (IpSecService.this) { + NetdService.get(NETD_FETCH_TIMEOUT_MS); + } + } + }.start(); } synchronized boolean isNetdAlive() { try { - final INetd netd = getNetdInstance(); + final INetd netd = mSrvConfig.getNetdInstance(); if (netd == null) { return false; } @@ -446,7 +466,8 @@ public class IpSecService extends IIpSecService.Stub { String localAddress = ""; try { spi = - getNetdInstance() + mSrvConfig + .getNetdInstance() .ipSecAllocateSpi( resourceId, direction, @@ -605,7 +626,7 @@ public class IpSecService extends IIpSecService.Stub { spis[direction] = mSpiRecords.get(c.getSpiResourceId(direction)); int spi = spis[direction].getSpi(); try { - getNetdInstance() + mSrvConfig.getNetdInstance() .ipSecAddSecurityAssociation( resourceId, c.getMode(), @@ -675,7 +696,8 @@ public class IpSecService extends IIpSecService.Stub { IpSecConfig c = info.getConfig(); try { for (int direction : DIRECTIONS) { - getNetdInstance() + mSrvConfig + .getNetdInstance() .ipSecApplyTransportModeTransform( socket.getFileDescriptor(), resourceId, @@ -703,7 +725,9 @@ public class IpSecService extends IIpSecService.Stub { public void removeTransportModeTransform(ParcelFileDescriptor socket, int resourceId) throws RemoteException { try { - getNetdInstance().ipSecRemoveTransportModeTransform(socket.getFileDescriptor()); + mSrvConfig + .getNetdInstance() + .ipSecRemoveTransportModeTransform(socket.getFileDescriptor()); } catch (ServiceSpecificException e) { // FIXME: get the error code and throw is at an IOException from Errno Exception } diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java index 15932cc2ee0c..aaec642ab4e2 100644 --- a/services/core/java/com/android/server/NetworkManagementService.java +++ b/services/core/java/com/android/server/NetworkManagementService.java @@ -18,6 +18,7 @@ package com.android.server; import static android.Manifest.permission.CONNECTIVITY_INTERNAL; import static android.Manifest.permission.DUMP; +import static android.Manifest.permission.NETWORK_STACK; import static android.Manifest.permission.SHUTDOWN; import static android.net.NetworkPolicyManager.FIREWALL_CHAIN_DOZABLE; import static android.net.NetworkPolicyManager.FIREWALL_CHAIN_NAME_DOZABLE; @@ -53,6 +54,7 @@ import android.content.Context; import android.net.ConnectivityManager; import android.net.INetd; import android.net.INetworkManagementEventObserver; +import android.net.ITetheringStatsProvider; import android.net.InterfaceConfiguration; import android.net.IpPrefix; import android.net.LinkAddress; @@ -220,6 +222,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub private final NetworkStatsFactory mStatsFactory = new NetworkStatsFactory(); + @GuardedBy("mTetheringStatsProviders") + private final HashMap<ITetheringStatsProvider, String> + mTetheringStatsProviders = Maps.newHashMap(); + private final Object mQuotaLock = new Object(); /** Set of interfaces with active quotas. */ @@ -319,6 +325,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub // Add ourself to the Watchdog monitors. Watchdog.getInstance().addMonitor(this); + + synchronized (mTetheringStatsProviders) { + mTetheringStatsProviders.put(new NetdTetheringStatsProvider(), "netd"); + } } static NetworkManagementService create(Context context, String socket) @@ -499,6 +509,23 @@ public class NetworkManagementService extends INetworkManagementService.Stub } } + @Override + public void registerTetheringStatsProvider(ITetheringStatsProvider provider, String name) { + mContext.enforceCallingOrSelfPermission(NETWORK_STACK, TAG); + Preconditions.checkNotNull(provider); + synchronized(mTetheringStatsProviders) { + mTetheringStatsProviders.put(provider, name); + } + } + + @Override + public void unregisterTetheringStatsProvider(ITetheringStatsProvider provider) { + mContext.enforceCallingOrSelfPermission(NETWORK_STACK, TAG); + synchronized(mTetheringStatsProviders) { + mTetheringStatsProviders.remove(provider); + } + } + // Sync the state of the given chain with the native daemon. private void syncFirewallChainLocked(int chain, SparseIntArray uidFirewallRules, String name) { int size = uidFirewallRules.size(); @@ -1748,14 +1775,16 @@ public class NetworkManagementService extends INetworkManagementService.Stub } } - @Override - public NetworkStats getNetworkStatsTethering() { - mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - - final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 1); - try { - final NativeDaemonEvent[] events = mConnector.executeForList( - "bandwidth", "gettetherstats"); + private class NetdTetheringStatsProvider extends ITetheringStatsProvider.Stub { + @Override + public NetworkStats getTetherStats() { + final NativeDaemonEvent[] events; + try { + events = mConnector.executeForList("bandwidth", "gettetherstats"); + } catch (NativeDaemonConnectorException e) { + throw e.rethrowAsParcelableException(); + } + final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 1); for (NativeDaemonEvent event : events) { if (event.getCode() != TetheringStatsListResult) continue; @@ -1781,8 +1810,24 @@ public class NetworkManagementService extends INetworkManagementService.Stub throw new IllegalStateException("problem parsing tethering stats: " + event); } } - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + return stats; + } + } + + @Override + public NetworkStats getNetworkStatsTethering() { + mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); + + final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 1); + synchronized (mTetheringStatsProviders) { + for (ITetheringStatsProvider provider: mTetheringStatsProviders.keySet()) { + try { + stats.combineAllValues(provider.getTetherStats()); + } catch (RemoteException e) { + Log.e(TAG, "Problem reading tethering stats from " + + mTetheringStatsProviders.get(provider) + ": " + e); + } + } } return stats; } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index c5fc038028e2..867a7cbe6b49 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -16447,23 +16447,41 @@ public final class ActivityManagerService extends ActivityManagerNative ArrayList<MemItem> catMems = new ArrayList<MemItem>(); catMems.add(new MemItem("Native", "Native", nativePss, nativeSwapPss, -1)); - final MemItem dalvikItem = - new MemItem("Dalvik", "Dalvik", dalvikPss, dalvikSwapPss, -2); - if (dalvikSubitemPss.length > 0) { - dalvikItem.subitems = new ArrayList<MemItem>(); - for (int j=0; j<dalvikSubitemPss.length; j++) { - final String name = Debug.MemoryInfo.getOtherLabel( - Debug.MemoryInfo.NUM_OTHER_STATS + j); - dalvikItem.subitems.add(new MemItem(name, name, dalvikSubitemPss[j], - dalvikSubitemSwapPss[j], j)); - } - } - catMems.add(dalvikItem); + final int dalvikId = -2; + catMems.add(new MemItem("Dalvik", "Dalvik", dalvikPss, dalvikSwapPss, dalvikId)); catMems.add(new MemItem("Unknown", "Unknown", otherPss, otherSwapPss, -3)); for (int j=0; j<Debug.MemoryInfo.NUM_OTHER_STATS; j++) { String label = Debug.MemoryInfo.getOtherLabel(j); catMems.add(new MemItem(label, label, miscPss[j], miscSwapPss[j], j)); } + if (dalvikSubitemPss.length > 0) { + // Add dalvik subitems. + for (MemItem memItem : catMems) { + int memItemStart = 0, memItemEnd = 0; + if (memItem.id == dalvikId) { + memItemStart = Debug.MemoryInfo.OTHER_DVK_STAT_DALVIK_START; + memItemEnd = Debug.MemoryInfo.OTHER_DVK_STAT_DALVIK_END; + } else if (memItem.id == Debug.MemoryInfo.OTHER_DALVIK_OTHER) { + memItemStart = Debug.MemoryInfo.OTHER_DVK_STAT_DALVIK_OTHER_START; + memItemEnd = Debug.MemoryInfo.OTHER_DVK_STAT_DALVIK_OTHER_END; + } else if (memItem.id == Debug.MemoryInfo.OTHER_DEX) { + memItemStart = Debug.MemoryInfo.OTHER_DVK_STAT_DEX_START; + memItemEnd = Debug.MemoryInfo.OTHER_DVK_STAT_DEX_END; + } else if (memItem.id == Debug.MemoryInfo.OTHER_ART) { + memItemStart = Debug.MemoryInfo.OTHER_DVK_STAT_ART_START; + memItemEnd = Debug.MemoryInfo.OTHER_DVK_STAT_ART_END; + } else { + continue; // No subitems, continue. + } + memItem.subitems = new ArrayList<MemItem>(); + for (int j=memItemStart; j<=memItemEnd; j++) { + final String name = Debug.MemoryInfo.getOtherLabel( + Debug.MemoryInfo.NUM_OTHER_STATS + j); + memItem.subitems.add(new MemItem(name, name, dalvikSubitemPss[j], + dalvikSubitemSwapPss[j], j)); + } + } + } ArrayList<MemItem> oomMems = new ArrayList<MemItem>(); for (int j=0; j<oomPss.length; j++) { @@ -21749,6 +21767,9 @@ public final class ActivityManagerService extends ActivityManagerNative } if (DEBUG_PSS) Slog.d(TAG_PSS, "Dump heap finished for " + path); mHandler.sendEmptyMessage(POST_DUMP_HEAP_NOTIFICATION_MSG); + + // Forced gc to clean up the remnant hprof fd. + Runtime.getRuntime().gc(); } } diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java index 3a4e07e96ad7..5ea6636db861 100644 --- a/services/core/java/com/android/server/connectivity/Tethering.java +++ b/services/core/java/com/android/server/connectivity/Tethering.java @@ -211,7 +211,7 @@ public class Tethering extends BaseNetworkObserver { final Handler smHandler = mTetherMasterSM.getHandler(); mOffloadController = new OffloadController(smHandler, deps.getOffloadHardwareInterface(smHandler, mLog), - mContext.getContentResolver(), + mContext.getContentResolver(), mNMService, mLog); mUpstreamNetworkMonitor = new UpstreamNetworkMonitor( mContext, mTetherMasterSM, mLog, TetherMasterSM.EVENT_UPSTREAM_CALLBACK); @@ -1755,6 +1755,11 @@ public class Tethering extends BaseNetworkObserver { pw.decreaseIndent(); } + pw.println("Hardware offload:"); + pw.increaseIndent(); + mOffloadController.dump(pw); + pw.decreaseIndent(); + pw.println("Log:"); pw.increaseIndent(); if (argsContain(args, SHORT_ARG)) { diff --git a/services/core/java/com/android/server/connectivity/tethering/OffloadController.java b/services/core/java/com/android/server/connectivity/tethering/OffloadController.java index b47386705a36..1a5ff778010c 100644 --- a/services/core/java/com/android/server/connectivity/tethering/OffloadController.java +++ b/services/core/java/com/android/server/connectivity/tethering/OffloadController.java @@ -16,24 +16,38 @@ package com.android.server.connectivity.tethering; +import static android.net.NetworkStats.SET_DEFAULT; +import static android.net.NetworkStats.TAG_NONE; +import static android.net.TrafficStats.UID_TETHERING; import static android.provider.Settings.Global.TETHER_OFFLOAD_DISABLED; import android.content.ContentResolver; +import android.net.ITetheringStatsProvider; import android.net.IpPrefix; import android.net.LinkAddress; import android.net.LinkProperties; +import android.net.NetworkStats; import android.net.RouteInfo; import android.net.util.SharedLog; import android.os.Handler; +import android.os.INetworkManagementService; +import android.os.RemoteException; +import android.os.SystemClock; import android.provider.Settings; +import android.text.TextUtils; + +import com.android.internal.util.IndentingPrintWriter; import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.Objects; import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; /** * A class to encapsulate the business logic of programming the tethering @@ -44,6 +58,8 @@ import java.util.Set; public class OffloadController { private static final String TAG = OffloadController.class.getSimpleName(); + private static final int STATS_FETCH_TIMEOUT_MS = 1000; + private final Handler mHandler; private final OffloadHardwareInterface mHwInterface; private final ContentResolver mContentResolver; @@ -59,14 +75,25 @@ public class OffloadController { // prefixes representing only the locally-assigned IP addresses. private Set<String> mLastLocalPrefixStrs; + // Maps upstream interface names to offloaded traffic statistics. + private HashMap<String, OffloadHardwareInterface.ForwardedStats> + mForwardedStats = new HashMap<>(); + public OffloadController(Handler h, OffloadHardwareInterface hwi, - ContentResolver contentResolver, SharedLog log) { + ContentResolver contentResolver, INetworkManagementService nms, SharedLog log) { mHandler = h; mHwInterface = hwi; mContentResolver = contentResolver; mLog = log.forSubComponent(TAG); mExemptPrefixes = new HashSet<>(); mLastLocalPrefixStrs = new HashSet<>(); + + try { + nms.registerTetheringStatsProvider( + new OffloadTetheringStatsProvider(), getClass().getSimpleName()); + } catch (RemoteException e) { + mLog.e("Cannot register offload stats provider: " + e); + } } public void start() { @@ -138,6 +165,7 @@ public class OffloadController { public void stop() { final boolean wasStarted = started(); + updateStatsForCurrentUpstream(); mUpstreamLinkProperties = null; mHwInterface.stopOffloadControl(); mControlInitialized = false; @@ -145,16 +173,76 @@ public class OffloadController { if (wasStarted) mLog.log("tethering offload stopped"); } + private class OffloadTetheringStatsProvider extends ITetheringStatsProvider.Stub { + @Override + public NetworkStats getTetherStats() { + NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 0); + CountDownLatch latch = new CountDownLatch(1); + + mHandler.post(() -> { + try { + NetworkStats.Entry entry = new NetworkStats.Entry(); + entry.set = SET_DEFAULT; + entry.tag = TAG_NONE; + entry.uid = UID_TETHERING; + + updateStatsForCurrentUpstream(); + + for (String iface : mForwardedStats.keySet()) { + entry.iface = iface; + entry.rxBytes = mForwardedStats.get(iface).rxBytes; + entry.txBytes = mForwardedStats.get(iface).txBytes; + stats.addValues(entry); + } + } finally { + latch.countDown(); + } + }); + + try { + latch.await(STATS_FETCH_TIMEOUT_MS, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + mLog.e("Tethering stats fetch timed out after " + STATS_FETCH_TIMEOUT_MS + "ms"); + } + + return stats; + } + } + + private void maybeUpdateStats(String iface) { + if (TextUtils.isEmpty(iface)) { + return; + } + + if (!mForwardedStats.containsKey(iface)) { + mForwardedStats.put(iface, new OffloadHardwareInterface.ForwardedStats()); + } + mForwardedStats.get(iface).add(mHwInterface.getForwardedStats(iface)); + } + + private void updateStatsForCurrentUpstream() { + if (mUpstreamLinkProperties != null) { + maybeUpdateStats(mUpstreamLinkProperties.getInterfaceName()); + } + } + public void setUpstreamLinkProperties(LinkProperties lp) { if (!started() || Objects.equals(mUpstreamLinkProperties, lp)) return; + String prevUpstream = (mUpstreamLinkProperties != null) ? + mUpstreamLinkProperties.getInterfaceName() : null; + mUpstreamLinkProperties = (lp != null) ? new LinkProperties(lp) : null; + // TODO: examine return code and decide what to do if programming // upstream parameters fails (probably just wait for a subsequent // onOffloadEvent() callback to tell us offload is available again and // then reapply all state). computeAndPushLocalPrefixes(); pushUpstreamParameters(); + + // Update stats after we've told the hardware to change routing so we don't miss packets. + maybeUpdateStats(prevUpstream); } public void setLocalPrefixes(Set<IpPrefix> localPrefixes) { @@ -262,4 +350,16 @@ public class OffloadController { for (IpPrefix pfx : prefixSet) localPrefixStrs.add(pfx.toString()); return localPrefixStrs; } + + public void dump(IndentingPrintWriter pw) { + if (isOffloadDisabled()) { + pw.println("Offload disabled"); + return; + } + pw.println("Offload HALs " + (started() ? "started" : "not started")); + LinkProperties lp = mUpstreamLinkProperties; + String upstream = (lp != null) ? lp.getInterfaceName() : null; + pw.println("Current upstream: " + upstream); + pw.println("Exempt prefixes: " + mLastLocalPrefixStrs); + } } diff --git a/services/core/java/com/android/server/timezone/IntentHelperImpl.java b/services/core/java/com/android/server/timezone/IntentHelperImpl.java index 3ffbb2d61fd5..11928b964ec5 100644 --- a/services/core/java/com/android/server/timezone/IntentHelperImpl.java +++ b/services/core/java/com/android/server/timezone/IntentHelperImpl.java @@ -16,6 +16,8 @@ package com.android.server.timezone; +import com.android.server.EventLogTags; + import android.app.timezone.RulesUpdaterContract; import android.content.BroadcastReceiver; import android.content.Context; @@ -24,8 +26,6 @@ import android.content.IntentFilter; import android.os.PatternMatcher; import android.util.Slog; -import java.util.regex.Pattern; - /** * The bona fide implementation of {@link IntentHelper}. */ @@ -75,6 +75,7 @@ final class IntentHelperImpl implements IntentHelper { public void sendTriggerUpdateCheck(CheckToken checkToken) { RulesUpdaterContract.sendBroadcast( mContext, mUpdaterAppPackageName, checkToken.toByteArray()); + EventLogTags.writeTimezoneTriggerCheck(checkToken.toString()); } @Override diff --git a/services/core/java/com/android/server/timezone/PackageStatusStorage.java b/services/core/java/com/android/server/timezone/PackageStatusStorage.java index fe82dc4f1572..cac7f7b811bf 100644 --- a/services/core/java/com/android/server/timezone/PackageStatusStorage.java +++ b/services/core/java/com/android/server/timezone/PackageStatusStorage.java @@ -16,6 +16,7 @@ package com.android.server.timezone; +import com.android.internal.annotations.GuardedBy; import com.android.internal.util.FastXmlSerializer; import org.xmlpull.v1.XmlPullParser; @@ -80,7 +81,7 @@ final class PackageStatusStorage { private final AtomicFile mPackageStatusFile; PackageStatusStorage(File storageDir) { - mPackageStatusFile = new AtomicFile(new File(storageDir, "packageStatus.xml")); + mPackageStatusFile = new AtomicFile(new File(storageDir, "package-status.xml")); if (!mPackageStatusFile.getBaseFile().exists()) { try { insertInitialPackageStatus(); @@ -103,7 +104,7 @@ final class PackageStatusStorage { PackageStatus getPackageStatus() { synchronized (this) { try { - return getPackageStatusInternal(); + return getPackageStatusLocked(); } catch (ParseException e) { // This means that data exists in the file but it was bad. Slog.e(LOG_TAG, "Package status invalid, resetting and retrying", e); @@ -111,7 +112,7 @@ final class PackageStatusStorage { // Reset the storage so it is in a good state again. recoverFromBadData(e); try { - return getPackageStatusInternal(); + return getPackageStatusLocked(); } catch (ParseException e2) { throw new IllegalStateException("Recovery from bad file failed", e2); } @@ -119,7 +120,8 @@ final class PackageStatusStorage { } } - private PackageStatus getPackageStatusInternal() throws ParseException { + @GuardedBy("this") + private PackageStatus getPackageStatusLocked() throws ParseException { try (FileInputStream fis = mPackageStatusFile.openRead()) { XmlPullParser parser = parseToPackageStatusTag(fis); Integer checkStatus = getNullableIntAttribute(parser, ATTRIBUTE_CHECK_STATUS); @@ -137,7 +139,7 @@ final class PackageStatusStorage { } } - // Callers should be synchronized(this). + @GuardedBy("this") private int recoverFromBadData(Exception cause) { mPackageStatusFile.delete(); try { @@ -155,7 +157,7 @@ final class PackageStatusStorage { // is reset to ensure that old tokens are unlikely to work. final int initialOptimisticLockId = (int) System.currentTimeMillis(); - writePackageStatusInternal(null /* status */, initialOptimisticLockId, + writePackageStatusLocked(null /* status */, initialOptimisticLockId, null /* packageVersions */); return initialOptimisticLockId; } @@ -243,7 +245,7 @@ final class PackageStatusStorage { } } - // Caller should be synchronized(this). + @GuardedBy("this") private int getCurrentOptimisticLockId() throws ParseException { try (FileInputStream fis = mPackageStatusFile.openRead()) { XmlPullParser parser = parseToPackageStatusTag(fis); @@ -278,7 +280,7 @@ final class PackageStatusStorage { } } - // Caller should be synchronized(this). + @GuardedBy("this") private boolean writePackageStatusWithOptimisticLockCheck(int optimisticLockId, int newOptimisticLockId, Integer status, PackageVersions packageVersions) throws IOException { @@ -294,12 +296,12 @@ final class PackageStatusStorage { return false; } - writePackageStatusInternal(status, newOptimisticLockId, packageVersions); + writePackageStatusLocked(status, newOptimisticLockId, packageVersions); return true; } - // Caller should be synchronized(this). - private void writePackageStatusInternal(Integer status, int optimisticLockId, + @GuardedBy("this") + private void writePackageStatusLocked(Integer status, int optimisticLockId, PackageVersions packageVersions) throws IOException { if ((status == null) != (packageVersions == null)) { throw new IllegalArgumentException( diff --git a/services/core/java/com/android/server/timezone/RulesManagerService.java b/services/core/java/com/android/server/timezone/RulesManagerService.java index d97ba2d0d78b..1c5aa600580a 100644 --- a/services/core/java/com/android/server/timezone/RulesManagerService.java +++ b/services/core/java/com/android/server/timezone/RulesManagerService.java @@ -17,6 +17,7 @@ package com.android.server.timezone; import com.android.internal.annotations.VisibleForTesting; +import com.android.server.EventLogTags; import com.android.server.SystemService; import com.android.timezone.distro.DistroException; import com.android.timezone.distro.DistroVersion; @@ -56,8 +57,6 @@ import static android.app.timezone.RulesState.STAGED_OPERATION_NONE; import static android.app.timezone.RulesState.STAGED_OPERATION_UNINSTALL; import static android.app.timezone.RulesState.STAGED_OPERATION_UNKNOWN; -// TODO(nfuller) Add EventLog calls where useful in the system server. -// TODO(nfuller) Check logging best practices in the system server. // TODO(nfuller) Check error handling best practices in the system server. public final class RulesManagerService extends IRulesManager.Stub { @@ -203,6 +202,7 @@ public final class RulesManagerService extends IRulesManager.Stub { if (checkTokenBytes != null) { checkToken = createCheckTokenOrThrow(checkTokenBytes); } + EventLogTags.writeTimezoneRequestInstall(toStringOrNull(checkToken)); synchronized (this) { if (distroParcelFileDescriptor == null) { @@ -254,6 +254,8 @@ public final class RulesManagerService extends IRulesManager.Stub { @Override public void run() { + EventLogTags.writeTimezoneInstallStarted(toStringOrNull(mCheckToken)); + boolean success = false; // Adopt the ParcelFileDescriptor into this try-with-resources so it is closed // when we are done. @@ -266,6 +268,7 @@ public final class RulesManagerService extends IRulesManager.Stub { TimeZoneDistro distro = new TimeZoneDistro(is); int installerResult = mInstaller.stageInstallWithErrorCode(distro); int resultCode = mapInstallerResultToApiCode(installerResult); + EventLogTags.writeTimezoneInstallComplete(toStringOrNull(mCheckToken), resultCode); sendFinishedStatus(mCallback, resultCode); // All the installer failure modes are currently non-recoverable and won't be @@ -273,6 +276,8 @@ public final class RulesManagerService extends IRulesManager.Stub { success = true; } catch (Exception e) { Slog.w(TAG, "Failed to install distro.", e); + EventLogTags.writeTimezoneInstallComplete( + toStringOrNull(mCheckToken), Callback.ERROR_UNKNOWN_FAILURE); sendFinishedStatus(mCallback, Callback.ERROR_UNKNOWN_FAILURE); } finally { // Notify the package tracker that the operation is now complete. @@ -308,6 +313,7 @@ public final class RulesManagerService extends IRulesManager.Stub { if (checkTokenBytes != null) { checkToken = createCheckTokenOrThrow(checkTokenBytes); } + EventLogTags.writeTimezoneRequestUninstall(toStringOrNull(checkToken)); synchronized(this) { if (callback == null) { throw new NullPointerException("callback == null"); @@ -337,6 +343,7 @@ public final class RulesManagerService extends IRulesManager.Stub { @Override public void run() { + EventLogTags.writeTimezoneUninstallStarted(toStringOrNull(mCheckToken)); boolean success = false; try { success = mInstaller.stageUninstall(); @@ -344,8 +351,12 @@ public final class RulesManagerService extends IRulesManager.Stub { // against SUCCESS. More granular failures may be added in future. int resultCode = success ? Callback.SUCCESS : Callback.ERROR_UNKNOWN_FAILURE; + EventLogTags.writeTimezoneUninstallComplete( + toStringOrNull(mCheckToken), resultCode); sendFinishedStatus(mCallback, resultCode); } catch (Exception e) { + EventLogTags.writeTimezoneUninstallComplete( + toStringOrNull(mCheckToken), Callback.ERROR_UNKNOWN_FAILURE); Slog.w(TAG, "Failed to uninstall distro.", e); sendFinishedStatus(mCallback, Callback.ERROR_UNKNOWN_FAILURE); } finally { @@ -372,7 +383,9 @@ public final class RulesManagerService extends IRulesManager.Stub { if (checkTokenBytes != null) { checkToken = createCheckTokenOrThrow(checkTokenBytes); } + EventLogTags.writeTimezoneRequestNothing(toStringOrNull(checkToken)); mPackageTracker.recordCheckResult(checkToken, success); + EventLogTags.writeTimezoneNothingComplete(toStringOrNull(checkToken)); } @Override @@ -445,6 +458,7 @@ public final class RulesManagerService extends IRulesManager.Stub { pw.println("RulesManagerService state: " + toString()); pw.println("Active rules version (ICU, libcore): " + ICU.getTZDataVersion() + "," + ZoneInfoDB.getInstance().getVersion()); + pw.println("Distro state: " + rulesState.toString()); mPackageTracker.dump(pw); } @@ -491,4 +505,8 @@ public final class RulesManagerService extends IRulesManager.Stub { return "Unknown"; } } + + private static String toStringOrNull(Object obj) { + return obj == null ? null : obj.toString(); + } } diff --git a/services/core/java/com/android/server/timezone/RulesManagerServiceHelperImpl.java b/services/core/java/com/android/server/timezone/RulesManagerServiceHelperImpl.java index 767f0e0993ef..b89ce1cd0f89 100644 --- a/services/core/java/com/android/server/timezone/RulesManagerServiceHelperImpl.java +++ b/services/core/java/com/android/server/timezone/RulesManagerServiceHelperImpl.java @@ -18,6 +18,7 @@ package com.android.server.timezone; import android.content.Context; import android.content.pm.PackageManager; +import android.os.AsyncTask; import android.os.Binder; import android.os.ParcelFileDescriptor; @@ -56,10 +57,9 @@ final class RulesManagerServiceHelperImpl implements PermissionHelper, Executor return true; } - // TODO Wake lock required? + // TODO(nfuller): Wake lock required while running in background thread? @Override public void execute(Runnable runnable) { - // TODO Is there a better way? - new Thread(runnable).start(); + AsyncTask.execute(runnable); } } diff --git a/services/core/jni/com_android_server_AlarmManagerService.cpp b/services/core/jni/com_android_server_AlarmManagerService.cpp index 3a0273d8c3c8..bcb0b4fcbe0b 100644 --- a/services/core/jni/com_android_server_AlarmManagerService.cpp +++ b/services/core/jni/com_android_server_AlarmManagerService.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "AlarmManagerService" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include <utils/Log.h> #include <utils/misc.h> diff --git a/services/core/jni/com_android_server_HardwarePropertiesManagerService.cpp b/services/core/jni/com_android_server_HardwarePropertiesManagerService.cpp index 14d50ce957fe..701403b18c9a 100644 --- a/services/core/jni/com_android_server_HardwarePropertiesManagerService.cpp +++ b/services/core/jni/com_android_server_HardwarePropertiesManagerService.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "HardwarePropertiesManagerService-JNI" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include <stdlib.h> diff --git a/services/core/jni/com_android_server_PersistentDataBlockService.cpp b/services/core/jni/com_android_server_PersistentDataBlockService.cpp index f94e5d9d438c..97e69fb4bb40 100644 --- a/services/core/jni/com_android_server_PersistentDataBlockService.cpp +++ b/services/core/jni/com_android_server_PersistentDataBlockService.cpp @@ -15,9 +15,9 @@ */ #include <android_runtime/AndroidRuntime.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <jni.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> #include <utils/misc.h> #include <sys/ioctl.h> diff --git a/services/core/jni/com_android_server_SerialService.cpp b/services/core/jni/com_android_server_SerialService.cpp index 1bd7a599ed60..aef0b25503c8 100644 --- a/services/core/jni/com_android_server_SerialService.cpp +++ b/services/core/jni/com_android_server_SerialService.cpp @@ -18,7 +18,7 @@ #include "utils/Log.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" #include <sys/types.h> diff --git a/services/core/jni/com_android_server_SystemServer.cpp b/services/core/jni/com_android_server_SystemServer.cpp index e46490bb3fac..01da4df31a80 100644 --- a/services/core/jni/com_android_server_SystemServer.cpp +++ b/services/core/jni/com_android_server_SystemServer.cpp @@ -15,7 +15,7 @@ */ #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <sensorservice/SensorService.h> diff --git a/services/core/jni/com_android_server_UsbDeviceManager.cpp b/services/core/jni/com_android_server_UsbDeviceManager.cpp index 3733a55e7504..f37f87060fa6 100644 --- a/services/core/jni/com_android_server_UsbDeviceManager.cpp +++ b/services/core/jni/com_android_server_UsbDeviceManager.cpp @@ -18,7 +18,7 @@ #include "utils/Log.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" #include "android_runtime/Log.h" diff --git a/services/core/jni/com_android_server_UsbHostManager.cpp b/services/core/jni/com_android_server_UsbHostManager.cpp index 795f6aa6018a..eab3979846e3 100644 --- a/services/core/jni/com_android_server_UsbHostManager.cpp +++ b/services/core/jni/com_android_server_UsbHostManager.cpp @@ -18,7 +18,7 @@ #include "utils/Log.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" #include "android_runtime/Log.h" diff --git a/services/core/jni/com_android_server_UsbMidiDevice.cpp b/services/core/jni/com_android_server_UsbMidiDevice.cpp index e12a01661a44..79d935fe610c 100644 --- a/services/core/jni/com_android_server_UsbMidiDevice.cpp +++ b/services/core/jni/com_android_server_UsbMidiDevice.cpp @@ -19,7 +19,7 @@ #include "utils/Log.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" #include "android_runtime/Log.h" diff --git a/services/core/jni/com_android_server_VibratorService.cpp b/services/core/jni/com_android_server_VibratorService.cpp index 03fbd19094ba..d7e7c241bf3e 100644 --- a/services/core/jni/com_android_server_VibratorService.cpp +++ b/services/core/jni/com_android_server_VibratorService.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "VibratorService" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" #include <utils/misc.h> diff --git a/services/core/jni/com_android_server_am_BatteryStatsService.cpp b/services/core/jni/com_android_server_am_BatteryStatsService.cpp index 531f9462a98f..1d59762af5f8 100644 --- a/services/core/jni/com_android_server_am_BatteryStatsService.cpp +++ b/services/core/jni/com_android_server_am_BatteryStatsService.cpp @@ -31,8 +31,8 @@ #include <android_runtime/AndroidRuntime.h> #include <jni.h> -#include <ScopedLocalRef.h> -#include <ScopedPrimitiveArray.h> +#include <nativehelper/ScopedLocalRef.h> +#include <nativehelper/ScopedPrimitiveArray.h> #include <log/log.h> #include <utils/misc.h> diff --git a/services/core/jni/com_android_server_connectivity_Vpn.cpp b/services/core/jni/com_android_server_connectivity_Vpn.cpp index 4d85d9a558aa..b6bea11a66ea 100644 --- a/services/core/jni/com_android_server_connectivity_Vpn.cpp +++ b/services/core/jni/com_android_server_connectivity_Vpn.cpp @@ -38,7 +38,7 @@ #include "netutils/ifc.h" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> namespace android { diff --git a/services/core/jni/com_android_server_connectivity_tethering_OffloadHardwareInterface.cpp b/services/core/jni/com_android_server_connectivity_tethering_OffloadHardwareInterface.cpp index 4e5c27fca784..87312f82d58a 100644 --- a/services/core/jni/com_android_server_connectivity_tethering_OffloadHardwareInterface.cpp +++ b/services/core/jni/com_android_server_connectivity_tethering_OffloadHardwareInterface.cpp @@ -18,7 +18,7 @@ #include <error.h> #include <hidl/HidlSupport.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <linux/netfilter/nfnetlink.h> #include <linux/netlink.h> #include <sys/socket.h> diff --git a/services/core/jni/com_android_server_fingerprint_FingerprintService.cpp b/services/core/jni/com_android_server_fingerprint_FingerprintService.cpp index 39474ece0d21..503f0cf993d4 100644 --- a/services/core/jni/com_android_server_fingerprint_FingerprintService.cpp +++ b/services/core/jni/com_android_server_fingerprint_FingerprintService.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "Fingerprint-JNI" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include <inttypes.h> #include <android_runtime/AndroidRuntime.h> diff --git a/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp b/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp index a23fbcbd42c7..3f6295b9ecfe 100644 --- a/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp +++ b/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp @@ -18,8 +18,8 @@ #define LOG_NDEBUG 1 -#include <JNIHelp.h> -#include <ScopedPrimitiveArray.h> +#include <nativehelper/JNIHelp.h> +#include <nativehelper/ScopedPrimitiveArray.h> #include <cstring> diff --git a/services/core/jni/com_android_server_input_InputApplicationHandle.cpp b/services/core/jni/com_android_server_input_InputApplicationHandle.cpp index e927b6031841..232b2c2c8c86 100644 --- a/services/core/jni/com_android_server_input_InputApplicationHandle.cpp +++ b/services/core/jni/com_android_server_input_InputApplicationHandle.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "InputApplicationHandle" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include <android_runtime/AndroidRuntime.h> #include <utils/threads.h> diff --git a/services/core/jni/com_android_server_input_InputApplicationHandle.h b/services/core/jni/com_android_server_input_InputApplicationHandle.h index e6f25cce1f98..c9af711a7586 100644 --- a/services/core/jni/com_android_server_input_InputApplicationHandle.h +++ b/services/core/jni/com_android_server_input_InputApplicationHandle.h @@ -19,7 +19,7 @@ #include <inputflinger/InputApplication.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" namespace android { diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp index 6791da928b1b..151c8874759a 100644 --- a/services/core/jni/com_android_server_input_InputManagerService.cpp +++ b/services/core/jni/com_android_server_input_InputManagerService.cpp @@ -25,7 +25,7 @@ #define DEBUG_INPUT_DISPATCHER_POLICY 0 -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include <atomic> #include <cinttypes> @@ -50,9 +50,9 @@ #include <android_view_PointerIcon.h> #include <android/graphics/GraphicsJNI.h> -#include <ScopedLocalRef.h> -#include <ScopedPrimitiveArray.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedLocalRef.h> +#include <nativehelper/ScopedPrimitiveArray.h> +#include <nativehelper/ScopedUtfChars.h> #include "com_android_server_power_PowerManagerService.h" #include "com_android_server_input_InputApplicationHandle.h" diff --git a/services/core/jni/com_android_server_input_InputWindowHandle.cpp b/services/core/jni/com_android_server_input_InputWindowHandle.cpp index 197d05661976..2b2a6fac9b6a 100644 --- a/services/core/jni/com_android_server_input_InputWindowHandle.cpp +++ b/services/core/jni/com_android_server_input_InputWindowHandle.cpp @@ -16,7 +16,7 @@ #define LOG_TAG "InputWindowHandle" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include <android_runtime/AndroidRuntime.h> #include <utils/threads.h> diff --git a/services/core/jni/com_android_server_input_InputWindowHandle.h b/services/core/jni/com_android_server_input_InputWindowHandle.h index 8d9e7d777636..44d4620c8b0c 100644 --- a/services/core/jni/com_android_server_input_InputWindowHandle.h +++ b/services/core/jni/com_android_server_input_InputWindowHandle.h @@ -19,7 +19,7 @@ #include <inputflinger/InputWindow.h> -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" namespace android { diff --git a/services/core/jni/com_android_server_lights_LightsService.cpp b/services/core/jni/com_android_server_lights_LightsService.cpp index bf91fe3fd0b4..178d15aab5de 100644 --- a/services/core/jni/com_android_server_lights_LightsService.cpp +++ b/services/core/jni/com_android_server_lights_LightsService.cpp @@ -17,9 +17,10 @@ #define LOG_TAG "LightsService" #include "jni.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "android_runtime/AndroidRuntime.h" +#include <android-base/chrono_utils.h> #include <utils/misc.h> #include <utils/Log.h> #include <hardware/hardware.h> @@ -137,8 +138,9 @@ static void setLight_native(JNIEnv* /* env */, jobject /* clazz */, jlong ptr, state.brightnessMode = brightnessMode; { - ALOGD_IF_SLOW(50, "Excessive delay setting light"); + android::base::Timer t; devices->lights[light]->set_light(devices->lights[light], &state); + if (t.duration() > 50ms) ALOGD("Excessive delay setting light"); } } diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp index 048ef76ed426..4bd7b63f8a27 100644 --- a/services/core/jni/com_android_server_power_PowerManagerService.cpp +++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp @@ -25,6 +25,7 @@ #include <limits.h> +#include <android-base/chrono_utils.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/Log.h> #include <utils/Timers.h> @@ -125,22 +126,34 @@ static void nativeReleaseSuspendBlocker(JNIEnv *env, jclass /* clazz */, jstring static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) { if (gPowerModule) { if (enable) { - ALOGD_IF_SLOW(20, "Excessive delay in setInteractive(true) while turning screen on"); + android::base::Timer t; gPowerModule->setInteractive(gPowerModule, true); + if (t.duration() > 20ms) { + ALOGD("Excessive delay in setInteractive(true) while turning screen on"); + } } else { - ALOGD_IF_SLOW(20, "Excessive delay in setInteractive(false) while turning screen off"); + android::base::Timer t; gPowerModule->setInteractive(gPowerModule, false); + if (t.duration() > 20ms) { + ALOGD("Excessive delay in setInteractive(false) while turning screen off"); + } } } } static void nativeSetAutoSuspend(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) { if (enable) { - ALOGD_IF_SLOW(100, "Excessive delay in autosuspend_enable() while turning screen off"); + android::base::Timer t; autosuspend_enable(); + if (t.duration() > 100ms) { + ALOGD("Excessive delay in autosuspend_enable() while turning screen off"); + } } else { - ALOGD_IF_SLOW(100, "Excessive delay in autosuspend_disable() while turning screen on"); + android::base::Timer t; autosuspend_disable(); + if (t.duration() > 100ms) { + ALOGD("Excessive delay in autosuspend_disable() while turning screen on"); + } } } diff --git a/services/core/jni/com_android_server_power_PowerManagerService.h b/services/core/jni/com_android_server_power_PowerManagerService.h index f5fd3d6ecad1..a17fd650522b 100644 --- a/services/core/jni/com_android_server_power_PowerManagerService.h +++ b/services/core/jni/com_android_server_power_PowerManagerService.h @@ -17,7 +17,7 @@ #ifndef _ANDROID_SERVER_POWER_MANAGER_SERVICE_H #define _ANDROID_SERVER_POWER_MANAGER_SERVICE_H -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include <powermanager/PowerManager.h> diff --git a/services/core/jni/com_android_server_tv_TvInputHal.cpp b/services/core/jni/com_android_server_tv_TvInputHal.cpp index e34a8e8a8cf8..038ab120c5af 100644 --- a/services/core/jni/com_android_server_tv_TvInputHal.cpp +++ b/services/core/jni/com_android_server_tv_TvInputHal.cpp @@ -21,7 +21,7 @@ #include "android_os_MessageQueue.h" #include "android_runtime/AndroidRuntime.h" #include "android_runtime/android_view_Surface.h" -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include <gui/Surface.h> diff --git a/services/core/jni/com_android_server_tv_TvUinputBridge.cpp b/services/core/jni/com_android_server_tv_TvUinputBridge.cpp index de115c80938b..980922a806f5 100644 --- a/services/core/jni/com_android_server_tv_TvUinputBridge.cpp +++ b/services/core/jni/com_android_server_tv_TvUinputBridge.cpp @@ -20,7 +20,7 @@ #include "jni.h" #include <android_runtime/AndroidRuntime.h> -#include <ScopedUtfChars.h> +#include <nativehelper/ScopedUtfChars.h> #include <android/keycodes.h> #include <utils/BitSet.h> diff --git a/services/core/jni/com_android_server_vr_VrManagerService.cpp b/services/core/jni/com_android_server_vr_VrManagerService.cpp index 1aba43b2cd8b..72df5b6d7dac 100644 --- a/services/core/jni/com_android_server_vr_VrManagerService.cpp +++ b/services/core/jni/com_android_server_vr_VrManagerService.cpp @@ -18,7 +18,7 @@ #include <android_runtime/AndroidRuntime.h> #include <jni.h> -#include <JNIHelp.h> +#include <nativehelper/JNIHelp.h> #include <utils/Errors.h> #include <utils/Log.h> diff --git a/services/core/jni/onload.cpp b/services/core/jni/onload.cpp index 5d7291a9ddb3..05f140bc5baf 100644 --- a/services/core/jni/onload.cpp +++ b/services/core/jni/onload.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "JNIHelp.h" +#include <nativehelper/JNIHelp.h> #include "jni.h" #include "utils/Log.h" #include "utils/misc.h" diff --git a/services/net/java/android/net/apf/ApfFilter.java b/services/net/java/android/net/apf/ApfFilter.java index 71201ce8650a..c58b4bd37bf5 100644 --- a/services/net/java/android/net/apf/ApfFilter.java +++ b/services/net/java/android/net/apf/ApfFilter.java @@ -181,6 +181,7 @@ public class ApfFilter { private static final int ETH_HEADER_LEN = 14; private static final int ETH_DEST_ADDR_OFFSET = 0; private static final int ETH_ETHERTYPE_OFFSET = 12; + private static final int ETH_TYPE_MIN = 0x0600; private static final byte[] ETH_BROADCAST_MAC_ADDRESS = {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff }; // TODO: Make these offsets relative to end of link-layer header; don't include ETH_HEADER_LEN. @@ -236,6 +237,7 @@ public class ApfFilter { private final IpManager.Callback mIpManagerCallback; private final NetworkInterface mNetworkInterface; private final IpConnectivityLog mMetricsLog; + @VisibleForTesting byte[] mHardwareAddress; @VisibleForTesting @@ -244,6 +246,7 @@ public class ApfFilter { private long mUniqueCounter; @GuardedBy("this") private boolean mMulticastFilter; + private final boolean mDrop802_3Frames; // Our IPv4 address, if we have just one, otherwise null. @GuardedBy("this") private byte[] mIPv4Address; @@ -253,11 +256,13 @@ public class ApfFilter { @VisibleForTesting ApfFilter(ApfCapabilities apfCapabilities, NetworkInterface networkInterface, - IpManager.Callback ipManagerCallback, boolean multicastFilter, IpConnectivityLog log) { + IpManager.Callback ipManagerCallback, boolean multicastFilter, + boolean ieee802_3Filter, IpConnectivityLog log) { mApfCapabilities = apfCapabilities; mIpManagerCallback = ipManagerCallback; mNetworkInterface = networkInterface; mMulticastFilter = multicastFilter; + mDrop802_3Frames = ieee802_3Filter; mMetricsLog = log; maybeStartFilter(); @@ -879,6 +884,7 @@ public class ApfFilter { /** * Begin generating an APF program to: * <ul> + * <li>Drop/Pass 802.3 frames (based on policy) * <li>Drop ARP requests not for us, if mIPv4Address is set, * <li>Drop IPv4 broadcast packets, except DHCP destined to our MAC, * <li>Drop IPv4 multicast packets, if mMulticastFilter, @@ -900,6 +906,8 @@ public class ApfFilter { // Here's a basic summary of what the initial program does: // + // if it's a 802.3 Frame (ethtype < 0x0600): + // drop or pass based on configurations // if it's ARP: // insert ARP filter to drop or pass these appropriately // if it's IPv4: @@ -910,9 +918,15 @@ public class ApfFilter { // pass // insert IPv6 filter to drop, pass, or fall off the end for ICMPv6 packets + gen.addLoad16(Register.R0, ETH_ETHERTYPE_OFFSET); + + if (mDrop802_3Frames) { + // drop 802.3 frames (ethtype < 0x0600) + gen.addJumpIfR0LessThan(ETH_TYPE_MIN, gen.DROP_LABEL); + } + // Add ARP filters: String skipArpFiltersLabel = "skipArpFilters"; - gen.addLoad16(Register.R0, ETH_ETHERTYPE_OFFSET); gen.addJumpIfR0NotEquals(ETH_P_ARP, skipArpFiltersLabel); generateArpFilterLocked(gen); gen.defineLabel(skipArpFiltersLabel); @@ -1077,7 +1091,7 @@ public class ApfFilter { */ public static ApfFilter maybeCreate(ApfCapabilities apfCapabilities, NetworkInterface networkInterface, IpManager.Callback ipManagerCallback, - boolean multicastFilter) { + boolean multicastFilter, boolean ieee802_3Filter) { if (apfCapabilities == null || networkInterface == null) return null; if (apfCapabilities.apfVersionSupported == 0) return null; if (apfCapabilities.maximumApfProgramSize < 512) { @@ -1094,7 +1108,7 @@ public class ApfFilter { return null; } return new ApfFilter(apfCapabilities, networkInterface, ipManagerCallback, - multicastFilter, new IpConnectivityLog()); + multicastFilter, ieee802_3Filter, new IpConnectivityLog()); } public synchronized void shutdown() { diff --git a/services/net/java/android/net/ip/IpManager.java b/services/net/java/android/net/ip/IpManager.java index adaf59974caf..6a46b5b1d09a 100644 --- a/services/net/java/android/net/ip/IpManager.java +++ b/services/net/java/android/net/ip/IpManager.java @@ -51,6 +51,7 @@ import android.util.Log; import android.util.SparseArray; import com.android.internal.annotations.VisibleForTesting; +import com.android.internal.R; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.IState; import com.android.internal.util.Preconditions; @@ -1418,8 +1419,12 @@ public class IpManager extends StateMachine { @Override public void enter() { + // Get the Configuration for ApfFilter from Context + boolean filter802_3Frames = + mContext.getResources().getBoolean(R.bool.config_apfDrop802_3Frames); + mApfFilter = ApfFilter.maybeCreate(mConfiguration.mApfCapabilities, mNetworkInterface, - mCallback, mMulticastFiltering); + mCallback, mMulticastFiltering, filter802_3Frames); // TODO: investigate the effects of any multicast filtering racing/interfering with the // rest of this IP configuration startup. if (mApfFilter == null) { diff --git a/services/tests/servicestests/src/com/android/server/timezone/PackageTrackerTest.java b/services/tests/servicestests/src/com/android/server/timezone/PackageTrackerTest.java index a972e4f84204..38142d3681b6 100644 --- a/services/tests/servicestests/src/com/android/server/timezone/PackageTrackerTest.java +++ b/services/tests/servicestests/src/com/android/server/timezone/PackageTrackerTest.java @@ -198,26 +198,25 @@ public class PackageTrackerTest { mFakeIntentHelper.assertReliabilityTriggeringDisabled(); } - // TODO(nfuller): Uncomment or delete when it's clear what will happen with http://b/35995024 - // @Test - // public void trackingEnabled_updateAppNotPrivileged() throws Exception { - // // Set up device configuration. - // configureTrackingEnabled(); - // configureReliabilityConfigSettingsOk(); - // configureUpdateAppPackageNotPrivileged(UPDATE_APP_PACKAGE_NAME); - // configureDataAppPackageOk(DATA_APP_PACKAGE_NAME); - // - // try { - // // Initialize the tracker. - // mPackageTracker.start(); - // fail(); - // } catch (RuntimeException expected) {} - // - // mFakeIntentHelper.assertNotInitialized(); - // - // // Check reliability triggering state. - // mFakeIntentHelper.assertReliabilityTriggeringDisabled(); - // } + @Test + public void trackingEnabled_updateAppNotPrivileged() throws Exception { + // Set up device configuration. + configureTrackingEnabled(); + configureReliabilityConfigSettingsOk(); + configureUpdateAppPackageNotPrivileged(UPDATE_APP_PACKAGE_NAME); + configureDataAppPackageOk(DATA_APP_PACKAGE_NAME); + + try { + // Initialize the tracker. + mPackageTracker.start(); + fail(); + } catch (RuntimeException expected) {} + + mFakeIntentHelper.assertNotInitialized(); + + // Check reliability triggering state. + mFakeIntentHelper.assertReliabilityTriggeringDisabled(); + } @Test public void trackingEnabled_dataAppConfigMissing() throws Exception { @@ -239,26 +238,25 @@ public class PackageTrackerTest { mFakeIntentHelper.assertReliabilityTriggeringDisabled(); } - // TODO(nfuller): Uncomment or delete when it's clear what will happen with http://b/35995024 - // @Test - // public void trackingEnabled_dataAppNotPrivileged() throws Exception { - // // Set up device configuration. - // configureTrackingEnabled(); - // configureReliabilityConfigSettingsOk(); - // configureUpdateAppPackageOk(UPDATE_APP_PACKAGE_NAME); - // configureDataAppPackageNotPrivileged(DATA_APP_PACKAGE_NAME); - // - // try { - // // Initialize the tracker. - // mPackageTracker.start(); - // fail(); - // } catch (RuntimeException expected) {} - // - // mFakeIntentHelper.assertNotInitialized(); - // - // // Check reliability triggering state. - // mFakeIntentHelper.assertReliabilityTriggeringDisabled(); - // } + @Test + public void trackingEnabled_dataAppNotPrivileged() throws Exception { + // Set up device configuration. + configureTrackingEnabled(); + configureReliabilityConfigSettingsOk(); + configureUpdateAppPackageOk(UPDATE_APP_PACKAGE_NAME); + configureDataAppPackageNotPrivileged(DATA_APP_PACKAGE_NAME); + + try { + // Initialize the tracker. + mPackageTracker.start(); + fail(); + } catch (RuntimeException expected) {} + + mFakeIntentHelper.assertNotInitialized(); + + // Check reliability triggering state. + mFakeIntentHelper.assertReliabilityTriggeringDisabled(); + } @Test public void trackingEnabled_packageUpdate_badUpdateAppManifestEntry() throws Exception { diff --git a/telecomm/java/android/telecom/Logging/EventManager.java b/telecomm/java/android/telecom/Logging/EventManager.java index fddbfcec001b..4fc338539f42 100644 --- a/telecomm/java/android/telecom/Logging/EventManager.java +++ b/telecomm/java/android/telecom/Logging/EventManager.java @@ -36,6 +36,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.TimeZone; import java.util.concurrent.LinkedBlockingQueue; import java.util.stream.Collectors; @@ -268,6 +269,7 @@ public class EventManager { public EventManager(@NonNull SessionManager.ISessionIdQueryHandler l) { mSessionIdHandler = l; + sDateFormat.setTimeZone(TimeZone.getDefault()); } public void event(Loggable recordEntry, String event, Object data) { diff --git a/telephony/java/android/telephony/MbmsDownloadManager.java b/telephony/java/android/telephony/MbmsDownloadManager.java index 4eeabb078a64..c747b8488634 100644 --- a/telephony/java/android/telephony/MbmsDownloadManager.java +++ b/telephony/java/android/telephony/MbmsDownloadManager.java @@ -28,8 +28,8 @@ import android.net.Uri; import android.os.IBinder; import android.os.RemoteException; import android.telephony.mbms.FileInfo; -import android.telephony.mbms.IDownloadCallback; import android.telephony.mbms.DownloadRequest; +import android.telephony.mbms.IDownloadProgressListener; import android.telephony.mbms.IMbmsDownloadManagerCallback; import android.telephony.mbms.MbmsDownloadManagerCallback; import android.telephony.mbms.MbmsDownloadReceiver; @@ -390,9 +390,10 @@ public class MbmsDownloadManager { * Asynchronous errors through the listener include any of the errors * * @param request The request that specifies what should be downloaded - * @param callback Optional callback that will provide progress updates if the app is running. + * @param progressListener Optional listener that will be provided progress updates + * if the app is running. */ - public void download(DownloadRequest request, IDownloadCallback callback) + public void download(DownloadRequest request, IDownloadProgressListener progressListener) throws MbmsException { IMbmsDownloadService downloadService = mService.get(); if (downloadService == null) { @@ -412,7 +413,7 @@ public class MbmsDownloadManager { checkValidDownloadDestination(request); writeDownloadRequestToken(request); try { - downloadService.download(request, callback); + downloadService.download(request, progressListener); } catch (RemoteException e) { mService.set(null); throw new MbmsException(MbmsException.ERROR_MIDDLEWARE_LOST); diff --git a/telephony/java/android/telephony/mbms/DownloadCallback.java b/telephony/java/android/telephony/mbms/DownloadProgressListener.java index 0c6fec4b9c75..d6bd5dca8781 100644 --- a/telephony/java/android/telephony/mbms/DownloadCallback.java +++ b/telephony/java/android/telephony/mbms/DownloadProgressListener.java @@ -20,22 +20,26 @@ package android.telephony.mbms; * A optional listener class used by download clients to track progress. * @hide */ -public class DownloadCallback extends IDownloadCallback.Stub { +public class DownloadProgressListener extends IDownloadProgressListener.Stub { /** * Gives process callbacks for a given DownloadRequest. - * request indicates which download is being referenced. - * fileInfo gives information about the file being downloaded. Note that + * This is optionally specified when requesting a download and + * only lives while the app is running - it's unlikely to be useful for + * downloads far in the future. + * + * @param request a {@link DownloadRequest}, indicating which download is being referenced. + * @param fileInfo a {@link FileInfo} specifying the file to report progress on. Note that * the request may result in many files being downloaded and the client * may not have been able to get a list of them in advance. - * downloadSize is the final amount to be downloaded. This may be different - * from the decoded final size, but is useful in gauging download progress. - * currentSize is the amount currently downloaded. - * decodedPercent is the percent from 0 to 100 of the file decoded. After the - * download completes the contents needs to be processed. It is perhaps - * uncompressed, transcoded and/or decrypted. Generally the download completes - * before the decode is started, but that's not required. + * @param currentDownloadSize is the current amount downloaded. + * @param fullDownloadSize is the total number of bytes that make up the downloaded content. + * This may be different from the decoded final size, but is useful in gauging download + * progress. + * @param currentDecodedSize is the number of bytes that have been decoded. + * @param fullDecodedSize is the total number of bytes that make up the final decoded content. */ public void progress(DownloadRequest request, FileInfo fileInfo, - int downloadSize, int currentSize, int decodedPercent) { + int currentDownloadSize, int fullDownloadSize, + int currentDecodedSize, int fullDecodedSize) { } } diff --git a/telephony/java/android/telephony/mbms/IDownloadCallback.aidl b/telephony/java/android/telephony/mbms/IDownloadProgressListener.aidl index a6bd7e5f84f9..bb9dc6cfea9f 100755 --- a/telephony/java/android/telephony/mbms/IDownloadCallback.aidl +++ b/telephony/java/android/telephony/mbms/IDownloadProgressListener.aidl @@ -23,12 +23,12 @@ import android.telephony.mbms.FileInfo; * The optional interface used by download clients to track progress. * @hide */ -interface IDownloadCallback +interface IDownloadProgressListener { /** * Gives progress callbacks for a given DownloadRequest. Includes a FileInfo * as the list of files may not have been known at request-time. */ - void progress(in DownloadRequest request, in FileInfo fileInfo, int downloadSize, - int currentSize, int decodedPercent); + void progress(in DownloadRequest request, in FileInfo fileInfo, int currentDownloadSize, + int fullDownloadSize, int currentDecodedSize, int fullDecodedSize); } diff --git a/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl b/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl index 725d11c880b2..0a76f322bbbb 100755 --- a/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl +++ b/telephony/java/android/telephony/mbms/vendor/IMbmsDownloadService.aidl @@ -21,7 +21,7 @@ import android.net.Uri; import android.telephony.mbms.DownloadRequest; import android.telephony.mbms.FileInfo; import android.telephony.mbms.IMbmsDownloadManagerCallback; -import android.telephony.mbms.IDownloadCallback; +import android.telephony.mbms.IDownloadProgressListener; /** * @hide @@ -34,7 +34,7 @@ interface IMbmsDownloadService int setTempFileRootDirectory(int subId, String rootDirectoryPath); - int download(in DownloadRequest downloadRequest, IDownloadCallback listener); + int download(in DownloadRequest downloadRequest, IDownloadProgressListener listener); List<DownloadRequest> listPendingDownloads(int subscriptionId); diff --git a/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java index 8fbd4481cfc2..d725d9f633ce 100644 --- a/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java +++ b/telephony/java/android/telephony/mbms/vendor/MbmsDownloadServiceBase.java @@ -20,7 +20,7 @@ import android.annotation.NonNull; import android.os.RemoteException; import android.telephony.mbms.DownloadRequest; import android.telephony.mbms.FileInfo; -import android.telephony.mbms.IDownloadCallback; +import android.telephony.mbms.IDownloadProgressListener; import android.telephony.mbms.IMbmsDownloadManagerCallback; import android.telephony.mbms.MbmsException; @@ -105,7 +105,7 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub { * @return TODO: enumerate possible return values */ @Override - public int download(DownloadRequest downloadRequest, IDownloadCallback listener) + public int download(DownloadRequest downloadRequest, IDownloadProgressListener listener) throws RemoteException { return 0; } diff --git a/tests/net/java/android/net/IpSecManagerTest.java b/tests/net/java/android/net/IpSecManagerTest.java new file mode 100644 index 000000000000..9f31d27508b2 --- /dev/null +++ b/tests/net/java/android/net/IpSecManagerTest.java @@ -0,0 +1,225 @@ +/* + * 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; + +import static android.system.OsConstants.AF_INET; +import static android.system.OsConstants.IPPROTO_UDP; +import static android.system.OsConstants.SOCK_DGRAM; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.anyInt; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import android.support.test.filters.SmallTest; +import android.system.Os; +import android.test.AndroidTestCase; +import com.android.server.IpSecService; +import java.net.InetAddress; +import java.net.UnknownHostException; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Unit tests for {@link IpSecManager}. */ +@SmallTest +@RunWith(JUnit4.class) +public class IpSecManagerTest { + + private static final int TEST_UDP_ENCAP_PORT = 34567; + private static final int DROID_SPI = 0xD1201D; + + private static final InetAddress GOOGLE_DNS_4; + + static { + try { + // Google Public DNS Addresses; + GOOGLE_DNS_4 = InetAddress.getByName("8.8.8.8"); + } catch (UnknownHostException e) { + throw new RuntimeException("Could not resolve DNS Addresses", e); + } + } + + private IpSecService mMockIpSecService; + private IpSecManager mIpSecManager; + + @Before + public void setUp() throws Exception { + mMockIpSecService = mock(IpSecService.class); + mIpSecManager = new IpSecManager(mMockIpSecService); + } + + /* + * Allocate a specific SPI + * Close SPIs + */ + @Test + public void testAllocSpi() throws Exception { + int resourceId = 1; + IpSecSpiResponse spiResp = + new IpSecSpiResponse(IpSecManager.Status.OK, resourceId, DROID_SPI); + when(mMockIpSecService.reserveSecurityParameterIndex( + eq(IpSecTransform.DIRECTION_IN), + eq(GOOGLE_DNS_4.getHostAddress()), + eq(DROID_SPI), + anyObject())) + .thenReturn(spiResp); + + IpSecManager.SecurityParameterIndex droidSpi = + mIpSecManager.reserveSecurityParameterIndex( + IpSecTransform.DIRECTION_IN, GOOGLE_DNS_4, DROID_SPI); + assertEquals(DROID_SPI, droidSpi.getSpi()); + + droidSpi.close(); + + verify(mMockIpSecService).releaseSecurityParameterIndex(resourceId); + } + + @Test + public void testAllocRandomSpi() throws Exception { + int resourceId = 1; + IpSecSpiResponse spiResp = + new IpSecSpiResponse(IpSecManager.Status.OK, resourceId, DROID_SPI); + when(mMockIpSecService.reserveSecurityParameterIndex( + eq(IpSecTransform.DIRECTION_OUT), + eq(GOOGLE_DNS_4.getHostAddress()), + eq(IpSecManager.INVALID_SECURITY_PARAMETER_INDEX), + anyObject())) + .thenReturn(spiResp); + + IpSecManager.SecurityParameterIndex randomSpi = + mIpSecManager.reserveSecurityParameterIndex( + IpSecTransform.DIRECTION_OUT, GOOGLE_DNS_4); + + assertEquals(DROID_SPI, randomSpi.getSpi()); + + randomSpi.close(); + + verify(mMockIpSecService).releaseSecurityParameterIndex(resourceId); + } + + /* + * Throws resource unavailable exception + */ + @Test + public void testAllocSpiResUnavaiableExeption() throws Exception { + IpSecSpiResponse spiResp = + new IpSecSpiResponse(IpSecManager.Status.RESOURCE_UNAVAILABLE, 0, 0); + when(mMockIpSecService.reserveSecurityParameterIndex( + anyInt(), anyString(), anyInt(), anyObject())) + .thenReturn(spiResp); + + try { + mIpSecManager.reserveSecurityParameterIndex(IpSecTransform.DIRECTION_OUT, GOOGLE_DNS_4); + fail("ResourceUnavailableException was not thrown"); + } catch (IpSecManager.ResourceUnavailableException e) { + } + } + + /* + * Throws spi unavailable exception + */ + @Test + public void testAllocSpiSpiUnavaiableExeption() throws Exception { + IpSecSpiResponse spiResp = new IpSecSpiResponse(IpSecManager.Status.SPI_UNAVAILABLE, 0, 0); + when(mMockIpSecService.reserveSecurityParameterIndex( + anyInt(), anyString(), anyInt(), anyObject())) + .thenReturn(spiResp); + + try { + mIpSecManager.reserveSecurityParameterIndex(IpSecTransform.DIRECTION_OUT, GOOGLE_DNS_4); + fail("ResourceUnavailableException was not thrown"); + } catch (IpSecManager.ResourceUnavailableException e) { + } + } + + /* + * Should throw exception when request spi 0 in IpSecManager + */ + @Test + public void testRequestAllocInvalidSpi() throws Exception { + try { + mIpSecManager.reserveSecurityParameterIndex( + IpSecTransform.DIRECTION_OUT, GOOGLE_DNS_4, 0); + fail("Able to allocate invalid spi"); + } catch (IllegalArgumentException e) { + } + } + + @Test + public void testOpenEncapsulationSocket() throws Exception { + int resourceId = 1; + IpSecUdpEncapResponse udpEncapResp = + new IpSecUdpEncapResponse( + IpSecManager.Status.OK, + resourceId, + TEST_UDP_ENCAP_PORT, + Os.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)); + when(mMockIpSecService.openUdpEncapsulationSocket(eq(TEST_UDP_ENCAP_PORT), anyObject())) + .thenReturn(udpEncapResp); + + IpSecManager.UdpEncapsulationSocket encapSocket = + mIpSecManager.openUdpEncapsulationSocket(TEST_UDP_ENCAP_PORT); + assertNotNull(encapSocket.getSocket()); + assertEquals(TEST_UDP_ENCAP_PORT, encapSocket.getPort()); + + encapSocket.close(); + + verify(mMockIpSecService).closeUdpEncapsulationSocket(resourceId); + } + + @Test + public void testOpenEncapsulationSocketOnRandomPort() throws Exception { + int resourceId = 1; + IpSecUdpEncapResponse udpEncapResp = + new IpSecUdpEncapResponse( + IpSecManager.Status.OK, + resourceId, + TEST_UDP_ENCAP_PORT, + Os.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)); + + when(mMockIpSecService.openUdpEncapsulationSocket(eq(0), anyObject())) + .thenReturn(udpEncapResp); + + IpSecManager.UdpEncapsulationSocket encapSocket = + mIpSecManager.openUdpEncapsulationSocket(); + + assertNotNull(encapSocket.getSocket()); + assertEquals(TEST_UDP_ENCAP_PORT, encapSocket.getPort()); + + encapSocket.close(); + + verify(mMockIpSecService).closeUdpEncapsulationSocket(resourceId); + } + + @Test + public void testOpenEncapsulationSocketWithInvalidPort() throws Exception { + try { + mIpSecManager.openUdpEncapsulationSocket(IpSecManager.INVALID_SECURITY_PARAMETER_INDEX); + fail("IllegalArgumentException was not thrown"); + } catch (IllegalArgumentException e) { + } + } + + // TODO: add test when applicable transform builder interface is available +} diff --git a/tests/net/java/android/net/apf/ApfTest.java b/tests/net/java/android/net/apf/ApfTest.java index 6bf3b6bc8441..bfbb8cc541d7 100644 --- a/tests/net/java/android/net/apf/ApfTest.java +++ b/tests/net/java/android/net/apf/ApfTest.java @@ -92,6 +92,9 @@ public class ApfTest extends AndroidTestCase { private final static boolean DROP_MULTICAST = true; private final static boolean ALLOW_MULTICAST = false; + private final static boolean DROP_802_3_FRAMES = true; + private final static boolean ALLOW_802_3_FRAMES = false; + private static String label(int code) { switch (code) { case PASS: return "PASS"; @@ -611,9 +614,9 @@ public class ApfTest extends AndroidTestCase { private final long mFixedTimeMs = SystemClock.elapsedRealtime(); public TestApfFilter(IpManager.Callback ipManagerCallback, boolean multicastFilter, - IpConnectivityLog log) throws Exception { + boolean ieee802_3Filter, IpConnectivityLog log) throws Exception { super(new ApfCapabilities(2, 1700, ARPHRD_ETHER), NetworkInterface.getByName("lo"), - ipManagerCallback, multicastFilter, log); + ipManagerCallback, multicastFilter, ieee802_3Filter, log); } // Pretend an RA packet has been received and show it to ApfFilter. @@ -742,7 +745,8 @@ public class ApfTest extends AndroidTestCase { LinkProperties lp = new LinkProperties(); lp.addLinkAddress(link); - ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, DROP_MULTICAST, mLog); + ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, DROP_MULTICAST, + ALLOW_802_3_FRAMES, mLog); apfFilter.setLinkProperties(lp); byte[] program = ipManagerCallback.getApfProgram(); @@ -793,7 +797,8 @@ public class ApfTest extends AndroidTestCase { @SmallTest public void testApfFilterIPv6() throws Exception { MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); - ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, mLog); + ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, + ALLOW_802_3_FRAMES, mLog); byte[] program = ipManagerCallback.getApfProgram(); // Verify empty IPv6 packet is passed @@ -834,7 +839,8 @@ public class ApfTest extends AndroidTestCase { LinkProperties lp = new LinkProperties(); lp.addLinkAddress(link); - ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, mLog); + ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, + DROP_802_3_FRAMES, mLog); apfFilter.setLinkProperties(lp); byte[] program = ipManagerCallback.getApfProgram(); @@ -896,7 +902,8 @@ public class ApfTest extends AndroidTestCase { // Verify it can be initialized to on ipManagerCallback.resetApfProgramWait(); apfFilter.shutdown(); - apfFilter = new TestApfFilter(ipManagerCallback, DROP_MULTICAST, mLog); + apfFilter = new TestApfFilter(ipManagerCallback, DROP_MULTICAST, + DROP_802_3_FRAMES, mLog); apfFilter.setLinkProperties(lp); program = ipManagerCallback.getApfProgram(); assertDrop(program, mcastv4packet.array()); @@ -911,6 +918,56 @@ public class ApfTest extends AndroidTestCase { apfFilter.shutdown(); } + @SmallTest + public void testApfFilter802_3() throws Exception { + MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); + LinkAddress link = new LinkAddress(InetAddress.getByAddress(MOCK_IPV4_ADDR), 19); + LinkProperties lp = new LinkProperties(); + lp.addLinkAddress(link); + + ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, + ALLOW_802_3_FRAMES, mLog); + apfFilter.setLinkProperties(lp); + + byte[] program = ipManagerCallback.getApfProgram(); + + // Verify empty packet of 100 zero bytes is passed + // Note that eth-type = 0 makes it an IEEE802.3 frame + ByteBuffer packet = ByteBuffer.wrap(new byte[100]); + assertPass(program, packet.array()); + + // Verify empty packet with IPv4 is passed + packet.putShort(ETH_ETHERTYPE_OFFSET, (short)ETH_P_IP); + assertPass(program, packet.array()); + + // Verify empty IPv6 packet is passed + packet.putShort(ETH_ETHERTYPE_OFFSET, (short)ETH_P_IPV6); + assertPass(program, packet.array()); + + // Now turn on the filter + ipManagerCallback.resetApfProgramWait(); + apfFilter.shutdown(); + apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, + DROP_802_3_FRAMES, mLog); + apfFilter.setLinkProperties(lp); + program = ipManagerCallback.getApfProgram(); + + // Verify that IEEE802.3 frame is dropped + // In this case ethtype is used for payload length + packet.putShort(ETH_ETHERTYPE_OFFSET, (short)(100 - 14)); + assertDrop(program, packet.array()); + + // Verify that IPv4 (as example of Ethernet II) frame will pass + packet.putShort(ETH_ETHERTYPE_OFFSET, (short)ETH_P_IP); + assertPass(program, packet.array()); + + // Verify that IPv6 (as example of Ethernet II) frame will pass + packet.putShort(ETH_ETHERTYPE_OFFSET, (short)ETH_P_IPV6); + assertPass(program, packet.array()); + + apfFilter.shutdown(); + } + private byte[] getProgram(MockIpManagerCallback cb, ApfFilter filter, LinkProperties lp) { cb.resetApfProgramWait(); filter.setLinkProperties(lp); @@ -935,7 +992,8 @@ public class ApfTest extends AndroidTestCase { @SmallTest public void testApfFilterArp() throws Exception { MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); - ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, mLog); + ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, + DROP_802_3_FRAMES, mLog); // Verify initially ARP request filter is off, and GARP filter is on. verifyArpFilter(ipManagerCallback.getApfProgram(), PASS); @@ -1056,7 +1114,8 @@ public class ApfTest extends AndroidTestCase { @SmallTest public void testApfFilterRa() throws Exception { MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback(); - TestApfFilter apfFilter = new TestApfFilter(ipManagerCallback, DROP_MULTICAST, mLog); + TestApfFilter apfFilter = new TestApfFilter(ipManagerCallback, DROP_MULTICAST, + DROP_802_3_FRAMES, mLog); byte[] program = ipManagerCallback.getApfProgram(); final int ROUTER_LIFETIME = 1000; @@ -1198,7 +1257,8 @@ public class ApfTest extends AndroidTestCase { final int maxRandomPacketSize = 512; final Random r = new Random(); MockIpManagerCallback cb = new MockIpManagerCallback(); - TestApfFilter apfFilter = new TestApfFilter(cb, DROP_MULTICAST, mLog); + TestApfFilter apfFilter = new TestApfFilter(cb, DROP_MULTICAST, + DROP_802_3_FRAMES, mLog); for (int i = 0; i < 1000; i++) { byte[] packet = new byte[r.nextInt(maxRandomPacketSize + 1)]; r.nextBytes(packet); @@ -1216,7 +1276,8 @@ public class ApfTest extends AndroidTestCase { final int maxRandomPacketSize = 512; final Random r = new Random(); MockIpManagerCallback cb = new MockIpManagerCallback(); - TestApfFilter apfFilter = new TestApfFilter(cb, DROP_MULTICAST, mLog); + TestApfFilter apfFilter = new TestApfFilter(cb, DROP_MULTICAST, + DROP_802_3_FRAMES, mLog); for (int i = 0; i < 1000; i++) { byte[] packet = new byte[r.nextInt(maxRandomPacketSize + 1)]; r.nextBytes(packet); diff --git a/tests/net/java/android/net/ip/IpManagerTest.java b/tests/net/java/android/net/ip/IpManagerTest.java index e7dbfe3f5044..dc77e22082ba 100644 --- a/tests/net/java/android/net/ip/IpManagerTest.java +++ b/tests/net/java/android/net/ip/IpManagerTest.java @@ -22,6 +22,7 @@ import static org.mockito.Mockito.any; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; +import static org.mockito.Mockito.reset; import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -75,7 +76,8 @@ public class IpManagerTest { @Mock private AlarmManager mAlarm; private MockContentResolver mContentResolver; - @Before public void setUp() throws Exception { + @Before + public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(mContext.getSystemService(eq(Context.ALARM_SERVICE))).thenReturn(mAlarm); @@ -88,6 +90,14 @@ public class IpManagerTest { when(mContext.getContentResolver()).thenReturn(mContentResolver); } + private IpManager makeIpManager(String ifname) throws Exception { + final IpManager ipm = new IpManager(mContext, ifname, mCb, mNMService); + verify(mNMService, timeout(100).times(1)).disableIpv6(ifname); + verify(mNMService, timeout(100).times(1)).clearInterfaceAddresses(ifname); + reset(mNMService); + return ipm; + } + @Test public void testNullCallbackDoesNotThrow() throws Exception { final IpManager ipm = new IpManager(mContext, "lo", null, mNMService); @@ -101,7 +111,8 @@ public class IpManagerTest { @Test public void testDefaultProvisioningConfiguration() throws Exception { final String iface = "test_wlan0"; - final IpManager ipm = new IpManager(mContext, iface, mCb, mNMService); + final IpManager ipm = makeIpManager(iface); + ProvisioningConfiguration config = new ProvisioningConfiguration.Builder() .withoutIPv4() // TODO: mock IpReachabilityMonitor's dependencies (NetworkInterface, PowerManager) diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java index 9d4a2b033e97..11e36bd37767 100644 --- a/tests/net/java/com/android/server/ConnectivityServiceTest.java +++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java @@ -881,6 +881,7 @@ public class ConnectivityServiceTest extends AndroidTestCase { } private void verifyNoNetwork() { + waitForIdle(); // Test getActiveNetworkInfo() assertNull(mCm.getActiveNetworkInfo()); // Test getActiveNetwork() @@ -3277,7 +3278,7 @@ public class ConnectivityServiceTest extends AndroidTestCase { ConditionVariable broadcastCV = waitForConnectivityBroadcasts(1); verifyNoNetwork(); - MockNetworkAgent lowpanNetwork = new MockNetworkAgent(TRANSPORT_WIFI_AWARE); + MockNetworkAgent wifiAware = new MockNetworkAgent(TRANSPORT_WIFI_AWARE); assertNull(mCm.getActiveNetworkInfo()); Network[] allNetworks = mCm.getAllNetworks(); @@ -3291,19 +3292,19 @@ public class ConnectivityServiceTest extends AndroidTestCase { final TestNetworkCallback callback = new TestNetworkCallback(); mCm.registerNetworkCallback(request, callback); - // Bring up lowpan. - lowpanNetwork.connect(false, false); - callback.expectAvailableCallbacks(lowpanNetwork); + // Bring up wifi aware network. + wifiAware.connect(false, false); + callback.expectAvailableCallbacks(wifiAware); assertNull(mCm.getActiveNetworkInfo()); assertNull(mCm.getActiveNetwork()); - // TODO: getAllNetworkInfo is dirty and returns a non-empty array rght from the start + // TODO: getAllNetworkInfo is dirty and returns a non-empty array right from the start // of this test. Fix it and uncomment the assert below. //assertEmpty(mCm.getAllNetworkInfo()); - // Disconnect lowpan. - lowpanNetwork.disconnect(); - callback.expectCallback(CallbackState.LOST, lowpanNetwork); + // Disconnect wifi aware network. + wifiAware.disconnect(); + callback.expectCallbackLike((info) -> info.state == CallbackState.LOST, TIMEOUT_MS); mCm.unregisterNetworkCallback(callback); verifyNoNetwork(); diff --git a/tests/net/java/com/android/server/IpSecServiceTest.java b/tests/net/java/com/android/server/IpSecServiceTest.java new file mode 100644 index 000000000000..23fee286b8e7 --- /dev/null +++ b/tests/net/java/com/android/server/IpSecServiceTest.java @@ -0,0 +1,435 @@ +/* + * 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 com.android.server; + +import static android.system.OsConstants.AF_INET; +import static android.system.OsConstants.EADDRINUSE; +import static android.system.OsConstants.IPPROTO_UDP; +import static android.system.OsConstants.SOCK_DGRAM; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.anyInt; +import static org.mockito.Matchers.anyLong; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import android.content.Context; +import android.net.INetd; +import android.net.IpSecAlgorithm; +import android.net.IpSecConfig; +import android.net.IpSecManager; +import android.net.IpSecSpiResponse; +import android.net.IpSecTransform; +import android.net.IpSecTransformResponse; +import android.net.IpSecUdpEncapResponse; +import android.os.Binder; +import android.os.ParcelFileDescriptor; +import android.support.test.filters.SmallTest; +import android.system.ErrnoException; +import android.system.Os; +import java.io.FileDescriptor; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.UnknownHostException; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Unit tests for {@link IpSecService}. */ +@SmallTest +@RunWith(JUnit4.class) +public class IpSecServiceTest { + + private static final int DROID_SPI = 0xD1201D; + private static final int DROID_SPI2 = DROID_SPI + 1; + private static final int TEST_UDP_ENCAP_INVALID_PORT = 100; + private static final int TEST_UDP_ENCAP_PORT_OUT_RANGE = 100000; + private static final int TEST_UDP_ENCAP_PORT = 34567; + + private static final String IPV4_LOOPBACK = "127.0.0.1"; + private static final String IPV4_ADDR = "192.168.0.2"; + + private static final InetAddress INADDR_ANY; + + static { + try { + INADDR_ANY = InetAddress.getByAddress(new byte[] {0, 0, 0, 0}); + } catch (UnknownHostException e) { + throw new RuntimeException(e); + } + } + + private static final int[] DIRECTIONS = + new int[] {IpSecTransform.DIRECTION_OUT, IpSecTransform.DIRECTION_IN}; + private static final byte[] CRYPT_KEY = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F + }; + private static final byte[] AUTH_KEY = { + 0x7A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, + 0x7A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F + }; + + Context mMockContext; + INetd mMockNetd; + IpSecService.IpSecServiceConfiguration mMockIpSecSrvConfig; + IpSecService mIpSecService; + + @Before + public void setUp() throws Exception { + mMockContext = mock(Context.class); + mMockNetd = mock(INetd.class); + mMockIpSecSrvConfig = mock(IpSecService.IpSecServiceConfiguration.class); + mIpSecService = new IpSecService(mMockContext, mMockIpSecSrvConfig); + + // Injecting mock netd + when(mMockIpSecSrvConfig.getNetdInstance()).thenReturn(mMockNetd); + } + + @Test + public void testIpSecServiceCreate() throws InterruptedException { + IpSecService ipSecSrv = IpSecService.create(mMockContext); + assertNotNull(ipSecSrv); + } + + @Test + public void testIpSecServiceReserveSpi() throws Exception { + when(mMockNetd.ipSecAllocateSpi( + anyInt(), + eq(IpSecTransform.DIRECTION_OUT), + anyString(), + eq(IPV4_LOOPBACK), + eq(DROID_SPI))) + .thenReturn(DROID_SPI); + + IpSecSpiResponse spiResp = + mIpSecService.reserveSecurityParameterIndex( + IpSecTransform.DIRECTION_OUT, IPV4_LOOPBACK, DROID_SPI, new Binder()); + assertEquals(IpSecManager.Status.OK, spiResp.status); + assertEquals(DROID_SPI, spiResp.spi); + } + + @Test + public void testReleaseSecurityParameterIndex() throws Exception { + when(mMockNetd.ipSecAllocateSpi( + anyInt(), + eq(IpSecTransform.DIRECTION_OUT), + anyString(), + eq(IPV4_LOOPBACK), + eq(DROID_SPI))) + .thenReturn(DROID_SPI); + + IpSecSpiResponse spiResp = + mIpSecService.reserveSecurityParameterIndex( + IpSecTransform.DIRECTION_OUT, IPV4_LOOPBACK, DROID_SPI, new Binder()); + + mIpSecService.releaseSecurityParameterIndex(spiResp.resourceId); + + verify(mMockNetd) + .ipSecDeleteSecurityAssociation( + eq(spiResp.resourceId), anyInt(), anyString(), anyString(), eq(DROID_SPI)); + } + + @Test + public void testReleaseInvalidSecurityParameterIndex() throws Exception { + try { + mIpSecService.releaseSecurityParameterIndex(1); + fail("IllegalArgumentException not thrown"); + } catch (IllegalArgumentException e) { + } + } + + /** This function finds an available port */ + int findUnusedPort() throws Exception { + // Get an available port. + ServerSocket s = new ServerSocket(0); + int port = s.getLocalPort(); + s.close(); + return port; + } + + @Test + public void testOpenAndCloseUdpEncapsulationSocket() throws Exception { + int localport = findUnusedPort(); + + IpSecUdpEncapResponse udpEncapResp = + mIpSecService.openUdpEncapsulationSocket(localport, new Binder()); + assertNotNull(udpEncapResp); + assertEquals(IpSecManager.Status.OK, udpEncapResp.status); + assertEquals(localport, udpEncapResp.port); + + mIpSecService.closeUdpEncapsulationSocket(udpEncapResp.resourceId); + udpEncapResp.fileDescriptor.close(); + + // TODO: Added check for the resource tracker + } + + @Test + public void testOpenUdpEncapsulationSocketAfterClose() throws Exception { + int localport = findUnusedPort(); + IpSecUdpEncapResponse udpEncapResp = + mIpSecService.openUdpEncapsulationSocket(localport, new Binder()); + assertNotNull(udpEncapResp); + assertEquals(IpSecManager.Status.OK, udpEncapResp.status); + assertEquals(localport, udpEncapResp.port); + + mIpSecService.closeUdpEncapsulationSocket(udpEncapResp.resourceId); + udpEncapResp.fileDescriptor.close(); + + /** Check if localport is available. */ + FileDescriptor newSocket = Os.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + Os.bind(newSocket, INADDR_ANY, localport); + Os.close(newSocket); + } + + /** + * This function checks if the IpSecService holds the reserved port. If + * closeUdpEncapsulationSocket is not called, the socket cleanup should not be complete. + */ + @Test + public void testUdpEncapPortNotReleased() throws Exception { + int localport = findUnusedPort(); + IpSecUdpEncapResponse udpEncapResp = + mIpSecService.openUdpEncapsulationSocket(localport, new Binder()); + assertNotNull(udpEncapResp); + assertEquals(IpSecManager.Status.OK, udpEncapResp.status); + assertEquals(localport, udpEncapResp.port); + + udpEncapResp.fileDescriptor.close(); + + FileDescriptor newSocket = Os.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + try { + Os.bind(newSocket, INADDR_ANY, localport); + fail("ErrnoException not thrown"); + } catch (ErrnoException e) { + assertEquals(EADDRINUSE, e.errno); + } + mIpSecService.closeUdpEncapsulationSocket(udpEncapResp.resourceId); + } + + @Test + public void testOpenUdpEncapsulationSocketOnRandomPort() throws Exception { + IpSecUdpEncapResponse udpEncapResp = + mIpSecService.openUdpEncapsulationSocket(0, new Binder()); + assertNotNull(udpEncapResp); + assertEquals(IpSecManager.Status.OK, udpEncapResp.status); + mIpSecService.closeUdpEncapsulationSocket(udpEncapResp.resourceId); + udpEncapResp.fileDescriptor.close(); + } + + @Test + public void testOpenUdpEncapsulationSocketPortRange() throws Exception { + try { + mIpSecService.openUdpEncapsulationSocket(TEST_UDP_ENCAP_INVALID_PORT, new Binder()); + fail("IllegalArgumentException not thrown"); + } catch (IllegalArgumentException e) { + } + + try { + mIpSecService.openUdpEncapsulationSocket(TEST_UDP_ENCAP_PORT_OUT_RANGE, new Binder()); + fail("IllegalArgumentException not thrown"); + } catch (IllegalArgumentException e) { + } + } + + @Test + public void testOpenUdpEncapsulationSocketTwice() throws Exception { + int localport = findUnusedPort(); + + IpSecUdpEncapResponse udpEncapResp = + mIpSecService.openUdpEncapsulationSocket(localport, new Binder()); + assertNotNull(udpEncapResp); + assertEquals(IpSecManager.Status.OK, udpEncapResp.status); + assertEquals(localport, udpEncapResp.port); + mIpSecService.openUdpEncapsulationSocket(localport, new Binder()); + + IpSecUdpEncapResponse testUdpEncapResp = + mIpSecService.openUdpEncapsulationSocket(localport, new Binder()); + assertEquals(IpSecManager.Status.RESOURCE_UNAVAILABLE, testUdpEncapResp.status); + + mIpSecService.closeUdpEncapsulationSocket(udpEncapResp.resourceId); + udpEncapResp.fileDescriptor.close(); + } + + @Test + public void testCloseInvalidUdpEncapsulationSocket() throws Exception { + try { + mIpSecService.closeUdpEncapsulationSocket(1); + fail("IllegalArgumentException not thrown"); + } catch (IllegalArgumentException e) { + } + } + + IpSecConfig buildIpSecConfig() throws Exception { + IpSecManager ipSecManager = new IpSecManager(mIpSecService); + + // Mocking the netd to allocate SPI + when(mMockNetd.ipSecAllocateSpi(anyInt(), anyInt(), anyString(), anyString(), anyInt())) + .thenReturn(DROID_SPI) + .thenReturn(DROID_SPI2); + + IpSecAlgorithm encryptAlgo = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY); + IpSecAlgorithm authAlgo = + new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, AUTH_KEY, AUTH_KEY.length * 8); + + InetAddress localAddr = InetAddress.getByAddress(new byte[] {127, 0, 0, 1}); + + /** Allocate and add SPI records in the IpSecService through IpSecManager interface. */ + IpSecManager.SecurityParameterIndex outSpi = + ipSecManager.reserveSecurityParameterIndex(IpSecTransform.DIRECTION_OUT, localAddr); + IpSecManager.SecurityParameterIndex inSpi = + ipSecManager.reserveSecurityParameterIndex(IpSecTransform.DIRECTION_IN, localAddr); + + IpSecConfig ipSecConfig = + new IpSecTransform.Builder(mMockContext) + .setSpi(IpSecTransform.DIRECTION_OUT, outSpi) + .setSpi(IpSecTransform.DIRECTION_IN, inSpi) + .setEncryption(IpSecTransform.DIRECTION_OUT, encryptAlgo) + .setAuthentication(IpSecTransform.DIRECTION_OUT, authAlgo) + .setEncryption(IpSecTransform.DIRECTION_IN, encryptAlgo) + .setAuthentication(IpSecTransform.DIRECTION_IN, authAlgo) + .getIpSecConfig(); + return ipSecConfig; + } + + @Test + public void testCreateTransportModeTransform() throws Exception { + IpSecConfig ipSecConfig = buildIpSecConfig(); + + IpSecTransformResponse createTransformResp = + mIpSecService.createTransportModeTransform(ipSecConfig, new Binder()); + assertEquals(IpSecManager.Status.OK, createTransformResp.status); + + verify(mMockNetd) + .ipSecAddSecurityAssociation( + eq(createTransformResp.resourceId), + anyInt(), + eq(IpSecTransform.DIRECTION_OUT), + anyString(), + anyString(), + anyLong(), + eq(DROID_SPI), + eq(IpSecAlgorithm.AUTH_HMAC_SHA256), + eq(AUTH_KEY), + anyInt(), + eq(IpSecAlgorithm.CRYPT_AES_CBC), + eq(CRYPT_KEY), + anyInt(), + anyInt(), + anyInt(), + anyInt()); + verify(mMockNetd) + .ipSecAddSecurityAssociation( + eq(createTransformResp.resourceId), + anyInt(), + eq(IpSecTransform.DIRECTION_IN), + anyString(), + anyString(), + anyLong(), + eq(DROID_SPI2), + eq(IpSecAlgorithm.AUTH_HMAC_SHA256), + eq(AUTH_KEY), + anyInt(), + eq(IpSecAlgorithm.CRYPT_AES_CBC), + eq(CRYPT_KEY), + anyInt(), + anyInt(), + anyInt(), + anyInt()); + } + + @Test + public void testDeleteTransportModeTransform() throws Exception { + IpSecConfig ipSecConfig = buildIpSecConfig(); + + IpSecTransformResponse createTransformResp = + mIpSecService.createTransportModeTransform(ipSecConfig, new Binder()); + mIpSecService.deleteTransportModeTransform(createTransformResp.resourceId); + + verify(mMockNetd) + .ipSecDeleteSecurityAssociation( + eq(createTransformResp.resourceId), + eq(IpSecTransform.DIRECTION_OUT), + anyString(), + anyString(), + eq(DROID_SPI)); + verify(mMockNetd) + .ipSecDeleteSecurityAssociation( + eq(createTransformResp.resourceId), + eq(IpSecTransform.DIRECTION_IN), + anyString(), + anyString(), + eq(DROID_SPI2)); + } + + @Test + public void testDeleteInvalidTransportModeTransform() throws Exception { + try { + mIpSecService.deleteTransportModeTransform(1); + fail("IllegalArgumentException not thrown"); + } catch (IllegalArgumentException e) { + } + } + + @Test + public void testApplyTransportModeTransform() throws Exception { + IpSecConfig ipSecConfig = buildIpSecConfig(); + + IpSecTransformResponse createTransformResp = + mIpSecService.createTransportModeTransform(ipSecConfig, new Binder()); + ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(new Socket()); + + int resourceId = createTransformResp.resourceId; + mIpSecService.applyTransportModeTransform(pfd, resourceId); + + verify(mMockNetd) + .ipSecApplyTransportModeTransform( + eq(pfd.getFileDescriptor()), + eq(resourceId), + eq(IpSecTransform.DIRECTION_OUT), + anyString(), + anyString(), + eq(DROID_SPI)); + verify(mMockNetd) + .ipSecApplyTransportModeTransform( + eq(pfd.getFileDescriptor()), + eq(resourceId), + eq(IpSecTransform.DIRECTION_IN), + anyString(), + anyString(), + eq(DROID_SPI2)); + } + + @Test + public void testRemoveTransportModeTransform() throws Exception { + ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(new Socket()); + mIpSecService.removeTransportModeTransform(pfd, 1); + + verify(mMockNetd).ipSecRemoveTransportModeTransform(pfd.getFileDescriptor()); + } +} diff --git a/tests/net/java/com/android/server/connectivity/TetheringTest.java b/tests/net/java/com/android/server/connectivity/TetheringTest.java index 460d53e8f522..6f048e2ccd2f 100644 --- a/tests/net/java/com/android/server/connectivity/TetheringTest.java +++ b/tests/net/java/com/android/server/connectivity/TetheringTest.java @@ -178,6 +178,7 @@ public class TetheringTest { mTethering = new Tethering(mServiceContext, mNMService, mStatsService, mPolicyManager, mLooper.getLooper(), mSystemProperties, mTetheringDependencies); + verify(mNMService).registerTetheringStatsProvider(any(), anyString()); } @After diff --git a/tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java b/tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java index 789ce6c3092a..45525e624d90 100644 --- a/tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java +++ b/tests/net/java/com/android/server/connectivity/tethering/OffloadControllerTest.java @@ -16,26 +16,38 @@ package com.android.server.connectivity.tethering; +import static android.net.NetworkStats.SET_DEFAULT; +import static android.net.NetworkStats.TAG_NONE; +import static android.net.TrafficStats.UID_TETHERING; import static android.provider.Settings.Global.TETHER_OFFLOAD_DISABLED; +import static com.android.server.connectivity.tethering.OffloadHardwareInterface.ForwardedStats; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; import android.content.pm.ApplicationInfo; +import android.net.ITetheringStatsProvider; import android.net.IpPrefix; import android.net.LinkAddress; import android.net.LinkProperties; +import android.net.NetworkStats; import android.net.RouteInfo; import android.net.util.SharedLog; +import android.os.Handler; +import android.os.Looper; +import android.os.INetworkManagementService; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; @@ -66,11 +78,14 @@ public class OffloadControllerTest { @Mock private OffloadHardwareInterface mHardware; @Mock private ApplicationInfo mApplicationInfo; @Mock private Context mContext; + @Mock private INetworkManagementService mNMService; private final ArgumentCaptor<ArrayList> mStringArrayCaptor = ArgumentCaptor.forClass(ArrayList.class); + private final ArgumentCaptor<ITetheringStatsProvider.Stub> mTetherStatsProviderCaptor = + ArgumentCaptor.forClass(ITetheringStatsProvider.Stub.class); private MockContentResolver mContentResolver; - @Before public void setUp() throws Exception { + @Before public void setUp() { MockitoAnnotations.initMocks(this); when(mContext.getApplicationInfo()).thenReturn(mApplicationInfo); when(mContext.getPackageName()).thenReturn("OffloadControllerTest"); @@ -90,15 +105,24 @@ public class OffloadControllerTest { when(mHardware.initOffloadConfig()).thenReturn(true); when(mHardware.initOffloadControl(any(OffloadHardwareInterface.ControlCallback.class))) .thenReturn(true); + when(mHardware.getForwardedStats(any())).thenReturn(new ForwardedStats()); } private void enableOffload() { Settings.Global.putInt(mContentResolver, TETHER_OFFLOAD_DISABLED, 0); } + private OffloadController makeOffloadController() throws Exception { + OffloadController offload = new OffloadController(new Handler(Looper.getMainLooper()), + mHardware, mContentResolver, mNMService, new SharedLog("test")); + verify(mNMService).registerTetheringStatsProvider( + mTetherStatsProviderCaptor.capture(), anyString()); + return offload; + } + // TODO: Restore when FakeSettingsProvider.clearSettingsProvider() is available. // @Test - public void testNoSettingsValueDefaultDisabledDoesNotStart() { + public void testNoSettingsValueDefaultDisabledDoesNotStart() throws Exception { setupFunctioningHardwareInterface(); when(mHardware.getDefaultTetherOffloadDisabled()).thenReturn(1); try { @@ -106,8 +130,7 @@ public class OffloadControllerTest { fail(); } catch (SettingNotFoundException expected) {} - final OffloadController offload = - new OffloadController(null, mHardware, mContentResolver, new SharedLog("test")); + final OffloadController offload = makeOffloadController(); offload.start(); final InOrder inOrder = inOrder(mHardware); @@ -120,7 +143,7 @@ public class OffloadControllerTest { // TODO: Restore when FakeSettingsProvider.clearSettingsProvider() is available. // @Test - public void testNoSettingsValueDefaultEnabledDoesStart() { + public void testNoSettingsValueDefaultEnabledDoesStart() throws Exception { setupFunctioningHardwareInterface(); when(mHardware.getDefaultTetherOffloadDisabled()).thenReturn(0); try { @@ -128,8 +151,7 @@ public class OffloadControllerTest { fail(); } catch (SettingNotFoundException expected) {} - final OffloadController offload = - new OffloadController(null, mHardware, mContentResolver, new SharedLog("test")); + final OffloadController offload = makeOffloadController(); offload.start(); final InOrder inOrder = inOrder(mHardware); @@ -141,12 +163,11 @@ public class OffloadControllerTest { } @Test - public void testSettingsAllowsStart() { + public void testSettingsAllowsStart() throws Exception { setupFunctioningHardwareInterface(); Settings.Global.putInt(mContentResolver, TETHER_OFFLOAD_DISABLED, 0); - final OffloadController offload = - new OffloadController(null, mHardware, mContentResolver, new SharedLog("test")); + final OffloadController offload = makeOffloadController(); offload.start(); final InOrder inOrder = inOrder(mHardware); @@ -158,12 +179,11 @@ public class OffloadControllerTest { } @Test - public void testSettingsDisablesStart() { + public void testSettingsDisablesStart() throws Exception { setupFunctioningHardwareInterface(); Settings.Global.putInt(mContentResolver, TETHER_OFFLOAD_DISABLED, 1); - final OffloadController offload = - new OffloadController(null, mHardware, mContentResolver, new SharedLog("test")); + final OffloadController offload = makeOffloadController(); offload.start(); final InOrder inOrder = inOrder(mHardware); @@ -178,8 +198,7 @@ public class OffloadControllerTest { setupFunctioningHardwareInterface(); enableOffload(); - final OffloadController offload = - new OffloadController(null, mHardware, mContentResolver, new SharedLog("test")); + final OffloadController offload = makeOffloadController(); offload.start(); final InOrder inOrder = inOrder(mHardware); @@ -244,6 +263,7 @@ public class OffloadControllerTest { inOrder.verify(mHardware, never()).setLocalPrefixes(mStringArrayCaptor.capture()); inOrder.verify(mHardware, times(1)).setUpstreamParameters( eq(testIfName), eq(ipv4Addr), eq(null), eq(null)); + inOrder.verify(mHardware, times(1)).getForwardedStats(eq(testIfName)); inOrder.verifyNoMoreInteractions(); final String ipv4Gateway = "192.0.2.1"; @@ -253,6 +273,7 @@ public class OffloadControllerTest { inOrder.verify(mHardware, never()).setLocalPrefixes(mStringArrayCaptor.capture()); inOrder.verify(mHardware, times(1)).setUpstreamParameters( eq(testIfName), eq(ipv4Addr), eq(ipv4Gateway), eq(null)); + inOrder.verify(mHardware, times(1)).getForwardedStats(eq(testIfName)); inOrder.verifyNoMoreInteractions(); final String ipv6Gw1 = "fe80::cafe"; @@ -262,6 +283,7 @@ public class OffloadControllerTest { inOrder.verify(mHardware, never()).setLocalPrefixes(mStringArrayCaptor.capture()); inOrder.verify(mHardware, times(1)).setUpstreamParameters( eq(testIfName), eq(ipv4Addr), eq(ipv4Gateway), mStringArrayCaptor.capture()); + inOrder.verify(mHardware, times(1)).getForwardedStats(eq(testIfName)); ArrayList<String> v6gws = mStringArrayCaptor.getValue(); assertEquals(1, v6gws.size()); assertTrue(v6gws.contains(ipv6Gw1)); @@ -274,6 +296,7 @@ public class OffloadControllerTest { inOrder.verify(mHardware, never()).setLocalPrefixes(mStringArrayCaptor.capture()); inOrder.verify(mHardware, times(1)).setUpstreamParameters( eq(testIfName), eq(ipv4Addr), eq(ipv4Gateway), mStringArrayCaptor.capture()); + inOrder.verify(mHardware, times(1)).getForwardedStats(eq(testIfName)); v6gws = mStringArrayCaptor.getValue(); assertEquals(2, v6gws.size()); assertTrue(v6gws.contains(ipv6Gw1)); @@ -291,6 +314,7 @@ public class OffloadControllerTest { inOrder.verify(mHardware, never()).setLocalPrefixes(mStringArrayCaptor.capture()); inOrder.verify(mHardware, times(1)).setUpstreamParameters( eq(testIfName), eq(ipv4Addr), eq(ipv4Gateway), mStringArrayCaptor.capture()); + inOrder.verify(mHardware, times(1)).getForwardedStats(eq(testIfName)); v6gws = mStringArrayCaptor.getValue(); assertEquals(2, v6gws.size()); assertTrue(v6gws.contains(ipv6Gw1)); @@ -325,6 +349,7 @@ public class OffloadControllerTest { assertEquals(2, v6gws.size()); assertTrue(v6gws.contains(ipv6Gw1)); assertTrue(v6gws.contains(ipv6Gw2)); + inOrder.verify(mHardware, times(1)).getForwardedStats(eq(testIfName)); inOrder.verifyNoMoreInteractions(); // Completely identical LinkProperties updates are de-duped. @@ -335,4 +360,65 @@ public class OffloadControllerTest { anyObject(), anyObject(), anyObject(), anyObject()); inOrder.verifyNoMoreInteractions(); } + + private void assertNetworkStats(String iface, ForwardedStats stats, NetworkStats.Entry entry) { + assertEquals(iface, entry.iface); + assertEquals(stats.rxBytes, entry.rxBytes); + assertEquals(stats.txBytes, entry.txBytes); + assertEquals(SET_DEFAULT, entry.set); + assertEquals(TAG_NONE, entry.tag); + assertEquals(UID_TETHERING, entry.uid); + } + + @Test + public void testGetForwardedStats() throws Exception { + setupFunctioningHardwareInterface(); + enableOffload(); + + final OffloadController offload = makeOffloadController(); + offload.start(); + + final String ethernetIface = "eth1"; + final String mobileIface = "rmnet_data0"; + + ForwardedStats ethernetStats = new ForwardedStats(); + ethernetStats.rxBytes = 12345; + ethernetStats.txBytes = 54321; + + ForwardedStats mobileStats = new ForwardedStats(); + mobileStats.rxBytes = 999; + mobileStats.txBytes = 99999; + + when(mHardware.getForwardedStats(eq(ethernetIface))).thenReturn(ethernetStats); + when(mHardware.getForwardedStats(eq(mobileIface))).thenReturn(mobileStats); + + final LinkProperties lp = new LinkProperties(); + lp.setInterfaceName(ethernetIface); + offload.setUpstreamLinkProperties(lp); + + lp.setInterfaceName(mobileIface); + offload.setUpstreamLinkProperties(lp); + + lp.setInterfaceName(ethernetIface); + offload.setUpstreamLinkProperties(lp); + + ethernetStats.rxBytes = 100000; + ethernetStats.txBytes = 100000; + offload.setUpstreamLinkProperties(null); + + NetworkStats stats = mTetherStatsProviderCaptor.getValue().getTetherStats(); + assertEquals(2, stats.size()); + + NetworkStats.Entry entry = null; + int ethernetPosition = ethernetIface.equals(stats.getValues(0, entry).iface) ? 0 : 1; + int mobilePosition = 1 - ethernetPosition; + + entry = stats.getValues(mobilePosition, entry); + assertNetworkStats(mobileIface, mobileStats, entry); + + ethernetStats.rxBytes = 12345 + 100000; + ethernetStats.txBytes = 54321 + 100000; + entry = stats.getValues(ethernetPosition, entry); + assertNetworkStats(ethernetIface, ethernetStats, entry); + } } diff --git a/tests/net/jni/apf_jni.cpp b/tests/net/jni/apf_jni.cpp index ee43dd488363..82cbb6b7fb0c 100644 --- a/tests/net/jni/apf_jni.cpp +++ b/tests/net/jni/apf_jni.cpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#include <JNIHelp.h> -#include <ScopedUtfChars.h> +#include <nativehelper/JNIHelp.h> +#include <nativehelper/ScopedUtfChars.h> #include <jni.h> #include <pcap.h> #include <stdlib.h> |