11b012d302b56b4adf950035136d1d191a1936d5aJeff Hao/* 21b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * Copyright (C) 2014 The Android Open Source Project 31b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * 41b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * Licensed under the Apache License, Version 2.0 (the "License"); 51b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * you may not use this file except in compliance with the License. 61b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * You may obtain a copy of the License at 71b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * 81b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * http://www.apache.org/licenses/LICENSE-2.0 91b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * 101b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * Unless required by applicable law or agreed to in writing, software 111b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * distributed under the License is distributed on an "AS IS" BASIS, 121b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * See the License for the specific language governing permissions and 141b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * limitations under the License. 151b012d302b56b4adf950035136d1d191a1936d5aJeff Hao */ 161b012d302b56b4adf950035136d1d191a1936d5aJeff Hao 171b012d302b56b4adf950035136d1d191a1936d5aJeff Haopackage android.app; 181b012d302b56b4adf950035136d1d191a1936d5aJeff Hao 191b012d302b56b4adf950035136d1d191a1936d5aJeff Haoimport android.os.Parcel; 201b012d302b56b4adf950035136d1d191a1936d5aJeff Haoimport android.os.Parcelable; 211b012d302b56b4adf950035136d1d191a1936d5aJeff Haoimport android.os.ParcelFileDescriptor; 221b012d302b56b4adf950035136d1d191a1936d5aJeff Hao 231b012d302b56b4adf950035136d1d191a1936d5aJeff Hao/** 241b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * System private API for passing profiler settings. 251b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * 261b012d302b56b4adf950035136d1d191a1936d5aJeff Hao * {@hide} 271b012d302b56b4adf950035136d1d191a1936d5aJeff Hao */ 281b012d302b56b4adf950035136d1d191a1936d5aJeff Haopublic class ProfilerInfo implements Parcelable { 291b012d302b56b4adf950035136d1d191a1936d5aJeff Hao 301b012d302b56b4adf950035136d1d191a1936d5aJeff Hao /* Name of profile output file. */ 311b012d302b56b4adf950035136d1d191a1936d5aJeff Hao public final String profileFile; 321b012d302b56b4adf950035136d1d191a1936d5aJeff Hao 331b012d302b56b4adf950035136d1d191a1936d5aJeff Hao /* File descriptor for profile output file, can be null. */ 341b012d302b56b4adf950035136d1d191a1936d5aJeff Hao public ParcelFileDescriptor profileFd; 351b012d302b56b4adf950035136d1d191a1936d5aJeff Hao 361b012d302b56b4adf950035136d1d191a1936d5aJeff Hao /* Indicates sample profiling when nonzero, interval in microseconds. */ 371b012d302b56b4adf950035136d1d191a1936d5aJeff Hao public final int samplingInterval; 381b012d302b56b4adf950035136d1d191a1936d5aJeff Hao 391b012d302b56b4adf950035136d1d191a1936d5aJeff Hao /* Automatically stop the profiler when the app goes idle. */ 401b012d302b56b4adf950035136d1d191a1936d5aJeff Hao public final boolean autoStopProfiler; 411b012d302b56b4adf950035136d1d191a1936d5aJeff Hao 426ffd4f9bab6b4c83f40caa6455664c6e6aadc6dfShukang Zhou /* Indicates whether to stream the profiling info to the out file continuously. */ 436ffd4f9bab6b4c83f40caa6455664c6e6aadc6dfShukang Zhou public final boolean streamingOutput; 446ffd4f9bab6b4c83f40caa6455664c6e6aadc6dfShukang Zhou 456ffd4f9bab6b4c83f40caa6455664c6e6aadc6dfShukang Zhou public ProfilerInfo(String filename, ParcelFileDescriptor fd, int interval, boolean autoStop, 466ffd4f9bab6b4c83f40caa6455664c6e6aadc6dfShukang Zhou boolean streaming) { 471b012d302b56b4adf950035136d1d191a1936d5aJeff Hao profileFile = filename; 481b012d302b56b4adf950035136d1d191a1936d5aJeff Hao profileFd = fd; 491b012d302b56b4adf950035136d1d191a1936d5aJeff Hao samplingInterval = interval; 501b012d302b56b4adf950035136d1d191a1936d5aJeff Hao autoStopProfiler = autoStop; 516ffd4f9bab6b4c83f40caa6455664c6e6aadc6dfShukang Zhou streamingOutput = streaming; 521b012d302b56b4adf950035136d1d191a1936d5aJeff Hao } 531b012d302b56b4adf950035136d1d191a1936d5aJeff Hao 541b012d302b56b4adf950035136d1d191a1936d5aJeff Hao public int describeContents() { 551b012d302b56b4adf950035136d1d191a1936d5aJeff Hao if (profileFd != null) { 561b012d302b56b4adf950035136d1d191a1936d5aJeff Hao return profileFd.describeContents(); 571b012d302b56b4adf950035136d1d191a1936d5aJeff Hao } else { 581b012d302b56b4adf950035136d1d191a1936d5aJeff Hao return 0; 591b012d302b56b4adf950035136d1d191a1936d5aJeff Hao } 601b012d302b56b4adf950035136d1d191a1936d5aJeff Hao } 611b012d302b56b4adf950035136d1d191a1936d5aJeff Hao 621b012d302b56b4adf950035136d1d191a1936d5aJeff Hao public void writeToParcel(Parcel out, int flags) { 631b012d302b56b4adf950035136d1d191a1936d5aJeff Hao out.writeString(profileFile); 641b012d302b56b4adf950035136d1d191a1936d5aJeff Hao if (profileFd != null) { 651b012d302b56b4adf950035136d1d191a1936d5aJeff Hao out.writeInt(1); 661b012d302b56b4adf950035136d1d191a1936d5aJeff Hao profileFd.writeToParcel(out, flags); 671b012d302b56b4adf950035136d1d191a1936d5aJeff Hao } else { 681b012d302b56b4adf950035136d1d191a1936d5aJeff Hao out.writeInt(0); 691b012d302b56b4adf950035136d1d191a1936d5aJeff Hao } 701b012d302b56b4adf950035136d1d191a1936d5aJeff Hao out.writeInt(samplingInterval); 711b012d302b56b4adf950035136d1d191a1936d5aJeff Hao out.writeInt(autoStopProfiler ? 1 : 0); 726ffd4f9bab6b4c83f40caa6455664c6e6aadc6dfShukang Zhou out.writeInt(streamingOutput ? 1 : 0); 731b012d302b56b4adf950035136d1d191a1936d5aJeff Hao } 741b012d302b56b4adf950035136d1d191a1936d5aJeff Hao 751b012d302b56b4adf950035136d1d191a1936d5aJeff Hao public static final Parcelable.Creator<ProfilerInfo> CREATOR = 761b012d302b56b4adf950035136d1d191a1936d5aJeff Hao new Parcelable.Creator<ProfilerInfo>() { 771b012d302b56b4adf950035136d1d191a1936d5aJeff Hao public ProfilerInfo createFromParcel(Parcel in) { 781b012d302b56b4adf950035136d1d191a1936d5aJeff Hao return new ProfilerInfo(in); 791b012d302b56b4adf950035136d1d191a1936d5aJeff Hao } 801b012d302b56b4adf950035136d1d191a1936d5aJeff Hao 811b012d302b56b4adf950035136d1d191a1936d5aJeff Hao public ProfilerInfo[] newArray(int size) { 821b012d302b56b4adf950035136d1d191a1936d5aJeff Hao return new ProfilerInfo[size]; 831b012d302b56b4adf950035136d1d191a1936d5aJeff Hao } 841b012d302b56b4adf950035136d1d191a1936d5aJeff Hao }; 851b012d302b56b4adf950035136d1d191a1936d5aJeff Hao 861b012d302b56b4adf950035136d1d191a1936d5aJeff Hao private ProfilerInfo(Parcel in) { 871b012d302b56b4adf950035136d1d191a1936d5aJeff Hao profileFile = in.readString(); 881b012d302b56b4adf950035136d1d191a1936d5aJeff Hao profileFd = in.readInt() != 0 ? ParcelFileDescriptor.CREATOR.createFromParcel(in) : null; 891b012d302b56b4adf950035136d1d191a1936d5aJeff Hao samplingInterval = in.readInt(); 901b012d302b56b4adf950035136d1d191a1936d5aJeff Hao autoStopProfiler = in.readInt() != 0; 916ffd4f9bab6b4c83f40caa6455664c6e6aadc6dfShukang Zhou streamingOutput = in.readInt() != 0; 921b012d302b56b4adf950035136d1d191a1936d5aJeff Hao } 931b012d302b56b4adf950035136d1d191a1936d5aJeff Hao} 94