Merge "Protobufferize PowerManager dumpsys"
This commit is contained in:
committed by
Android (Google) Code Review
commit
bf07da5650
@@ -18,8 +18,10 @@ package android.os;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.os.LooperProto;
|
||||
import android.util.Log;
|
||||
import android.util.Printer;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
/**
|
||||
* Class used to run a message loop for a thread. Threads by default do
|
||||
@@ -289,6 +291,16 @@ public final class Looper {
|
||||
mQueue.dump(pw, prefix + " ");
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void writeToProto(ProtoOutputStream proto, long fieldId) {
|
||||
final long looperToken = proto.start(fieldId);
|
||||
proto.write(LooperProto.THREAD_NAME, mThread.getName());
|
||||
proto.write(LooperProto.THREAD_ID, mThread.getId());
|
||||
proto.write(LooperProto.IDENTITY_HASH_CODE, System.identityHashCode(this));
|
||||
mQueue.writeToProto(proto, LooperProto.QUEUE);
|
||||
proto.end(looperToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Looper (" + mThread.getName() + ", tid " + mThread.getId()
|
||||
|
||||
@@ -16,13 +16,15 @@
|
||||
|
||||
package android.os;
|
||||
|
||||
import android.os.MessageProto;
|
||||
import android.util.TimeUtils;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Defines a message containing a description and arbitrary data object that can be
|
||||
* sent to a {@link Handler}. This object contains two extra int fields and an
|
||||
* extra object field that allow you to not do allocations in many cases.
|
||||
* extra object field that allow you to not do allocations in many cases.
|
||||
*
|
||||
* <p class="note">While the constructor of Message is public, the best way to get
|
||||
* one of these is to call {@link #obtain Message.obtain()} or one of the
|
||||
@@ -31,7 +33,7 @@ import android.util.TimeUtils;
|
||||
*/
|
||||
public final class Message implements Parcelable {
|
||||
/**
|
||||
* User-defined message code so that the recipient can identify
|
||||
* User-defined message code so that the recipient can identify
|
||||
* what this message is about. Each {@link Handler} has its own name-space
|
||||
* for message codes, so you do not need to worry about yours conflicting
|
||||
* with other handlers.
|
||||
@@ -43,7 +45,7 @@ public final class Message implements Parcelable {
|
||||
* {@link #setData(Bundle) setData()} if you only need to store a
|
||||
* few integer values.
|
||||
*/
|
||||
public int arg1;
|
||||
public int arg1;
|
||||
|
||||
/**
|
||||
* arg1 and arg2 are lower-cost alternatives to using
|
||||
@@ -58,7 +60,7 @@ public final class Message implements Parcelable {
|
||||
* be non-null if it contains a Parcelable of a framework class (not one
|
||||
* implemented by the application). For other data transfer use
|
||||
* {@link #setData}.
|
||||
*
|
||||
*
|
||||
* <p>Note that Parcelable objects here are not supported prior to
|
||||
* the {@link android.os.Build.VERSION_CODES#FROYO} release.
|
||||
*/
|
||||
@@ -97,13 +99,13 @@ public final class Message implements Parcelable {
|
||||
/*package*/ int flags;
|
||||
|
||||
/*package*/ long when;
|
||||
|
||||
|
||||
/*package*/ Bundle data;
|
||||
|
||||
|
||||
/*package*/ Handler target;
|
||||
|
||||
|
||||
/*package*/ Runnable callback;
|
||||
|
||||
|
||||
// sometimes we store linked lists of these things
|
||||
/*package*/ Message next;
|
||||
|
||||
@@ -216,9 +218,9 @@ public final class Message implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link #obtain()}, but sets the values of the <em>target</em>, <em>what</em>,
|
||||
* Same as {@link #obtain()}, but sets the values of the <em>target</em>, <em>what</em>,
|
||||
* <em>arg1</em>, and <em>arg2</em> members.
|
||||
*
|
||||
*
|
||||
* @param h The <em>target</em> value to set.
|
||||
* @param what The <em>what</em> value to set.
|
||||
* @param arg1 The <em>arg1</em> value to set.
|
||||
@@ -236,9 +238,9 @@ public final class Message implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link #obtain()}, but sets the values of the <em>target</em>, <em>what</em>,
|
||||
* Same as {@link #obtain()}, but sets the values of the <em>target</em>, <em>what</em>,
|
||||
* <em>arg1</em>, <em>arg2</em>, and <em>obj</em> members.
|
||||
*
|
||||
*
|
||||
* @param h The <em>target</em> value to set.
|
||||
* @param what The <em>what</em> value to set.
|
||||
* @param arg1 The <em>arg1</em> value to set.
|
||||
@@ -246,7 +248,7 @@ public final class Message implements Parcelable {
|
||||
* @param obj The <em>obj</em> value to set.
|
||||
* @return A Message object from the global pool.
|
||||
*/
|
||||
public static Message obtain(Handler h, int what,
|
||||
public static Message obtain(Handler h, int what,
|
||||
int arg1, int arg2, Object obj) {
|
||||
Message m = obtain();
|
||||
m.target = h;
|
||||
@@ -339,7 +341,7 @@ public final class Message implements Parcelable {
|
||||
public long getWhen() {
|
||||
return when;
|
||||
}
|
||||
|
||||
|
||||
public void setTarget(Handler target) {
|
||||
this.target = target;
|
||||
}
|
||||
@@ -367,8 +369,8 @@ public final class Message implements Parcelable {
|
||||
public Runnable getCallback() {
|
||||
return callback;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Obtains a Bundle of arbitrary data associated with this
|
||||
* event, lazily creating it if necessary. Set this value by calling
|
||||
* {@link #setData(Bundle)}. Note that when transferring data across
|
||||
@@ -383,11 +385,11 @@ public final class Message implements Parcelable {
|
||||
if (data == null) {
|
||||
data = new Bundle();
|
||||
}
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Like getData(), but does not lazily create the Bundle. A null
|
||||
* is returned if the Bundle does not already exist. See
|
||||
* {@link #getData} for further information on this.
|
||||
@@ -401,7 +403,7 @@ public final class Message implements Parcelable {
|
||||
/**
|
||||
* Sets a Bundle of arbitrary data values. Use arg1 and arg2 members
|
||||
* as a lower cost way to send a few simple integer values, if you can.
|
||||
* @see #getData()
|
||||
* @see #getData()
|
||||
* @see #peekData()
|
||||
*/
|
||||
public void setData(Bundle data) {
|
||||
@@ -520,6 +522,37 @@ public final class Message implements Parcelable {
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
void writeToProto(ProtoOutputStream proto, long fieldId) {
|
||||
final long messageToken = proto.start(fieldId);
|
||||
proto.write(MessageProto.WHEN, when);
|
||||
|
||||
if (target != null) {
|
||||
if (callback != null) {
|
||||
proto.write(MessageProto.CALLBACK, callback.getClass().getName());
|
||||
} else {
|
||||
proto.write(MessageProto.WHAT, what);
|
||||
}
|
||||
|
||||
if (arg1 != 0) {
|
||||
proto.write(MessageProto.ARG1, arg1);
|
||||
}
|
||||
|
||||
if (arg2 != 0) {
|
||||
proto.write(MessageProto.ARG2, arg2);
|
||||
}
|
||||
|
||||
if (obj != null) {
|
||||
proto.write(MessageProto.OBJ, obj.toString());
|
||||
}
|
||||
|
||||
proto.write(MessageProto.TARGET, target.getClass().getName());
|
||||
} else {
|
||||
proto.write(MessageProto.BARRIER, arg1);
|
||||
}
|
||||
|
||||
proto.end(messageToken);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<Message> CREATOR
|
||||
= new Parcelable.Creator<Message>() {
|
||||
public Message createFromParcel(Parcel source) {
|
||||
@@ -527,12 +560,12 @@ public final class Message implements Parcelable {
|
||||
msg.readFromParcel(source);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
public Message[] newArray(int size) {
|
||||
return new Message[size];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -18,9 +18,11 @@ package android.os;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.os.MessageQueueProto;
|
||||
import android.util.Log;
|
||||
import android.util.Printer;
|
||||
import android.util.SparseArray;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -31,7 +33,7 @@ import java.util.ArrayList;
|
||||
* Low-level class holding the list of messages to be dispatched by a
|
||||
* {@link Looper}. Messages are not added directly to a MessageQueue,
|
||||
* but rather through {@link Handler} objects associated with the Looper.
|
||||
*
|
||||
*
|
||||
* <p>You can retrieve the MessageQueue for the current thread with
|
||||
* {@link Looper#myQueue() Looper.myQueue()}.
|
||||
*/
|
||||
@@ -770,6 +772,18 @@ public final class MessageQueue {
|
||||
}
|
||||
}
|
||||
|
||||
void writeToProto(ProtoOutputStream proto, long fieldId) {
|
||||
final long messageQueueToken = proto.start(fieldId);
|
||||
synchronized (this) {
|
||||
for (Message msg = mMessages; msg != null; msg = msg.next) {
|
||||
msg.writeToProto(proto, MessageQueueProto.MESSAGES);
|
||||
}
|
||||
proto.write(MessageQueueProto.IS_POLLING_LOCKED, isPollingLocked());
|
||||
proto.write(MessageQueueProto.IS_QUITTING, mQuitting);
|
||||
}
|
||||
proto.end(messageQueueToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback interface for discovering when a thread is going to block
|
||||
* waiting for more messages.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package android.os;
|
||||
|
||||
import android.os.WorkSourceProto;
|
||||
import android.util.Log;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -296,7 +298,7 @@ public class WorkSource implements Parcelable {
|
||||
break;
|
||||
}
|
||||
if (mUids[i] == uid) {
|
||||
int diff = mNames[i].compareTo(name);
|
||||
int diff = mNames[i].compareTo(name);
|
||||
if (diff > 0) {
|
||||
break;
|
||||
}
|
||||
@@ -692,6 +694,20 @@ public class WorkSource implements Parcelable {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void writeToProto(ProtoOutputStream proto, long fieldId) {
|
||||
final long workSourceToken = proto.start(fieldId);
|
||||
for (int i = 0; i < mNum; i++) {
|
||||
final long contentProto = proto.start(WorkSourceProto.WORK_SOURCE_CONTENTS);
|
||||
proto.write(WorkSourceProto.WorkSourceContentProto.UID, mUids[i]);
|
||||
if (mNames != null) {
|
||||
proto.write(WorkSourceProto.WorkSourceContentProto.NAME, mNames[i]);
|
||||
}
|
||||
proto.end(contentProto);
|
||||
}
|
||||
proto.end(workSourceToken);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<WorkSource> CREATOR
|
||||
= new Parcelable.Creator<WorkSource>() {
|
||||
public WorkSource createFromParcel(Parcel in) {
|
||||
|
||||
30
core/proto/android/os/looper.proto
Normal file
30
core/proto/android/os/looper.proto
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package android.os;
|
||||
|
||||
option java_multiple_files = true;
|
||||
|
||||
import "frameworks/base/core/proto/android/os/messagequeue.proto";
|
||||
|
||||
message LooperProto {
|
||||
string thread_name = 1;
|
||||
int64 thread_id = 2;
|
||||
int32 identity_hash_code = 3;
|
||||
android.os.MessageQueueProto queue = 4;
|
||||
}
|
||||
37
core/proto/android/os/message.proto
Normal file
37
core/proto/android/os/message.proto
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package android.os;
|
||||
|
||||
option java_multiple_files = true;
|
||||
|
||||
message MessageProto {
|
||||
int64 when = 1;
|
||||
// Name of callback class.
|
||||
string callback = 2;
|
||||
// User-defined message code so that the recipient can identify what this
|
||||
// message is about.
|
||||
int32 what = 3;
|
||||
int32 arg1 = 4;
|
||||
int32 arg2 = 5;
|
||||
// String representation of an arbitrary object to send to the recipient.
|
||||
string obj = 6;
|
||||
// Name of target class.
|
||||
string target = 7;
|
||||
int32 barrier = 8;
|
||||
}
|
||||
29
core/proto/android/os/messagequeue.proto
Normal file
29
core/proto/android/os/messagequeue.proto
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package android.os;
|
||||
|
||||
option java_multiple_files = true;
|
||||
|
||||
import "frameworks/base/core/proto/android/os/message.proto";
|
||||
|
||||
message MessageQueueProto {
|
||||
repeated android.os.MessageProto messages = 1;
|
||||
bool is_polling_locked = 2;
|
||||
bool is_quitting = 3;
|
||||
}
|
||||
30
core/proto/android/os/worksource.proto
Normal file
30
core/proto/android/os/worksource.proto
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package android.os;
|
||||
|
||||
option java_multiple_files = true;
|
||||
|
||||
message WorkSourceProto {
|
||||
message WorkSourceContentProto {
|
||||
int32 uid = 1;
|
||||
string name = 2;
|
||||
}
|
||||
|
||||
repeated WorkSourceContentProto work_source_contents = 1;
|
||||
}
|
||||
408
core/proto/android/service/power.proto
Normal file
408
core/proto/android/service/power.proto
Normal file
@@ -0,0 +1,408 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package android.service.power;
|
||||
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "PowerServiceProto";
|
||||
|
||||
import "frameworks/base/core/proto/android/os/looper.proto";
|
||||
import "frameworks/base/core/proto/android/os/worksource.proto";
|
||||
import "frameworks/base/core/proto/android/service/wirelesschargerdetector.proto";
|
||||
|
||||
message PowerServiceDumpProto {
|
||||
message ConstantsProto {
|
||||
bool is_no_cached_wake_locks = 1;
|
||||
}
|
||||
message ActiveWakeLocksProto {
|
||||
bool is_cpu = 1;
|
||||
bool is_screen_bright = 2;
|
||||
bool is_screen_dim = 3;
|
||||
bool is_button_bright = 4;
|
||||
bool is_proximity_screen_off = 5;
|
||||
// only set if already awake
|
||||
bool is_stay_awake = 6;
|
||||
bool is_doze = 7;
|
||||
bool is_draw = 8;
|
||||
}
|
||||
message UserActivityProto {
|
||||
bool is_screen_bright = 1;
|
||||
bool is_screen_dim = 2;
|
||||
bool is_screen_dream = 3;
|
||||
}
|
||||
message UidProto {
|
||||
// Enum values gotten from ActivityManager.java
|
||||
enum ProcessState {
|
||||
// Process is a persistent system process.
|
||||
PROCESS_STATE_PERSISTENT = 0;
|
||||
// Process is a persistent system process and is doing UI.
|
||||
PROCESS_STATE_PERSISTENT_UI = 1;
|
||||
// Process is hosting the current top activities. Note that this
|
||||
// covers all activities that are visible to the user.
|
||||
PROCESS_STATE_TOP = 2;
|
||||
// Process is hosting a foreground service due to a system binding.
|
||||
PROCESS_STATE_BOUND_FOREGROUND_SERVICE = 3;
|
||||
// Process is hosting a foreground service.
|
||||
PROCESS_STATE_FOREGROUND_SERVICE = 4;
|
||||
// Same as {@link #PROCESS_STATE_TOP} but while device is sleeping.
|
||||
PROCESS_STATE_TOP_SLEEPING = 5;
|
||||
// Process is important to the user, and something they are aware of.
|
||||
PROCESS_STATE_IMPORTANT_FOREGROUND = 6;
|
||||
// Process is important to the user, but not something they are aware of.
|
||||
PROCESS_STATE_IMPORTANT_BACKGROUND = 7;
|
||||
// Process is in the background running a backup/restore operation.
|
||||
PROCESS_STATE_BACKUP = 8;
|
||||
// Process is in the background, but it can't restore its state so
|
||||
// we want to try to avoid killing it.
|
||||
PROCESS_STATE_HEAVY_WEIGHT = 9;
|
||||
// Process is in the background running a service.
|
||||
PROCESS_STATE_SERVICE = 10;
|
||||
// Process is in the background running a receiver.
|
||||
PROCESS_STATE_RECEIVER = 11;
|
||||
// Process is in the background but hosts the home activity.
|
||||
PROCESS_STATE_HOME = 12;
|
||||
// Process is in the background but hosts the last shown activity.
|
||||
PROCESS_STATE_LAST_ACTIVITY = 13;
|
||||
// Process is being cached for later use and contains activities.
|
||||
PROCESS_STATE_CACHED_ACTIVITY = 14;
|
||||
// Process is being cached for later use and is a client of another
|
||||
// cached process that contains activities.
|
||||
PROCESS_STATE_CACHED_ACTIVITY_CLIENT = 15;
|
||||
// Process is being cached for later use and is empty.
|
||||
PROCESS_STATE_CACHED_EMPTY = 16;
|
||||
// Process does not exist.
|
||||
PROCESS_STATE_NONEXISTENT = 17;
|
||||
}
|
||||
int32 uid = 1;
|
||||
string uid_string = 2;
|
||||
bool is_active = 3;
|
||||
int32 num_wake_locks = 4;
|
||||
bool is_process_state_unknown = 5;
|
||||
ProcessState process_state = 6;
|
||||
}
|
||||
|
||||
// Enum values gotten from PowerManagerInternal.java
|
||||
enum Wakefulness {
|
||||
WAKEFULNESS_ASLEEP = 0;
|
||||
WAKEFULNESS_AWAKE = 1;
|
||||
WAKEFULNESS_DREAMING = 2;
|
||||
WAKEFULNESS_DOZING = 3;
|
||||
WAKEFULNESS_UNKNOWN = 4;
|
||||
}
|
||||
// Enum values gotten from BatteryManager.java
|
||||
enum PlugType {
|
||||
PLUG_TYPE_NONE = 0;
|
||||
PLUG_TYPE_PLUGGED_AC = 1;
|
||||
PLUG_TYPE_PLUGGED_USB = 2;
|
||||
PLUG_TYPE_PLUGGED_WIRELESS = 4;
|
||||
}
|
||||
// Enum values gotten from Intent.java
|
||||
enum DockState {
|
||||
DOCK_STATE_UNDOCKED = 0;
|
||||
DOCK_STATE_DESK = 1;
|
||||
DOCK_STATE_CAR = 2;
|
||||
DOCK_STATE_LE_DESK = 3;
|
||||
DOCK_STATE_HE_DESK = 4;
|
||||
}
|
||||
|
||||
ConstantsProto constants = 1;
|
||||
// A bitfield that indicates what parts of the power state have
|
||||
// changed and need to be recalculated.
|
||||
int32 dirty = 2;
|
||||
// Indicates whether the device is awake or asleep or somewhere in between.
|
||||
Wakefulness wakefulness = 3;
|
||||
bool is_wakefulness_changing = 4;
|
||||
// True if the device is plugged into a power source.
|
||||
bool is_powered = 5;
|
||||
// The current plug type
|
||||
PlugType plug_type = 6;
|
||||
// The current battery level percentage.
|
||||
int32 battery_level = 7;
|
||||
// The battery level percentage at the time the dream started.
|
||||
int32 battery_level_when_dream_started = 8;
|
||||
// The current dock state.
|
||||
DockState dock_state = 9;
|
||||
// True if the device should stay on.
|
||||
bool is_stay_on = 10;
|
||||
// True if the proximity sensor reads a positive result.
|
||||
bool is_proximity_positive = 11;
|
||||
// True if boot completed occurred. We keep the screen on until this happens.
|
||||
bool is_boot_completed = 12;
|
||||
// True if systemReady() has been called.
|
||||
bool is_system_ready = 13;
|
||||
// True if auto-suspend mode is enabled.
|
||||
bool is_hal_auto_suspend_mode_enabled = 14;
|
||||
// True if interactive mode is enabled.
|
||||
bool is_hal_auto_interactive_mode_enabled = 15;
|
||||
// Summarizes the state of all active wakelocks.
|
||||
ActiveWakeLocksProto active_wake_locks = 16;
|
||||
// Have we scheduled a message to check for long wake locks? This is when
|
||||
// we will check. (In milliseconds timestamp)
|
||||
int64 notify_long_scheduled_ms = 17;
|
||||
// Last time we checked for long wake locks. (In milliseconds timestamp)
|
||||
int64 notify_long_dispatched_ms = 18;
|
||||
// The time we decided to do next long check. (In milliseconds timestamp)
|
||||
int64 notify_long_next_check_ms = 19;
|
||||
// Summarizes the effect of the user activity timer.
|
||||
UserActivityProto user_activity = 20;
|
||||
// If true, instructs the display controller to wait for the proximity
|
||||
// sensor to go negative before turning the screen on.
|
||||
bool is_request_wait_for_negative_proximity = 21;
|
||||
// True if MSG_SANDMAN has been scheduled.
|
||||
bool is_sandman_scheduled = 22;
|
||||
// True if the sandman has just been summoned for the first time since entering
|
||||
// the dreaming or dozing state. Indicates whether a new dream should begin.
|
||||
bool is_sandman_summoned = 23;
|
||||
// If true, the device is in low power mode.
|
||||
bool is_low_power_mode_enabled = 24;
|
||||
// True if the battery level is currently considered low.
|
||||
bool is_battery_level_low = 25;
|
||||
// True if we are currently in light device idle mode.
|
||||
bool is_light_device_idle_mode = 26;
|
||||
// True if we are currently in device idle mode.
|
||||
bool is_device_idle_mode = 27;
|
||||
// Set of app ids that we will always respect the wake locks for.
|
||||
repeated int32 device_idle_whitelist = 28;
|
||||
// Set of app ids that are temporarily allowed to acquire wakelocks due to
|
||||
// high-pri message
|
||||
repeated int32 device_idle_temp_whitelist = 29;
|
||||
// Timestamp of the last time the device was awoken.
|
||||
int64 last_wake_time_ms = 30;
|
||||
// Timestamp of the last time the device was put to sleep.
|
||||
int64 last_sleep_time_ms = 31;
|
||||
// Timestamp of the last call to user activity.
|
||||
int64 last_user_activity_time_ms = 32;
|
||||
int64 last_user_activity_time_no_change_lights_ms = 33;
|
||||
// Timestamp of last interactive power hint.
|
||||
int64 last_interactive_power_hint_time_ms = 34;
|
||||
// Timestamp of the last screen brightness boost.
|
||||
int64 last_screen_brightness_boost_time_ms = 35;
|
||||
// True if screen brightness boost is in progress.
|
||||
bool is_screen_brightness_boost_in_progress = 36;
|
||||
// True if the display power state has been fully applied, which means the
|
||||
// display is actually on or actually off or whatever was requested.
|
||||
bool is_display_ready = 37;
|
||||
// True if the wake lock suspend blocker has been acquired.
|
||||
bool is_holding_wake_lock_suspend_blocker = 38;
|
||||
// The suspend blocker used to keep the CPU alive when the display is on, the
|
||||
// display is getting ready or there is user activity (in which case the
|
||||
// display must be on).
|
||||
bool is_holding_display_suspend_blocker = 39;
|
||||
// Settings and configuration
|
||||
PowerServiceSettingsAndConfigurationDumpProto settings_and_configuration = 40;
|
||||
// Sleep timeout in ms
|
||||
sint32 sleep_timeout_ms = 41;
|
||||
// Screen off timeout in ms
|
||||
int32 screen_off_timeout_ms = 42;
|
||||
// Screen dim duration in ms
|
||||
int32 screen_dim_duration_ms = 43;
|
||||
// We are currently in the middle of a batch change of uids.
|
||||
bool are_uids_changing = 44;
|
||||
// Some uids have actually changed while mUidsChanging was true.
|
||||
bool are_uids_changed = 45;
|
||||
// List of UIDs and their states
|
||||
repeated UidProto uids = 46;
|
||||
android.os.LooperProto looper = 47;
|
||||
// List of all wake locks acquired by applications.
|
||||
repeated WakeLockProto wake_locks = 48;
|
||||
// List of all suspend blockers.
|
||||
repeated SuspendBlockerProto suspend_blockers = 49;
|
||||
WirelessChargerDetectorProto wireless_charger_detector = 50;
|
||||
}
|
||||
|
||||
message SuspendBlockerProto {
|
||||
string name = 1;
|
||||
int32 reference_count = 2;
|
||||
}
|
||||
|
||||
message WakeLockProto {
|
||||
message WakeLockFlagsProto {
|
||||
// Turn the screen on when the wake lock is acquired.
|
||||
bool is_acquire_causes_wakeup = 1;
|
||||
// When this wake lock is released, poke the user activity timer
|
||||
// so the screen stays on for a little longer.
|
||||
bool is_on_after_release = 2;
|
||||
}
|
||||
|
||||
// Enum values gotten from PowerManager.java
|
||||
enum LockLevel {
|
||||
WAKE_LOCK_INVALID = 0;
|
||||
// Ensures that the CPU is running.
|
||||
PARTIAL_WAKE_LOCK = 1;
|
||||
// Ensures that the screen is on (but may be dimmed).
|
||||
SCREEN_DIM_WAKE_LOCK = 6;
|
||||
// Ensures that the screen is on at full brightness.
|
||||
SCREEN_BRIGHT_WAKE_LOCK = 10;
|
||||
// Ensures that the screen and keyboard backlight are on at full brightness.
|
||||
FULL_WAKE_LOCK = 26;
|
||||
// Turns the screen off when the proximity sensor activates.
|
||||
PROXIMITY_SCREEN_OFF_WAKE_LOCK = 32;
|
||||
// Put the screen in a low power state and allow the CPU to suspend
|
||||
// if no other wake locks are held.
|
||||
DOZE_WAKE_LOCK = 64;
|
||||
// Keep the device awake enough to allow drawing to occur.
|
||||
DRAW_WAKE_LOCK = 128;
|
||||
}
|
||||
|
||||
LockLevel lock_level = 1;
|
||||
string tag = 2;
|
||||
WakeLockFlagsProto flags = 3;
|
||||
bool is_disabled = 4;
|
||||
// Acquire time in ms
|
||||
int64 acq_ms = 5;
|
||||
bool is_notified_long = 6;
|
||||
// Owner UID
|
||||
int32 uid = 7;
|
||||
// Owner PID
|
||||
int32 pid = 8;
|
||||
android.os.WorkSourceProto work_source = 9;
|
||||
}
|
||||
|
||||
message PowerServiceSettingsAndConfigurationDumpProto {
|
||||
message StayOnWhilePluggedInProto {
|
||||
bool is_stay_on_while_plugged_in_ac = 1;
|
||||
bool is_stay_on_while_plugged_in_usb = 2;
|
||||
bool is_stay_on_while_plugged_in_wireless = 3;
|
||||
}
|
||||
message ScreenBrightnessSettingLimitsProto {
|
||||
int32 setting_minimum = 1;
|
||||
int32 setting_maximum = 2;
|
||||
int32 setting_default = 3;
|
||||
int32 setting_for_vr_default = 4;
|
||||
}
|
||||
|
||||
// Enum values gotten from Settings.java
|
||||
enum ScreenBrightnessMode {
|
||||
SCREEN_BRIGHTNESS_MODE_MANUAL = 0;
|
||||
SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1;
|
||||
}
|
||||
// Enum values gotten from Display.java
|
||||
enum DisplayState {
|
||||
DISPLAY_STATE_UNKNOWN = 0;
|
||||
DISPLAY_STATE_OFF = 1;
|
||||
DISPLAY_STATE_ON = 2;
|
||||
DISPLAY_STATE_DOZE = 3;
|
||||
DISPLAY_STATE_DOZE_SUSPEND = 4;
|
||||
DISPLAY_STATE_VR = 5;
|
||||
}
|
||||
|
||||
|
||||
// True to decouple auto-suspend mode from the display state.
|
||||
bool is_decouple_hal_auto_suspend_mode_from_display_config = 1;
|
||||
// True to decouple interactive mode from the display state.
|
||||
bool is_decouple_hal_interactive_mode_from_display_config = 2;
|
||||
// True if the device should wake up when plugged or unplugged.
|
||||
bool is_wake_up_when_plugged_or_unplugged_config = 3;
|
||||
// True if the device should wake up when plugged or unplugged in theater mode.
|
||||
bool is_wake_up_when_plugged_or_unplugged_in_theater_mode_config = 4;
|
||||
// True if theater mode is enabled
|
||||
bool is_theater_mode_enabled = 5;
|
||||
// True if the device should suspend when the screen is off due to proximity.
|
||||
bool is_suspend_when_screen_off_due_to_proximity_config = 6;
|
||||
// True if dreams are supported on this device.
|
||||
bool are_dreams_supported_config = 7;
|
||||
// Default value for dreams enabled
|
||||
bool are_dreams_enabled_by_default_config = 8;
|
||||
// Default value for dreams activate-on-sleep
|
||||
bool are_dreams_activated_on_sleep_by_default_config = 9;
|
||||
// Default value for dreams activate-on-dock
|
||||
bool are_dreams_activated_on_dock_by_default_config = 10;
|
||||
// True if dreams can run while not plugged in.
|
||||
bool are_dreams_enabled_on_battery_config = 11;
|
||||
// Minimum battery level to allow dreaming when powered.
|
||||
// Use -1 to disable this safety feature.
|
||||
sint32 dreams_battery_level_minimum_when_powered_config = 12;
|
||||
// Minimum battery level to allow dreaming when not powered.
|
||||
// Use -1 to disable this safety feature.
|
||||
sint32 dreams_battery_level_minimum_when_not_powered_config = 13;
|
||||
// If the battery level drops by this percentage and the user activity
|
||||
// timeout has expired, then assume the device is receiving insufficient
|
||||
// current to charge effectively and terminate the dream. Use -1 to disable
|
||||
// this safety feature.
|
||||
sint32 dreams_battery_level_drain_cutoff_config = 14;
|
||||
// True if dreams are enabled by the user.
|
||||
bool are_dreams_enabled_setting = 15;
|
||||
// True if dreams should be activated on sleep.
|
||||
bool are_dreams_activate_on_sleep_setting = 16;
|
||||
// True if dreams should be activated on dock.
|
||||
bool are_dreams_activate_on_dock_setting = 17;
|
||||
// True if doze should not be started until after the screen off transition.
|
||||
bool is_doze_after_screen_off_config = 18;
|
||||
// If true, the device is in low power mode.
|
||||
bool is_low_power_mode_setting = 19;
|
||||
// Current state of whether the settings are allowing auto low power mode.
|
||||
bool is_auto_low_power_mode_configured = 20;
|
||||
// The user turned off low power mode below the trigger level
|
||||
bool is_auto_low_power_mode_snoozing = 21;
|
||||
// The minimum screen off timeout, in milliseconds.
|
||||
int32 minimum_screen_off_timeout_config_ms = 22;
|
||||
// The screen dim duration, in milliseconds.
|
||||
int32 maximum_screen_dim_duration_config_ms = 23;
|
||||
// The maximum screen dim time expressed as a ratio relative to the screen off timeout.
|
||||
float maximum_screen_dim_ratio_config = 24;
|
||||
// The screen off timeout setting value in milliseconds.
|
||||
int32 screen_off_timeout_setting_ms = 25;
|
||||
// The sleep timeout setting value in milliseconds.
|
||||
sint32 sleep_timeout_setting_ms = 26;
|
||||
// The maximum allowable screen off timeout according to the device administration policy.
|
||||
int32 maximum_screen_off_timeout_from_device_admin_ms = 27;
|
||||
bool is_maximum_screen_off_timeout_from_device_admin_enforced_locked = 28;
|
||||
// The stay on while plugged in setting.
|
||||
// A set of battery conditions under which to make the screen stay on.
|
||||
StayOnWhilePluggedInProto stay_on_while_plugged_in = 29;
|
||||
// The screen brightness setting, from 0 to 255.
|
||||
// Use -1 if no value has been set.
|
||||
sint32 screen_brightness_setting = 30;
|
||||
// The screen auto-brightness adjustment setting, from -1 to 1.
|
||||
// Use 0 if there is no adjustment.
|
||||
float screen_auto_brightness_adjustment_setting = 31;
|
||||
// The screen brightness mode.
|
||||
ScreenBrightnessMode screen_brightness_mode_setting = 32;
|
||||
// The screen brightness setting override from the window manager
|
||||
// to allow the current foreground activity to override the brightness.
|
||||
// Use -1 to disable.
|
||||
sint32 screen_brightness_override_from_window_manager = 33;
|
||||
// The user activity timeout override from the window manager
|
||||
// to allow the current foreground activity to override the user activity
|
||||
// timeout. Use -1 to disable.
|
||||
sint64 user_activity_timeout_override_from_window_manager_ms = 34;
|
||||
// The window manager has determined the user to be inactive via other means.
|
||||
// Set this to false to disable.
|
||||
bool is_user_inactive_override_from_window_manager = 35;
|
||||
// The screen brightness setting override from the settings application
|
||||
// to temporarily adjust the brightness until next updated,
|
||||
// Use -1 to disable.
|
||||
sint32 temporary_screen_brightness_setting_override = 36;
|
||||
// The screen brightness adjustment setting override from the settings
|
||||
// application to temporarily adjust the auto-brightness adjustment factor
|
||||
// until next updated, in the range -1..1.
|
||||
// Use NaN to disable.
|
||||
float temporary_screen_auto_brightness_adjustment_setting_override = 37;
|
||||
// The screen state to use while dozing.
|
||||
DisplayState doze_screen_state_override_from_dream_manager = 38;
|
||||
// The screen brightness to use while dozing.
|
||||
float dozed_screen_brightness_override_from_dream_manager = 39;
|
||||
// Screen brightness settings limits.
|
||||
ScreenBrightnessSettingLimitsProto screen_brightness_setting_limits = 40;
|
||||
// The screen brightness setting, from 0 to 255, to be used while in VR Mode.
|
||||
int32 screen_brightness_for_vr_setting = 41;
|
||||
// True if double tap to wake is enabled
|
||||
bool is_double_tap_wake_enabled = 42;
|
||||
// True if we are currently in VR Mode.
|
||||
bool is_vr_mode_enabled = 43;
|
||||
}
|
||||
50
core/proto/android/service/wirelesschargerdetector.proto
Normal file
50
core/proto/android/service/wirelesschargerdetector.proto
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package android.service.power;
|
||||
|
||||
option java_multiple_files = true;
|
||||
|
||||
message WirelessChargerDetectorProto {
|
||||
message VectorProto {
|
||||
float x = 1;
|
||||
float y = 2;
|
||||
float z = 3;
|
||||
}
|
||||
|
||||
// Previously observed wireless power state.
|
||||
bool is_powered_wirelessly = 1;
|
||||
// True if the device is thought to be at rest on a wireless charger.
|
||||
bool is_at_rest = 2;
|
||||
// The gravity vector most recently observed while at rest.
|
||||
VectorProto rest = 3;
|
||||
// True if detection is in progress.
|
||||
bool is_detection_in_progress = 4;
|
||||
// The time when detection was last performed.
|
||||
int64 detection_start_time_ms = 5;
|
||||
// True if the rest position should be updated if at rest.
|
||||
bool is_must_update_rest_position = 6;
|
||||
// The total number of samples collected.
|
||||
int32 total_samples = 7;
|
||||
// The number of samples collected that showed evidence of not being at rest.
|
||||
int32 moving_samples = 8;
|
||||
// The value of the first sample that was collected.
|
||||
VectorProto first_sample = 9;
|
||||
// The value of the last sample that was collected.
|
||||
VectorProto last_sample = 10;
|
||||
}
|
||||
@@ -51,21 +51,23 @@ import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
import android.os.WorkSource;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.provider.Settings.SettingNotFoundException;
|
||||
import android.service.dreams.DreamManagerInternal;
|
||||
import android.service.power.PowerServiceDumpProto;
|
||||
import android.service.power.PowerServiceSettingsAndConfigurationDumpProto;
|
||||
import android.service.power.SuspendBlockerProto;
|
||||
import android.service.power.WakeLockProto;
|
||||
import android.service.vr.IVrManager;
|
||||
import android.service.vr.IVrStateCallbacks;
|
||||
import android.util.EventLog;
|
||||
import android.util.KeyValueListParser;
|
||||
import android.util.Log;
|
||||
import android.util.PrintWriterPrinter;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.util.TimeUtils;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManagerPolicy;
|
||||
|
||||
import com.android.internal.app.IAppOpsService;
|
||||
import com.android.internal.app.IBatteryStats;
|
||||
import com.android.internal.os.BackgroundThread;
|
||||
@@ -78,7 +80,7 @@ import com.android.server.Watchdog;
|
||||
import com.android.server.am.BatteryStatsService;
|
||||
import com.android.server.lights.Light;
|
||||
import com.android.server.lights.LightsManager;
|
||||
import com.android.server.vr.VrManagerService;
|
||||
|
||||
import libcore.util.Objects;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
@@ -575,6 +577,13 @@ public final class PowerManagerService extends SystemService
|
||||
pw.print(" "); pw.print(KEY_NO_CACHED_WAKE_LOCKS); pw.print("=");
|
||||
pw.println(NO_CACHED_WAKE_LOCKS);
|
||||
}
|
||||
|
||||
void dumpProto(ProtoOutputStream proto) {
|
||||
final long constantsToken = proto.start(PowerServiceDumpProto.CONSTANTS);
|
||||
proto.write(PowerServiceDumpProto.ConstantsProto.IS_NO_CACHED_WAKE_LOCKS,
|
||||
NO_CACHED_WAKE_LOCKS);
|
||||
proto.end(constantsToken);
|
||||
}
|
||||
}
|
||||
|
||||
final Constants mConstants;
|
||||
@@ -3244,6 +3253,354 @@ public final class PowerManagerService extends SystemService
|
||||
}
|
||||
}
|
||||
|
||||
private void dumpProto(FileDescriptor fd) {
|
||||
final WirelessChargerDetector wcd;
|
||||
final ProtoOutputStream proto = new ProtoOutputStream(fd);
|
||||
|
||||
synchronized (mLock) {
|
||||
mConstants.dumpProto(proto);
|
||||
proto.write(PowerServiceDumpProto.DIRTY, mDirty);
|
||||
proto.write(PowerServiceDumpProto.WAKEFULNESS, mWakefulness);
|
||||
proto.write(PowerServiceDumpProto.IS_WAKEFULNESS_CHANGING, mWakefulnessChanging);
|
||||
proto.write(PowerServiceDumpProto.IS_POWERED, mIsPowered);
|
||||
proto.write(PowerServiceDumpProto.PLUG_TYPE, mPlugType);
|
||||
proto.write(PowerServiceDumpProto.BATTERY_LEVEL, mBatteryLevel);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.BATTERY_LEVEL_WHEN_DREAM_STARTED,
|
||||
mBatteryLevelWhenDreamStarted);
|
||||
proto.write(PowerServiceDumpProto.DOCK_STATE, mDockState);
|
||||
proto.write(PowerServiceDumpProto.IS_STAY_ON, mStayOn);
|
||||
proto.write(PowerServiceDumpProto.IS_PROXIMITY_POSITIVE, mProximityPositive);
|
||||
proto.write(PowerServiceDumpProto.IS_BOOT_COMPLETED, mBootCompleted);
|
||||
proto.write(PowerServiceDumpProto.IS_SYSTEM_READY, mSystemReady);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.IS_HAL_AUTO_SUSPEND_MODE_ENABLED,
|
||||
mHalAutoSuspendModeEnabled);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.IS_HAL_AUTO_INTERACTIVE_MODE_ENABLED,
|
||||
mHalInteractiveModeEnabled);
|
||||
|
||||
final long activeWakeLocksToken = proto.start(PowerServiceDumpProto.ACTIVE_WAKE_LOCKS);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.ActiveWakeLocksProto.IS_CPU,
|
||||
(mWakeLockSummary & WAKE_LOCK_CPU) != 0);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.ActiveWakeLocksProto.IS_SCREEN_BRIGHT,
|
||||
(mWakeLockSummary & WAKE_LOCK_SCREEN_BRIGHT) != 0);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.ActiveWakeLocksProto.IS_SCREEN_DIM,
|
||||
(mWakeLockSummary & WAKE_LOCK_SCREEN_DIM) != 0);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.ActiveWakeLocksProto.IS_BUTTON_BRIGHT,
|
||||
(mWakeLockSummary & WAKE_LOCK_BUTTON_BRIGHT) != 0);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.ActiveWakeLocksProto.IS_PROXIMITY_SCREEN_OFF,
|
||||
(mWakeLockSummary & WAKE_LOCK_PROXIMITY_SCREEN_OFF) != 0);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.ActiveWakeLocksProto.IS_STAY_AWAKE,
|
||||
(mWakeLockSummary & WAKE_LOCK_STAY_AWAKE) != 0);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.ActiveWakeLocksProto.IS_DOZE,
|
||||
(mWakeLockSummary & WAKE_LOCK_DOZE) != 0);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.ActiveWakeLocksProto.IS_DRAW,
|
||||
(mWakeLockSummary & WAKE_LOCK_DRAW) != 0);
|
||||
proto.end(activeWakeLocksToken);
|
||||
|
||||
proto.write(PowerServiceDumpProto.NOTIFY_LONG_SCHEDULED_MS, mNotifyLongScheduled);
|
||||
proto.write(PowerServiceDumpProto.NOTIFY_LONG_DISPATCHED_MS, mNotifyLongDispatched);
|
||||
proto.write(PowerServiceDumpProto.NOTIFY_LONG_NEXT_CHECK_MS, mNotifyLongNextCheck);
|
||||
|
||||
final long userActivityToken = proto.start(PowerServiceDumpProto.USER_ACTIVITY);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.UserActivityProto.IS_SCREEN_BRIGHT,
|
||||
(mUserActivitySummary & USER_ACTIVITY_SCREEN_BRIGHT) != 0);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.UserActivityProto.IS_SCREEN_DIM,
|
||||
(mUserActivitySummary & USER_ACTIVITY_SCREEN_DIM) != 0);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.UserActivityProto.IS_SCREEN_DREAM,
|
||||
(mUserActivitySummary & USER_ACTIVITY_SCREEN_DREAM) != 0);
|
||||
proto.end(userActivityToken);
|
||||
|
||||
proto.write(
|
||||
PowerServiceDumpProto.IS_REQUEST_WAIT_FOR_NEGATIVE_PROXIMITY,
|
||||
mRequestWaitForNegativeProximity);
|
||||
proto.write(PowerServiceDumpProto.IS_SANDMAN_SCHEDULED, mSandmanScheduled);
|
||||
proto.write(PowerServiceDumpProto.IS_SANDMAN_SUMMONED, mSandmanSummoned);
|
||||
proto.write(PowerServiceDumpProto.IS_LOW_POWER_MODE_ENABLED, mLowPowerModeEnabled);
|
||||
proto.write(PowerServiceDumpProto.IS_BATTERY_LEVEL_LOW, mBatteryLevelLow);
|
||||
proto.write(PowerServiceDumpProto.IS_LIGHT_DEVICE_IDLE_MODE, mLightDeviceIdleMode);
|
||||
proto.write(PowerServiceDumpProto.IS_DEVICE_IDLE_MODE, mDeviceIdleMode);
|
||||
|
||||
for (int id : mDeviceIdleWhitelist) {
|
||||
proto.write(PowerServiceDumpProto.DEVICE_IDLE_WHITELIST, id);
|
||||
}
|
||||
for (int id : mDeviceIdleTempWhitelist) {
|
||||
proto.write(PowerServiceDumpProto.DEVICE_IDLE_TEMP_WHITELIST, id);
|
||||
}
|
||||
|
||||
proto.write(PowerServiceDumpProto.LAST_WAKE_TIME_MS, mLastWakeTime);
|
||||
proto.write(PowerServiceDumpProto.LAST_SLEEP_TIME_MS, mLastSleepTime);
|
||||
proto.write(PowerServiceDumpProto.LAST_USER_ACTIVITY_TIME_MS, mLastUserActivityTime);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.LAST_USER_ACTIVITY_TIME_NO_CHANGE_LIGHTS_MS,
|
||||
mLastUserActivityTimeNoChangeLights);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.LAST_INTERACTIVE_POWER_HINT_TIME_MS,
|
||||
mLastInteractivePowerHintTime);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.LAST_SCREEN_BRIGHTNESS_BOOST_TIME_MS,
|
||||
mLastScreenBrightnessBoostTime);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.IS_SCREEN_BRIGHTNESS_BOOST_IN_PROGRESS,
|
||||
mScreenBrightnessBoostInProgress);
|
||||
proto.write(PowerServiceDumpProto.IS_DISPLAY_READY, mDisplayReady);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.IS_HOLDING_WAKE_LOCK_SUSPEND_BLOCKER,
|
||||
mHoldingWakeLockSuspendBlocker);
|
||||
proto.write(
|
||||
PowerServiceDumpProto.IS_HOLDING_DISPLAY_SUSPEND_BLOCKER,
|
||||
mHoldingDisplaySuspendBlocker);
|
||||
|
||||
final long settingsAndConfigurationToken =
|
||||
proto.start(PowerServiceDumpProto.SETTINGS_AND_CONFIGURATION);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.IS_DECOUPLE_HAL_AUTO_SUSPEND_MODE_FROM_DISPLAY_CONFIG,
|
||||
mDecoupleHalAutoSuspendModeFromDisplayConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.IS_DECOUPLE_HAL_INTERACTIVE_MODE_FROM_DISPLAY_CONFIG,
|
||||
mDecoupleHalInteractiveModeFromDisplayConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.IS_WAKE_UP_WHEN_PLUGGED_OR_UNPLUGGED_CONFIG,
|
||||
mWakeUpWhenPluggedOrUnpluggedConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.IS_WAKE_UP_WHEN_PLUGGED_OR_UNPLUGGED_IN_THEATER_MODE_CONFIG,
|
||||
mWakeUpWhenPluggedOrUnpluggedInTheaterModeConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.IS_THEATER_MODE_ENABLED,
|
||||
mTheaterModeEnabled);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.IS_SUSPEND_WHEN_SCREEN_OFF_DUE_TO_PROXIMITY_CONFIG,
|
||||
mSuspendWhenScreenOffDueToProximityConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.ARE_DREAMS_SUPPORTED_CONFIG,
|
||||
mDreamsSupportedConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.ARE_DREAMS_ENABLED_BY_DEFAULT_CONFIG,
|
||||
mDreamsEnabledByDefaultConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.ARE_DREAMS_ACTIVATED_ON_SLEEP_BY_DEFAULT_CONFIG,
|
||||
mDreamsActivatedOnSleepByDefaultConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.ARE_DREAMS_ACTIVATED_ON_DOCK_BY_DEFAULT_CONFIG,
|
||||
mDreamsActivatedOnDockByDefaultConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.ARE_DREAMS_ENABLED_ON_BATTERY_CONFIG,
|
||||
mDreamsEnabledOnBatteryConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.DREAMS_BATTERY_LEVEL_MINIMUM_WHEN_POWERED_CONFIG,
|
||||
mDreamsBatteryLevelMinimumWhenPoweredConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.DREAMS_BATTERY_LEVEL_MINIMUM_WHEN_NOT_POWERED_CONFIG,
|
||||
mDreamsBatteryLevelMinimumWhenNotPoweredConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.DREAMS_BATTERY_LEVEL_DRAIN_CUTOFF_CONFIG,
|
||||
mDreamsBatteryLevelDrainCutoffConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.ARE_DREAMS_ENABLED_SETTING,
|
||||
mDreamsEnabledSetting);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.ARE_DREAMS_ACTIVATE_ON_SLEEP_SETTING,
|
||||
mDreamsActivateOnSleepSetting);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.ARE_DREAMS_ACTIVATE_ON_DOCK_SETTING,
|
||||
mDreamsActivateOnDockSetting);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.IS_DOZE_AFTER_SCREEN_OFF_CONFIG,
|
||||
mDozeAfterScreenOffConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.IS_LOW_POWER_MODE_SETTING,
|
||||
mLowPowerModeSetting);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.IS_AUTO_LOW_POWER_MODE_CONFIGURED,
|
||||
mAutoLowPowerModeConfigured);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.IS_AUTO_LOW_POWER_MODE_SNOOZING,
|
||||
mAutoLowPowerModeSnoozing);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.MINIMUM_SCREEN_OFF_TIMEOUT_CONFIG_MS,
|
||||
mMinimumScreenOffTimeoutConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.MAXIMUM_SCREEN_DIM_DURATION_CONFIG_MS,
|
||||
mMaximumScreenDimDurationConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.MAXIMUM_SCREEN_DIM_RATIO_CONFIG,
|
||||
mMaximumScreenDimRatioConfig);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.SCREEN_OFF_TIMEOUT_SETTING_MS,
|
||||
mScreenOffTimeoutSetting);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.SLEEP_TIMEOUT_SETTING_MS,
|
||||
mSleepTimeoutSetting);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.MAXIMUM_SCREEN_OFF_TIMEOUT_FROM_DEVICE_ADMIN_MS,
|
||||
mMaximumScreenOffTimeoutFromDeviceAdmin);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.IS_MAXIMUM_SCREEN_OFF_TIMEOUT_FROM_DEVICE_ADMIN_ENFORCED_LOCKED,
|
||||
isMaximumScreenOffTimeoutFromDeviceAdminEnforcedLocked());
|
||||
|
||||
final long stayOnWhilePluggedInToken =
|
||||
proto.start(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.STAY_ON_WHILE_PLUGGED_IN);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.StayOnWhilePluggedInProto
|
||||
.IS_STAY_ON_WHILE_PLUGGED_IN_AC,
|
||||
((mStayOnWhilePluggedInSetting & BatteryManager.BATTERY_PLUGGED_AC) != 0));
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.StayOnWhilePluggedInProto
|
||||
.IS_STAY_ON_WHILE_PLUGGED_IN_USB,
|
||||
((mStayOnWhilePluggedInSetting & BatteryManager.BATTERY_PLUGGED_USB) != 0));
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.StayOnWhilePluggedInProto
|
||||
.IS_STAY_ON_WHILE_PLUGGED_IN_WIRELESS,
|
||||
((mStayOnWhilePluggedInSetting & BatteryManager.BATTERY_PLUGGED_WIRELESS)
|
||||
!= 0));
|
||||
proto.end(stayOnWhilePluggedInToken);
|
||||
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.SCREEN_BRIGHTNESS_SETTING,
|
||||
mScreenBrightnessSetting);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.SCREEN_AUTO_BRIGHTNESS_ADJUSTMENT_SETTING,
|
||||
mScreenAutoBrightnessAdjustmentSetting);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.SCREEN_BRIGHTNESS_MODE_SETTING,
|
||||
mScreenBrightnessModeSetting);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.SCREEN_BRIGHTNESS_OVERRIDE_FROM_WINDOW_MANAGER,
|
||||
mScreenBrightnessOverrideFromWindowManager);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.USER_ACTIVITY_TIMEOUT_OVERRIDE_FROM_WINDOW_MANAGER_MS,
|
||||
mUserActivityTimeoutOverrideFromWindowManager);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.IS_USER_INACTIVE_OVERRIDE_FROM_WINDOW_MANAGER,
|
||||
mUserInactiveOverrideFromWindowManager);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.TEMPORARY_SCREEN_BRIGHTNESS_SETTING_OVERRIDE,
|
||||
mTemporaryScreenBrightnessSettingOverride);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.TEMPORARY_SCREEN_AUTO_BRIGHTNESS_ADJUSTMENT_SETTING_OVERRIDE,
|
||||
mTemporaryScreenAutoBrightnessAdjustmentSettingOverride);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.DOZE_SCREEN_STATE_OVERRIDE_FROM_DREAM_MANAGER,
|
||||
mDozeScreenStateOverrideFromDreamManager);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.DOZED_SCREEN_BRIGHTNESS_OVERRIDE_FROM_DREAM_MANAGER,
|
||||
mDozeScreenBrightnessOverrideFromDreamManager);
|
||||
|
||||
final long screenBrightnessSettingLimitsToken =
|
||||
proto.start(
|
||||
PowerServiceSettingsAndConfigurationDumpProto
|
||||
.SCREEN_BRIGHTNESS_SETTING_LIMITS);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.ScreenBrightnessSettingLimitsProto
|
||||
.SETTING_MINIMUM,
|
||||
mScreenBrightnessSettingMinimum);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.ScreenBrightnessSettingLimitsProto
|
||||
.SETTING_MAXIMUM,
|
||||
mScreenBrightnessSettingMaximum);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.ScreenBrightnessSettingLimitsProto
|
||||
.SETTING_DEFAULT,
|
||||
mScreenBrightnessSettingDefault);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.ScreenBrightnessSettingLimitsProto
|
||||
.SETTING_FOR_VR_DEFAULT,
|
||||
mScreenBrightnessForVrSettingDefault);
|
||||
proto.end(screenBrightnessSettingLimitsToken);
|
||||
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.SCREEN_BRIGHTNESS_FOR_VR_SETTING,
|
||||
mScreenBrightnessForVrSetting);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.IS_DOUBLE_TAP_WAKE_ENABLED,
|
||||
mDoubleTapWakeEnabled);
|
||||
proto.write(
|
||||
PowerServiceSettingsAndConfigurationDumpProto.IS_VR_MODE_ENABLED,
|
||||
mIsVrModeEnabled);
|
||||
proto.end(settingsAndConfigurationToken);
|
||||
|
||||
final int sleepTimeout = getSleepTimeoutLocked();
|
||||
final int screenOffTimeout = getScreenOffTimeoutLocked(sleepTimeout);
|
||||
final int screenDimDuration = getScreenDimDurationLocked(screenOffTimeout);
|
||||
proto.write(PowerServiceDumpProto.SLEEP_TIMEOUT_MS, sleepTimeout);
|
||||
proto.write(PowerServiceDumpProto.SCREEN_OFF_TIMEOUT_MS, screenOffTimeout);
|
||||
proto.write(PowerServiceDumpProto.SCREEN_DIM_DURATION_MS, screenDimDuration);
|
||||
proto.write(PowerServiceDumpProto.ARE_UIDS_CHANGING, mUidsChanging);
|
||||
proto.write(PowerServiceDumpProto.ARE_UIDS_CHANGED, mUidsChanged);
|
||||
|
||||
for (int i = 0; i < mUidState.size(); i++) {
|
||||
final UidState state = mUidState.valueAt(i);
|
||||
final long uIDToken = proto.start(PowerServiceDumpProto.UIDS);
|
||||
final int uid = mUidState.keyAt(i);
|
||||
proto.write(PowerServiceDumpProto.UidProto.UID, uid);
|
||||
proto.write(PowerServiceDumpProto.UidProto.UID_STRING, UserHandle.formatUid(uid));
|
||||
proto.write(PowerServiceDumpProto.UidProto.IS_ACTIVE, state.mActive);
|
||||
proto.write(PowerServiceDumpProto.UidProto.NUM_WAKE_LOCKS, state.mNumWakeLocks);
|
||||
if (state.mProcState == ActivityManager.PROCESS_STATE_UNKNOWN) {
|
||||
proto.write(PowerServiceDumpProto.UidProto.IS_PROCESS_STATE_UNKNOWN, true);
|
||||
} else {
|
||||
proto.write(PowerServiceDumpProto.UidProto.PROCESS_STATE, state.mProcState);
|
||||
}
|
||||
proto.end(uIDToken);
|
||||
}
|
||||
|
||||
mHandler.getLooper().writeToProto(proto, PowerServiceDumpProto.LOOPER);
|
||||
|
||||
for (WakeLock wl : mWakeLocks) {
|
||||
wl.writeToProto(proto, PowerServiceDumpProto.WAKE_LOCKS);
|
||||
}
|
||||
|
||||
for (SuspendBlocker sb : mSuspendBlockers) {
|
||||
sb.writeToProto(proto, PowerServiceDumpProto.SUSPEND_BLOCKERS);
|
||||
}
|
||||
wcd = mWirelessChargerDetector;
|
||||
}
|
||||
|
||||
if (wcd != null) {
|
||||
wcd.writeToProto(proto, PowerServiceDumpProto.WIRELESS_CHARGER_DETECTOR);
|
||||
}
|
||||
proto.flush();
|
||||
}
|
||||
|
||||
private SuspendBlocker createSuspendBlockerLocked(String name) {
|
||||
SuspendBlocker suspendBlocker = new SuspendBlockerImpl(name);
|
||||
mSuspendBlockers.add(suspendBlocker);
|
||||
@@ -3471,6 +3828,32 @@ public final class PowerManagerService extends SystemService
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void writeToProto(ProtoOutputStream proto, long fieldId) {
|
||||
final long wakeLockToken = proto.start(fieldId);
|
||||
proto.write(WakeLockProto.LOCK_LEVEL, (mFlags & PowerManager.WAKE_LOCK_LEVEL_MASK));
|
||||
proto.write(WakeLockProto.TAG, mTag);
|
||||
|
||||
final long wakeLockFlagsToken = proto.start(WakeLockProto.FLAGS);
|
||||
proto.write(WakeLockProto.WakeLockFlagsProto.IS_ACQUIRE_CAUSES_WAKEUP,
|
||||
(mFlags & PowerManager.ACQUIRE_CAUSES_WAKEUP)!=0);
|
||||
proto.write(WakeLockProto.WakeLockFlagsProto.IS_ON_AFTER_RELEASE,
|
||||
(mFlags & PowerManager.ON_AFTER_RELEASE)!=0);
|
||||
proto.end(wakeLockFlagsToken);
|
||||
|
||||
proto.write(WakeLockProto.IS_DISABLED, mDisabled);
|
||||
if (mNotifiedAcquired) {
|
||||
proto.write(WakeLockProto.ACQ_MS, mAcquireTime);
|
||||
}
|
||||
proto.write(WakeLockProto.IS_NOTIFIED_LONG, mNotifiedLong);
|
||||
proto.write(WakeLockProto.UID, mOwnerUid);
|
||||
proto.write(WakeLockProto.PID, mOwnerPid);
|
||||
|
||||
if (mWorkSource != null) {
|
||||
mWorkSource.writeToProto(proto, WakeLockProto.WORK_SOURCE);
|
||||
}
|
||||
proto.end(wakeLockToken);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private String getLockLevelString() {
|
||||
switch (mFlags & PowerManager.WAKE_LOCK_LEVEL_MASK) {
|
||||
@@ -3568,6 +3951,15 @@ public final class PowerManagerService extends SystemService
|
||||
return mName + ": ref count=" + mReferenceCount;
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToProto(ProtoOutputStream proto, long fieldId) {
|
||||
final long sbToken = proto.start(fieldId);
|
||||
synchronized (this) {
|
||||
proto.write(SuspendBlockerProto.NAME, mName);
|
||||
proto.write(SuspendBlockerProto.REFERENCE_COUNT, mReferenceCount);
|
||||
}
|
||||
proto.end(sbToken);
|
||||
}
|
||||
}
|
||||
|
||||
static final class UidState {
|
||||
@@ -4055,8 +4447,19 @@ public final class PowerManagerService extends SystemService
|
||||
}
|
||||
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
|
||||
boolean isDumpProto = false;
|
||||
for (String arg : args) {
|
||||
if (arg.equals("--proto")) {
|
||||
isDumpProto = true;
|
||||
}
|
||||
}
|
||||
try {
|
||||
dumpInternal(pw);
|
||||
if (isDumpProto) {
|
||||
dumpProto(fd);
|
||||
} else {
|
||||
dumpInternal(pw);
|
||||
}
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.server.power;
|
||||
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
/**
|
||||
* Low-level suspend blocker mechanism equivalent to holding a partial wake lock.
|
||||
*
|
||||
@@ -40,4 +42,6 @@ interface SuspendBlocker {
|
||||
* The system may crash.
|
||||
*/
|
||||
void release();
|
||||
|
||||
void writeToProto(ProtoOutputStream proto, long fieldId);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,10 @@ import android.os.BatteryManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.service.power.WirelessChargerDetectorProto;
|
||||
import android.util.Slog;
|
||||
import android.util.TimeUtils;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@@ -170,6 +172,44 @@ final class WirelessChargerDetector {
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToProto(ProtoOutputStream proto, long fieldId) {
|
||||
final long wcdToken = proto.start(fieldId);
|
||||
synchronized (mLock) {
|
||||
proto.write(WirelessChargerDetectorProto.IS_POWERED_WIRELESSLY, mPoweredWirelessly);
|
||||
proto.write(WirelessChargerDetectorProto.IS_AT_REST, mAtRest);
|
||||
|
||||
final long restVectorToken = proto.start(WirelessChargerDetectorProto.REST);
|
||||
proto.write(WirelessChargerDetectorProto.VectorProto.X, mRestX);
|
||||
proto.write(WirelessChargerDetectorProto.VectorProto.Y, mRestY);
|
||||
proto.write(WirelessChargerDetectorProto.VectorProto.Z, mRestZ);
|
||||
proto.end(restVectorToken);
|
||||
|
||||
proto.write(
|
||||
WirelessChargerDetectorProto.IS_DETECTION_IN_PROGRESS, mDetectionInProgress);
|
||||
proto.write(WirelessChargerDetectorProto.DETECTION_START_TIME_MS, mDetectionStartTime);
|
||||
proto.write(
|
||||
WirelessChargerDetectorProto.IS_MUST_UPDATE_REST_POSITION,
|
||||
mMustUpdateRestPosition);
|
||||
proto.write(WirelessChargerDetectorProto.TOTAL_SAMPLES, mTotalSamples);
|
||||
proto.write(WirelessChargerDetectorProto.MOVING_SAMPLES, mMovingSamples);
|
||||
|
||||
final long firstSampleVectorToken =
|
||||
proto.start(WirelessChargerDetectorProto.FIRST_SAMPLE);
|
||||
proto.write(WirelessChargerDetectorProto.VectorProto.X, mFirstSampleX);
|
||||
proto.write(WirelessChargerDetectorProto.VectorProto.Y, mFirstSampleY);
|
||||
proto.write(WirelessChargerDetectorProto.VectorProto.Z, mFirstSampleZ);
|
||||
proto.end(firstSampleVectorToken);
|
||||
|
||||
final long lastSampleVectorToken =
|
||||
proto.start(WirelessChargerDetectorProto.LAST_SAMPLE);
|
||||
proto.write(WirelessChargerDetectorProto.VectorProto.X, mLastSampleX);
|
||||
proto.write(WirelessChargerDetectorProto.VectorProto.Y, mLastSampleY);
|
||||
proto.write(WirelessChargerDetectorProto.VectorProto.Z, mLastSampleZ);
|
||||
proto.end(lastSampleVectorToken);
|
||||
}
|
||||
proto.end(wcdToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the charging state and returns true if docking was detected.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user