diff options
13 files changed, 239 insertions, 63 deletions
| diff --git a/cmds/statsd/Android.mk b/cmds/statsd/Android.mk index 01f4a84bbb93..a7daa3f2b63a 100644 --- a/cmds/statsd/Android.mk +++ b/cmds/statsd/Android.mk @@ -136,7 +136,7 @@ LOCAL_SHARED_LIBRARIES := $(statsd_common_shared_libraries) \  LOCAL_MODULE_CLASS := EXECUTABLES -#LOCAL_INIT_RC := statsd.rc +LOCAL_INIT_RC := statsd.rc  include $(BUILD_EXECUTABLE) diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index f55a59a53466..7a9588d1a2c4 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -108,6 +108,8 @@ message Atom {          CpuIdleTime cpu_idle_time = 10015;          CpuActiveTime cpu_active_time = 10016;          CpuClusterTime cpu_cluster_time = 10017; +        DiskSpace disk_space = 10018; +        SystemUptime system_uptime = 10019;      }  } @@ -1297,4 +1299,27 @@ message CpuClusterTime {      optional uint64 uid = 1;      optional uint64 idx = 2;      optional uint64 time_ms = 3; +} + +/* + * Pulls free disk space, for data, system partition and temporary directory. + */ +message DiskSpace { +    // available bytes in data partition +    optional uint64 data_available_bytes = 1; +    // available bytes in system partition +    optional uint64 system_available_bytes = 2; +    // available bytes in download cache or temp directories +    optional uint64 temp_available_bytes = 3; +} + +/* + * Pulls system up time. + */ +message SystemUptime { +    // Milliseconds since the system was booted. +    // This clock stops when the system enters deep sleep (CPU off, display dark, device waiting +    // for external input). +    // It is not affected by clock scaling, idle, or other power saving mechanisms. +    optional uint64 uptime_ms = 1;  }
\ No newline at end of file diff --git a/cmds/statsd/src/external/StatsPullerManagerImpl.cpp b/cmds/statsd/src/external/StatsPullerManagerImpl.cpp index 79f1a5d84174..e06ae48f7215 100644 --- a/cmds/statsd/src/external/StatsPullerManagerImpl.cpp +++ b/cmds/statsd/src/external/StatsPullerManagerImpl.cpp @@ -66,6 +66,15 @@ StatsPullerManagerImpl::StatsPullerManagerImpl()      mPullers.insert({android::util::CPU_TIME_PER_UID_FREQ, make_shared<CpuTimePerUidFreqPuller>()});      mPullers.insert({android::util::CPU_SUSPEND_TIME, make_shared<StatsCompanionServicePuller>(android::util::CPU_SUSPEND_TIME)});      mPullers.insert({android::util::CPU_IDLE_TIME, make_shared<StatsCompanionServicePuller>(android::util::CPU_IDLE_TIME)}); +    mPullers.insert({android::util::DISK_SPACE, +                     make_shared<StatsCompanionServicePuller>(android::util::DISK_SPACE)}); +    mPullers.insert({android::util::SYSTEM_UPTIME, +                     make_shared<StatsCompanionServicePuller>(android::util::SYSTEM_UPTIME)}); +    mPullers.insert( +            {android::util::WIFI_ACTIVITY_ENERGY_INFO, +             make_shared<StatsCompanionServicePuller>(android::util::WIFI_ACTIVITY_ENERGY_INFO)}); +    mPullers.insert({android::util::MODEM_ACTIVITY_INFO, +                     make_shared<StatsCompanionServicePuller>(android::util::MODEM_ACTIVITY_INFO)});      mStatsCompanionService = StatsService::getStatsCompanionService();  } diff --git a/cmds/statsd/src/logd/LogReader.cpp b/cmds/statsd/src/logd/LogReader.cpp index 7636268ccd3a..5d43ef3f88bd 100644 --- a/cmds/statsd/src/logd/LogReader.cpp +++ b/cmds/statsd/src/logd/LogReader.cpp @@ -98,7 +98,10 @@ int LogReader::connect_and_read() {              // Read a message              err = android_logger_list_read(loggers, &msg); -            if (err < 0) { +            // err = 0 - no content, unexpected connection drop or EOF. +            // err = +ive number - size of retrieved data from logger +            // err = -ive number, OS supplied error _except_ for -EAGAIN +            if (err <= 0) {                  fprintf(stderr, "logcat read failure: %s\n", strerror(err));                  break;              } diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 4228fbb7c40e..0e323f8570a0 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -9424,6 +9424,14 @@ public final class Settings {         public static final String WIFI_VERBOSE_LOGGING_ENABLED =                 "wifi_verbose_logging_enabled"; +        /** +         * Setting to enable connected MAC randomization in Wi-Fi; disabled by default, and +         * setting to 1 will enable it. In the future, additional values may be supported. +         * @hide +         */ +        public static final String WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED = +                "wifi_connected_mac_randomization_enabled"; +         /**          * The maximum number of times we will retry a connection to an access          * point for which we have failed in acquiring an IP address from DHCP. diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java index 4e98d9b09318..9f9033cff96a 100644 --- a/core/java/android/util/FeatureFlagUtils.java +++ b/core/java/android/util/FeatureFlagUtils.java @@ -45,6 +45,7 @@ public class FeatureFlagUtils {          DEFAULT_FLAGS.put("settings_security_settings_v2", "true");          DEFAULT_FLAGS.put("settings_zone_picker_v2", "true");          DEFAULT_FLAGS.put("settings_suggestion_ui_v2", "false"); +        DEFAULT_FLAGS.put("settings_about_phone_v2", "false");      }      /** diff --git a/core/java/android/widget/VideoView2.java b/core/java/android/widget/VideoView2.java index f4a4ea921415..56f3dbd1e94e 100644 --- a/core/java/android/widget/VideoView2.java +++ b/core/java/android/widget/VideoView2.java @@ -34,46 +34,95 @@ import java.lang.annotation.Retention;  import java.lang.annotation.RetentionPolicy;  import java.util.Map; +// TODO: Use @link tag to refer MediaPlayer2 in docs once MediaPlayer2.java is submitted. Same to +// MediaSession2. +// TODO: change the reference from MediaPlayer to MediaPlayer2.  /** - * TODO PUBLIC API + * Displays a video file.  VideoView2 class is a View class which is wrapping MediaPlayer2 so that + * developers can easily implement a video rendering application. + * + * <p> + * <em> Data sources that VideoView2 supports : </em> + * VideoView2 can play video files and audio-only fiels as + * well. It can load from various sources such as resources or content providers. The supported + * media file formats are the same as MediaPlayer2. + * + * <p> + * <em> View type can be selected : </em> + * VideoView2 can render videos on top of TextureView as well as + * SurfaceView selectively. The default is SurfaceView and it can be changed using + * {@link #setViewType(int)} method. Using SurfaceView is recommended in most cases for saving + * battery. TextureView might be preferred for supporting various UIs such as animation and + * translucency. + * + * <p> + * <em> Differences between {@link VideoView} class : </em> + * VideoView2 covers and inherits the most of + * VideoView's functionalities. The main differences are + * <ul> + * <li> VideoView2 inherits FrameLayout and renders videos using SurfaceView and TextureView + * selectively while VideoView inherits SurfaceView class. + * <li> VideoView2 is integrated with MediaControlView2 and a default MediaControlView2 instance is + * attached to VideoView2 by default. If a developer does not want to use the default + * MediaControlView2, needs to set enableControlView attribute to false. For instance, + * <pre> + * <VideoView2 + *     android:id="@+id/video_view" + *     xmlns:widget="http://schemas.android.com/apk/com.android.media.update" + *     widget:enableControlView="false" /> + * </pre> + * If a developer wants to attach a customed MediaControlView2, then set enableControlView attribute + * to false and assign the customed media control widget using {@link #setMediaControlView2}. + * <li> VideoView2 is integrated with MediaPlayer2 while VideoView is integrated with MediaPlayer. + * <li> VideoView2 is integrated with MediaSession2 and so it responses with media key events. + * A VideoView2 keeps a MediaSession2 instance internally and connects it to a corresponding + * MediaControlView2 instance. + * </p> + * </ul> + * + * <p> + * <em> Audio focus and audio attributes : </em> + * By default, VideoView2 requests audio focus with + * {@link AudioManager#AUDIOFOCUS_GAIN}. Use {@link #setAudioFocusRequest(int)} to change this + * behavior. The default {@link AudioAttributes} used during playback have a usage of + * {@link AudioAttributes#USAGE_MEDIA} and a content type of + * {@link AudioAttributes#CONTENT_TYPE_MOVIE}, use {@link #setAudioAttributes(AudioAttributes)} to + * modify them. + * + * <p> + * Note: VideoView2 does not retain its full state when going into the background. In particular, it + * does not restore the current play state, play position, selected tracks. Applications should save + * and restore these on their own in {@link android.app.Activity#onSaveInstanceState} and + * {@link android.app.Activity#onRestoreInstanceState}. + *   * @hide   */  public class VideoView2 extends FrameLayout { +    /** @hide */      @IntDef({              VIEW_TYPE_TEXTUREVIEW,              VIEW_TYPE_SURFACEVIEW      })      @Retention(RetentionPolicy.SOURCE)      public @interface ViewType {} +      public static final int VIEW_TYPE_SURFACEVIEW = 1;      public static final int VIEW_TYPE_TEXTUREVIEW = 2;      private final VideoView2Provider mProvider; -    /** -     * @hide -     */      public VideoView2(@NonNull Context context) {          this(context, null);      } -    /** -     * @hide -     */      public VideoView2(@NonNull Context context, @Nullable AttributeSet attrs) {          this(context, attrs, 0);      } -    /** -     * @hide -     */      public VideoView2(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {          this(context, attrs, defStyleAttr, 0);      } -    /** -     * @hide -     */      public VideoView2(              @NonNull Context context, @Nullable AttributeSet attrs,              int defStyleAttr, int defStyleRes) { @@ -91,89 +140,102 @@ public class VideoView2 extends FrameLayout {      }      /** -     * @hide +     * Sets MediaControlView2 instance. It will replace the previously assigned MediaControlView2 +     * instance if any. +     * +     * @param mediaControlView a media control view2 instance.       */      public void setMediaControlView2(MediaControlView2 mediaControlView) {          mProvider.setMediaControlView2_impl(mediaControlView);      }      /** -     * @hide +     * Returns MediaControlView2 instance which is currently attached to VideoView2 by default or by +     * {@link #setMediaControlView2} method.       */      public MediaControlView2 getMediaControlView2() {          return mProvider.getMediaControlView2_impl();      }      /** -     * @hide +     * Starts playback with the media contents specified by {@link #setVideoURI} and +     * {@link #setVideoPath}. +     * If it has been paused, this method will resume playback from the current position.       */      public void start() {          mProvider.start_impl();      }      /** -     * @hide +     * Pauses playback.       */      public void pause() {          mProvider.pause_impl();      }      /** -     * @hide +     * Gets the duration of the media content specified by #setVideoURI and #setVideoPath +     * in milliseconds.       */      public int getDuration() {          return mProvider.getDuration_impl();      }      /** -     * @hide +     * Gets current playback position in milliseconds.       */      public int getCurrentPosition() {          return mProvider.getCurrentPosition_impl();      } +    // TODO: mention about key-frame related behavior.      /** -     * @hide +     * Moves the media by specified time position. +     * @param msec the offset in milliseconds from the start to seek to.       */      public void seekTo(int msec) {          mProvider.seekTo_impl(msec);      }      /** -     * @hide +     * Says if the media is currently playing. +     * @return true if the media is playing, false if it is not (eg. paused or stopped).       */      public boolean isPlaying() {          return mProvider.isPlaying_impl();      } +    // TODO: check what will return if it is a local media.      /** -     * @hide +     * Gets the percentage (0-100) of the content that has been buffered or played so far.       */      public int getBufferPercentage() {          return mProvider.getBufferPercentage_impl();      }      /** -     * @hide +     * Returns the audio session ID.       */      public int getAudioSessionId() {          return mProvider.getAudioSessionId_impl();      }      /** -     * @hide +     * Starts rendering closed caption or subtitles if there is any. The first subtitle track will +     * be chosen by default if there multiple subtitle tracks exist.       */      public void showSubtitle() {          mProvider.showSubtitle_impl();      }      /** -     * @hide +     * Stops showing closed captions or subtitles.       */      public void hideSubtitle() {          mProvider.hideSubtitle_impl();      } +    // TODO: This should be revised after integration with MediaPlayer2.      /**       * Sets playback speed.       * @@ -181,9 +243,7 @@ public class VideoView2 extends FrameLayout {       * or equal to zero, it will be just ignored and nothing will be changed. If it exceeds the       * maximum speed that internal engine supports, system will determine best handling or it will       * be reset to the normal speed 1.0f. -     * TODO: This should be revised after integration with MediaPlayer2.       * @param speed the playback speed. It should be positive. -     * @hide       */      public void setSpeed(float speed) {          mProvider.setSpeed_impl(speed); @@ -194,7 +254,6 @@ public class VideoView2 extends FrameLayout {       *       * If setSpeed() has never been called, returns the default value 1.0f.       * @return current speed setting -     * @hide       */      public float getSpeed() {          return mProvider.getSpeed_impl(); @@ -213,8 +272,6 @@ public class VideoView2 extends FrameLayout {       *       * @param focusGain the type of audio focus gain that will be requested, or       *     {@link AudioManager#AUDIOFOCUS_NONE} to disable the use audio focus during playback. -     * -     * @hide       */      public void setAudioFocusRequest(int focusGain) {          mProvider.setAudioFocusRequest_impl(focusGain); @@ -224,8 +281,6 @@ public class VideoView2 extends FrameLayout {       * Sets the {@link AudioAttributes} to be used during the playback of the video.       *       * @param attributes non-null <code>AudioAttributes</code>. -     * -     * @hide       */      public void setAudioAttributes(@NonNull AudioAttributes attributes) {          mProvider.setAudioAttributes_impl(attributes); @@ -235,35 +290,51 @@ public class VideoView2 extends FrameLayout {       * Sets video path.       *       * @param path the path of the video. -     * @hide       */      public void setVideoPath(String path) {          mProvider.setVideoPath_impl(path);      }      /** -     * @hide +     * Sets video URI. +     * +     * @param uri the URI of the video.       */      public void setVideoURI(Uri uri) {          mProvider.setVideoURI_impl(uri);      }      /** -     * @hide +     * Sets video URI using specific headers. +     * +     * @param uri     the URI of the video. +     * @param headers the headers for the URI request. +     *                Note that the cross domain redirection is allowed by default, but that can be +     *                changed with key/value pairs through the headers parameter with +     *                "android-allow-cross-domain-redirect" as the key and "0" or "1" as the value +     *                to disallow or allow cross domain redirection.       */      public void setVideoURI(Uri uri, Map<String, String> headers) {          mProvider.setVideoURI_impl(uri, headers);      }      /** -     * @hide +     * Selects which view will be used to render video between SurfacView and TextureView. +     * +     * @param viewType the view type to render video +     * <ul> +     * <li>{@link #VIEW_TYPE_SURFACEVIEW} +     * <li>{@link #VIEW_TYPE_TEXTUREVIEW} +     * </ul>       */      public void setViewType(@ViewType int viewType) {          mProvider.setViewType_impl(viewType);      }      /** -     * @hide +     * Returns view type. +     * +     * @return view type. See {@see setViewType}.       */      @ViewType      public int getViewType() { @@ -271,42 +342,57 @@ public class VideoView2 extends FrameLayout {      }      /** -     * @hide +     * Stops playback and release all the resources. This should be called whenever a VideoView2 +     * instance is no longer to be used.       */      public void stopPlayback() {          mProvider.stopPlayback_impl();      }      /** -     * @hide +     * Registers a callback to be invoked when the media file is loaded and ready to go. +     * +     * @param l the callback that will be run.       */      public void setOnPreparedListener(OnPreparedListener l) {          mProvider.setOnPreparedListener_impl(l);      }      /** -     * @hide +     * Registers a callback to be invoked when the end of a media file has been reached during +     * playback. +     * +     * @param l the callback that will be run.       */      public void setOnCompletionListener(OnCompletionListener l) {          mProvider.setOnCompletionListener_impl(l);      }      /** -     * @hide +     * Registers a callback to be invoked when an error occurs during playback or setup.  If no +     * listener is specified, or if the listener returned false, VideoView2 will inform the user of +     * any errors. +     * +     * @param l The callback that will be run       */      public void setOnErrorListener(OnErrorListener l) {          mProvider.setOnErrorListener_impl(l);      }      /** -     * @hide +     * Registers a callback to be invoked when an informational event occurs during playback or +     * setup. +     * +     * @param l The callback that will be run       */      public void setOnInfoListener(OnInfoListener l) {          mProvider.setOnInfoListener_impl(l);      }      /** -     * @hide +     * Registers a callback to be invoked when a view type change is done. +     * {@see #setViewType(int)} +     * @param l The callback that will be run       */      public void setOnViewTypeChangedListener(OnViewTypeChangedListener l) {          mProvider.setOnViewTypeChangedListener_impl(l); @@ -314,18 +400,22 @@ public class VideoView2 extends FrameLayout {      /**       * Interface definition of a callback to be invoked when the viw type has been changed. -     * @hide       */      public interface OnViewTypeChangedListener {          /**           * Called when the view type has been changed. -         * @see VideoView2#setViewType(int) +         * @see #setViewType(int) +         * @param viewType +         * <ul> +         * <li>{@link #VIEW_TYPE_SURFACEVIEW} +         * <li>{@link #VIEW_TYPE_TEXTUREVIEW} +         * </ul>           */          void onViewTypeChanged(@ViewType int viewType);      }      /** -     * @hide +     * Interface definition of a callback to be invoked when the media source is ready for playback.       */      public interface OnPreparedListener {          /** @@ -335,7 +425,8 @@ public class VideoView2 extends FrameLayout {      }      /** -     * @hide +     * Interface definition for a callback to be invoked when playback of a media source has +     * completed.       */      public interface OnCompletionListener {          /** @@ -345,25 +436,32 @@ public class VideoView2 extends FrameLayout {      }      /** -     * @hide +     * Interface definition of a callback to be invoked when there has been an error during an +     * asynchronous operation.       */      public interface OnErrorListener { +        // TODO: Redefine error codes.          /**           * Called to indicate an error. +         * @param what the type of error that has occurred +         * @param extra an extra code, specific to the error. +         * @return true if the method handled the error, false if it didn't. +         * @see MediaPlayer#OnErrorListener           */          boolean onError(int what, int extra);      }      /** -     * @hide +     * Interface definition of a callback to be invoked to communicate some info and/or warning +     * about the media or its playback.       */      public interface OnInfoListener {          /**           * Called to indicate an info or a warning. -         * @see MediaPlayer#OnInfoListener -         *           * @param what the type of info or warning.           * @param extra an extra code, specific to the info. +         * +         * @see MediaPlayer#OnInfoListener           */          void onInfo(int what, int extra);      } diff --git a/core/proto/android/providers/settings.proto b/core/proto/android/providers/settings.proto index 8d6df12d56dd..95eb889a3f3a 100644 --- a/core/proto/android/providers/settings.proto +++ b/core/proto/android/providers/settings.proto @@ -391,8 +391,9 @@ message GlobalSettingsProto {      optional SettingProto zram_enabled = 347;      optional SettingProto enable_smart_replies_in_notifications = 348;      optional SettingProto show_first_crash_dialog = 349; +    optional SettingProto wifi_connected_mac_randomization_enabled = 350; -    // Next tag = 350; +    // Next tag = 351;  }  message SecureSettingsProto { diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java index fa0ea5c3aa85..7403c26dd5b5 100644 --- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java +++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java @@ -391,6 +391,7 @@ public class SettingsBackupTest {                      Settings.Global.WFC_IMS_ROAMING_MODE,                      Settings.Global.WIFI_BADGING_THRESHOLDS,                      Settings.Global.WIFI_BOUNCE_DELAY_OVERRIDE_MS, +                    Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED,                      Settings.Global.WIFI_COUNTRY_CODE,                      Settings.Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN,                      Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON, diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml index f6541bb92fb4..042767d39f84 100644 --- a/packages/SettingsLib/res/values/strings.xml +++ b/packages/SettingsLib/res/values/strings.xml @@ -498,6 +498,8 @@      <string name="wifi_display_certification">Wireless display certification</string>      <!-- Setting Checkbox title whether to enable WiFi Verbose Logging. [CHAR LIMIT=40] -->      <string name="wifi_verbose_logging">Enable Wi\u2011Fi Verbose Logging</string> +    <!-- Setting Checkbox title whether to enable connected MAC randomization --> +    <string name="wifi_connected_mac_randomization">Connected MAC Randomization</string>      <!-- Setting Checkbox title whether to always keep mobile data active. [CHAR LIMIT=80] -->      <string name="mobile_data_always_on">Mobile data always active</string>      <!-- Setting Checkbox title whether to enable hardware acceleration for tethering. [CHAR LIMIT=80] --> @@ -552,6 +554,8 @@      <string name="wifi_display_certification_summary">Show options for wireless display certification</string>      <!-- Setting Checkbox summary whether to enable Wifi verbose Logging [CHAR LIMIT=80] -->      <string name="wifi_verbose_logging_summary">Increase Wi\u2011Fi logging level, show per SSID RSSI in Wi\u2011Fi Picker</string> +    <!-- Setting Checkbox title whether to enable connected MAC randomization --> +    <string name="wifi_connected_mac_randomization_summary">Randomize MAC address when connecting to Wi\u2011Fi networks</string>      <!-- UI debug setting: limit size of Android logger buffers -->      <string name="select_logd_size_title">Logger buffer sizes</string>      <!-- UI debug setting: limit size of Android logger buffers [CHAR LIMIT=59] --> diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java index 87ed7eb705e9..5a75681f43c4 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java @@ -1128,6 +1128,9 @@ class SettingsProtoDumpUtil {          dumpSetting(s, p,                  Settings.Global.SHOW_FIRST_CRASH_DIALOG,                  GlobalSettingsProto.SHOW_FIRST_CRASH_DIALOG); +        dumpSetting(s, p, +                    Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, +                    GlobalSettingsProto.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED);      }      /** Dump a single {@link SettingsState.Setting} to a proto buf */ diff --git a/services/core/java/com/android/server/stats/StatsCompanionService.java b/services/core/java/com/android/server/stats/StatsCompanionService.java index 4cb5e089bd83..f82dc24f3d61 100644 --- a/services/core/java/com/android/server/stats/StatsCompanionService.java +++ b/services/core/java/com/android/server/stats/StatsCompanionService.java @@ -28,12 +28,10 @@ import android.content.pm.UserInfo;  import android.net.NetworkStats;  import android.net.wifi.IWifiManager;  import android.net.wifi.WifiActivityEnergyInfo; -import android.os.SystemClock; -import android.telephony.ModemActivityInfo; -import android.telephony.TelephonyManager;  import android.os.BatteryStatsInternal;  import android.os.Binder;  import android.os.Bundle; +import android.os.Environment;  import android.os.IBinder;  import android.os.IStatsCompanionService;  import android.os.IStatsManager; @@ -41,18 +39,22 @@ import android.os.Parcelable;  import android.os.Process;  import android.os.RemoteException;  import android.os.ServiceManager; +import android.os.StatFs;  import android.os.StatsLogEventWrapper;  import android.os.SynchronousResultReceiver; +import android.os.SystemClock;  import android.os.UserHandle;  import android.os.UserManager; +import android.telephony.ModemActivityInfo; +import android.telephony.TelephonyManager;  import android.util.Slog;  import android.util.StatsLog;  import com.android.internal.annotations.GuardedBy;  import com.android.internal.net.NetworkStatsFactory; +import com.android.internal.os.KernelCpuSpeedReader;  import com.android.internal.os.KernelWakelockReader;  import com.android.internal.os.KernelWakelockStats; -import com.android.internal.os.KernelCpuSpeedReader;  import com.android.internal.os.PowerProfile;  import com.android.server.LocalServices;  import com.android.server.SystemService; @@ -97,6 +99,11 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {      private final KernelCpuSpeedReader[] mKernelCpuSpeedReaders;      private IWifiManager mWifiManager = null;      private TelephonyManager mTelephony = null; +    private final StatFs mStatFsData = new StatFs(Environment.getDataDirectory().getAbsolutePath()); +    private final StatFs mStatFsSystem = +        new StatFs(Environment.getRootDirectory().getAbsolutePath()); +    private final StatFs mStatFsTemp = +        new StatFs(Environment.getDownloadCacheDirectory().getAbsolutePath());      public StatsCompanionService(Context context) {          super(); @@ -560,7 +567,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {                      if (clusterTimeMs != null) {                          for (int speed = clusterTimeMs.length - 1; speed >= 0; --speed) {                              StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 3); -                            e.writeInt(tagId); +                            e.writeInt(cluster);                              e.writeInt(speed);                              e.writeLong(clusterTimeMs[speed]);                              ret.add(e); @@ -589,6 +596,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {                          e.writeLong(wifiInfo.getControllerIdleTimeMillis());                          e.writeLong(wifiInfo.getControllerEnergyUsed());                          ret.add(e); +                        return ret.toArray(new StatsLogEventWrapper[ret.size()]);                      } catch (RemoteException e) {                          Slog.e(TAG, "Pulling wifiManager for wifi controller activity energy info has error", e);                      } finally { @@ -619,6 +627,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {                      e.writeLong(modemInfo.getRxTimeMillis());                      e.writeLong(modemInfo.getEnergyUsed());                      ret.add(e); +                    return ret.toArray(new StatsLogEventWrapper[ret.size()]);                  }                  break;              } @@ -627,14 +636,30 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {                  StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 1);                  e.writeLong(SystemClock.elapsedRealtime());                  ret.add(e); -                break; +                return ret.toArray(new StatsLogEventWrapper[ret.size()]);              }              case StatsLog.CPU_IDLE_TIME: {                  List<StatsLogEventWrapper> ret = new ArrayList();                  StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 1);                  e.writeLong(SystemClock.uptimeMillis());                  ret.add(e); -                break; +                return ret.toArray(new StatsLogEventWrapper[ret.size()]); +            } +            case StatsLog.DISK_SPACE: { +              List<StatsLogEventWrapper> ret = new ArrayList(); +              StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 3); +              e.writeLong(mStatFsData.getAvailableBytes()); +              e.writeLong(mStatFsSystem.getAvailableBytes()); +              e.writeLong(mStatFsTemp.getAvailableBytes()); +              ret.add(e); +              return ret.toArray(new StatsLogEventWrapper[ret.size()]); +            } +            case StatsLog.SYSTEM_UPTIME: { +              List<StatsLogEventWrapper> ret = new ArrayList(); +              StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, 1); +              e.writeLong(SystemClock.uptimeMillis()); +              ret.add(e); +              return ret.toArray(new StatsLogEventWrapper[ret.size()]);              }              default:                  Slog.w(TAG, "No such tagId data as " + tagId); diff --git a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java index 7c3082fb93de..045b73c59345 100644 --- a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java @@ -134,7 +134,6 @@ import com.google.common.util.concurrent.AbstractFuture;  import org.junit.After;  import org.junit.Before; -import org.junit.Ignore;  import org.junit.Rule;  import org.junit.Test;  import org.junit.rules.MethodRule; @@ -185,7 +184,6 @@ import java.util.stream.Collectors;      "com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner"   * </code></pre>   */ -@Ignore  @RunWith(AndroidJUnit4.class)  @MediumTest  public class NetworkPolicyManagerServiceTest { |