diff options
24 files changed, 774 insertions, 194 deletions
diff --git a/car-lib/src/android/car/vms/IVmsPublisherService.aidl b/car-lib/src/android/car/vms/IVmsPublisherService.aidl index 5e210fe703..f122ec6a21 100644 --- a/car-lib/src/android/car/vms/IVmsPublisherService.aidl +++ b/car-lib/src/android/car/vms/IVmsPublisherService.aidl @@ -31,7 +31,7 @@ interface IVmsPublisherService { oneway void publish(in IBinder token, int layer, int version, in byte[] message) = 0; /** - * Returns whether the layer/version has any clients subscribed to it. + * Returns the list of VmsLayers that has any clients subscribed to it. */ List<VmsLayer> getSubscriptions() = 1; diff --git a/car-lib/src/android/car/vms/VmsLayerDependency.java b/car-lib/src/android/car/vms/VmsLayerDependency.java index 254330e3a3..a6c513d0e5 100644 --- a/car-lib/src/android/car/vms/VmsLayerDependency.java +++ b/car-lib/src/android/car/vms/VmsLayerDependency.java @@ -20,6 +20,7 @@ import android.car.annotation.FutureFeature; import android.os.Parcel; import android.os.Parcelable; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -30,14 +31,14 @@ import java.util.List; @FutureFeature public final class VmsLayerDependency implements Parcelable { private final VmsLayer mLayer; - private final List<VmsLayer> mDependency = new ArrayList<>(); + private final List<VmsLayer> mDependency; /** * Construct a dependency for layer on other layers. */ public VmsLayerDependency(VmsLayer layer, List<VmsLayer> dependencies) { mLayer = layer; - mDependency.addAll(dependencies); + mDependency = Collections.unmodifiableList(dependencies); } /** @@ -45,6 +46,7 @@ public final class VmsLayerDependency implements Parcelable { */ public VmsLayerDependency(VmsLayer layer) { mLayer = layer; + mDependency = Collections.emptyList(); } /** @@ -62,7 +64,7 @@ public final class VmsLayerDependency implements Parcelable { * Returns the dependencies. */ public List<VmsLayer> getDependencies() { - return new ArrayList<VmsLayer>(mDependency); + return mDependency; } public static final Parcelable.Creator<VmsLayerDependency> CREATOR = new @@ -88,7 +90,8 @@ public final class VmsLayerDependency implements Parcelable { private VmsLayerDependency(Parcel in) { mLayer = in.readParcelable(VmsLayer.class.getClassLoader()); - in.readParcelableList(mDependency, VmsLayer.class.getClassLoader()); - + List<VmsLayer> dependency = new ArrayList<>(); + in.readParcelableList(dependency, VmsLayer.class.getClassLoader()); + mDependency = Collections.unmodifiableList(dependency); } }
\ No newline at end of file diff --git a/car-lib/src/android/car/vms/VmsLayersOffering.java b/car-lib/src/android/car/vms/VmsLayersOffering.java index e3691bcc06..12b3dd30b2 100644 --- a/car-lib/src/android/car/vms/VmsLayersOffering.java +++ b/car-lib/src/android/car/vms/VmsLayersOffering.java @@ -20,6 +20,7 @@ import android.car.annotation.FutureFeature; import android.os.Parcel; import android.os.Parcelable; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -30,13 +31,17 @@ import java.util.List; @FutureFeature public final class VmsLayersOffering implements Parcelable { - private final List<VmsLayerDependency> mDependencies = new ArrayList<>(); + private final List<VmsLayerDependency> mDependencies; + + public VmsLayersOffering(List<VmsLayerDependency> dependencies) { + mDependencies = Collections.unmodifiableList(dependencies); + } /** * Returns the dependencies. */ public List<VmsLayerDependency> getDependencies() { - return new ArrayList<VmsLayerDependency>(mDependencies); + return mDependencies; } public static final Parcelable.Creator<VmsLayersOffering> CREATOR = new @@ -60,6 +65,8 @@ public final class VmsLayersOffering implements Parcelable { } private VmsLayersOffering(Parcel in) { - in.readParcelableList(mDependencies, VmsLayerDependency.class.getClassLoader()); + List<VmsLayerDependency> dependencies = new ArrayList<>(); + in.readParcelableList(dependencies, VmsLayerDependency.class.getClassLoader()); + mDependencies = Collections.unmodifiableList(dependencies); } }
\ No newline at end of file diff --git a/car-lib/src/android/car/vms/VmsPublisherClientService.java b/car-lib/src/android/car/vms/VmsPublisherClientService.java index 7cda632e8a..c1ef1dd06c 100644 --- a/car-lib/src/android/car/vms/VmsPublisherClientService.java +++ b/car-lib/src/android/car/vms/VmsPublisherClientService.java @@ -58,7 +58,7 @@ public abstract class VmsPublisherClientService extends Service { private final VmsPublisherClientBinder mVmsPublisherClient = new VmsPublisherClientBinder(this); private volatile IVmsPublisherService mVmsPublisherService = null; @GuardedBy("mLock") - private volatile IBinder mToken = null; + private IBinder mToken = null; @Override public final IBinder onBind(Intent intent) { @@ -122,8 +122,7 @@ public abstract class VmsPublisherClientService extends Service { throw new IllegalStateException("VmsPublisherService does not have a valid token."); } try { - mVmsPublisherService - .publish(token, layerId, layerVersion, payload); + mVmsPublisherService.publish(token, layerId, layerVersion, payload); return true; } catch (RemoteException e) { Log.e(TAG, "unable to publish message: " + payload, e); diff --git a/car_product/build/car.mk b/car_product/build/car.mk index a65c5aa897..16aa275218 100644 --- a/car_product/build/car.mk +++ b/car_product/build/car.mk @@ -82,6 +82,7 @@ PRODUCT_PACKAGES += \ CarLensPickerApp \ LocalMediaPlayer \ CarMediaApp \ + CarMessengerApp \ Stream \ CarHvacApp \ CarMapsPlaceholder \ diff --git a/car_product/overlay/frameworks/base/packages/SettingsProvider/res/values/default.xml b/car_product/overlay/frameworks/base/packages/SettingsProvider/res/values/default.xml index 8fa076cee2..a8b1fa2f05 100644 --- a/car_product/overlay/frameworks/base/packages/SettingsProvider/res/values/default.xml +++ b/car_product/overlay/frameworks/base/packages/SettingsProvider/res/values/default.xml @@ -17,9 +17,9 @@ */ --> <resources> - <bool name="def_device_provisioned">false</bool> - <bool name="def_user_setup_complete">false</bool> + <!-- There is no frx in the emulator so default to being fully set up. --> + <bool name="def_device_provisioned">true</bool> + <bool name="def_user_setup_complete">true</bool> <bool name="def_bluetooth_on">true</bool> <bool name="def_wifi_on">false</bool> - <bool name="def_lockscreen_disabled">true</bool> </resources> diff --git a/car_product/overlay/frameworks/packages/SettingsProvider/res/values/default.xml b/car_product/overlay/frameworks/packages/SettingsProvider/res/values/default.xml deleted file mode 100644 index a44a93c025..0000000000 --- a/car_product/overlay/frameworks/packages/SettingsProvider/res/values/default.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/** - * Copyright (c) 2015, 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. - */ ---> -<resources> - <bool name="def_device_provisioned">false</bool> - <integer name="add_users_when_locked">1</integer> -</resources> diff --git a/obd2-lib/src/com/android/car/obd2/Obd2Command.java b/obd2-lib/src/com/android/car/obd2/Obd2Command.java index 3cbbf58e6f..e02c6af50a 100644 --- a/obd2-lib/src/com/android/car/obd2/Obd2Command.java +++ b/obd2-lib/src/com/android/car/obd2/Obd2Command.java @@ -17,9 +17,23 @@ package com.android.car.obd2; import com.android.car.obd2.commands.AmbientAirTemperature; +import com.android.car.obd2.commands.CalculatedEngineLoad; +import com.android.car.obd2.commands.EngineCoolantTemperature; import com.android.car.obd2.commands.EngineOilTemperature; +import com.android.car.obd2.commands.EngineRuntime; +import com.android.car.obd2.commands.FuelGaugePressure; +import com.android.car.obd2.commands.FuelSystemStatus; +import com.android.car.obd2.commands.FuelTankLevel; +import com.android.car.obd2.commands.FuelTrimCommand.Bank1LongTermFuelTrimCommand; +import com.android.car.obd2.commands.FuelTrimCommand.Bank1ShortTermFuelTrimCommand; +import com.android.car.obd2.commands.FuelTrimCommand.Bank2LongTermFuelTrimCommand; +import com.android.car.obd2.commands.FuelTrimCommand.Bank2ShortTermFuelTrimCommand; +import com.android.car.obd2.commands.RPM; +import com.android.car.obd2.commands.Speed; +import com.android.car.obd2.commands.ThrottlePosition; import java.io.IOException; import java.util.HashMap; +import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -51,16 +65,22 @@ public abstract class Obd2Command<ValueType> { private static final HashMap<Integer, OutputSemanticHandler<Float>> SUPPORTED_FLOAT_COMMANDS = new HashMap<>(); - private static void addSupportedIntegerCommand( - OutputSemanticHandler<Integer> integerOutputSemanticHandler) { - SUPPORTED_INTEGER_COMMANDS.put( - integerOutputSemanticHandler.getPid(), integerOutputSemanticHandler); + private static void addSupportedIntegerCommands( + OutputSemanticHandler<Integer>... integerOutputSemanticHandlers) { + for (OutputSemanticHandler<Integer> integerOutputSemanticHandler : + integerOutputSemanticHandlers) { + SUPPORTED_INTEGER_COMMANDS.put( + integerOutputSemanticHandler.getPid(), integerOutputSemanticHandler); + } } - private static void addSupportedFloatCommand( - OutputSemanticHandler<Float> floatOutputSemanticHandler) { - SUPPORTED_FLOAT_COMMANDS.put( - floatOutputSemanticHandler.getPid(), floatOutputSemanticHandler); + private static void addSupportedFloatCommands( + OutputSemanticHandler<Float>... floatOutputSemanticHandlers) { + for (OutputSemanticHandler<Float> floatOutputSemanticHandler : + floatOutputSemanticHandlers) { + SUPPORTED_FLOAT_COMMANDS.put( + floatOutputSemanticHandler.getPid(), floatOutputSemanticHandler); + } } public static Set<Integer> getSupportedIntegerCommands() { @@ -80,8 +100,23 @@ public abstract class Obd2Command<ValueType> { } static { - addSupportedFloatCommand(new AmbientAirTemperature()); - addSupportedIntegerCommand(new EngineOilTemperature()); + addSupportedFloatCommands( + new AmbientAirTemperature(), + new CalculatedEngineLoad(), + new FuelTankLevel(), + new Bank2ShortTermFuelTrimCommand(), + new Bank2LongTermFuelTrimCommand(), + new Bank1LongTermFuelTrimCommand(), + new Bank1ShortTermFuelTrimCommand(), + new ThrottlePosition()); + addSupportedIntegerCommands( + new EngineOilTemperature(), + new EngineCoolantTemperature(), + new FuelGaugePressure(), + new FuelSystemStatus(), + new RPM(), + new EngineRuntime(), + new Speed()); } protected final int mMode; @@ -89,7 +124,7 @@ public abstract class Obd2Command<ValueType> { Obd2Command(int mode, OutputSemanticHandler<ValueType> semanticHandler) { mMode = mode; - mSemanticHandler = semanticHandler; + mSemanticHandler = Objects.requireNonNull(semanticHandler); } public abstract Optional<ValueType> run(Obd2Connection connection) throws Exception; diff --git a/obd2-lib/src/com/android/car/obd2/commands/CalculatedEngineLoad.java b/obd2-lib/src/com/android/car/obd2/commands/CalculatedEngineLoad.java new file mode 100644 index 0000000000..ca06343b81 --- /dev/null +++ b/obd2-lib/src/com/android/car/obd2/commands/CalculatedEngineLoad.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.car.obd2.commands; + +import com.android.car.obd2.IntegerArrayStream; +import com.android.car.obd2.Obd2Command; +import java.util.Optional; + +public class CalculatedEngineLoad implements Obd2Command.OutputSemanticHandler<Float> { + @Override + public int getPid() { + return 0x04; + } + + @Override + public Optional<Float> consume(IntegerArrayStream data) { + return data.hasAtLeast( + 1, theData -> Optional.of(theData.consume() / 2.25f), theData -> Optional.empty()); + } +} diff --git a/obd2-lib/src/com/android/car/obd2/commands/EngineCoolantTemperature.java b/obd2-lib/src/com/android/car/obd2/commands/EngineCoolantTemperature.java new file mode 100644 index 0000000000..41ad73ce12 --- /dev/null +++ b/obd2-lib/src/com/android/car/obd2/commands/EngineCoolantTemperature.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.car.obd2.commands; + +import com.android.car.obd2.IntegerArrayStream; +import com.android.car.obd2.Obd2Command; +import java.util.Optional; + +public class EngineCoolantTemperature implements Obd2Command.OutputSemanticHandler<Integer> { + @Override + public int getPid() { + return 0x05; + } + + @Override + public Optional<Integer> consume(IntegerArrayStream data) { + return data.hasAtLeast( + 1, theData -> Optional.of(theData.consume() - 40), theData -> Optional.empty()); + } +} diff --git a/obd2-lib/src/com/android/car/obd2/commands/EngineRuntime.java b/obd2-lib/src/com/android/car/obd2/commands/EngineRuntime.java new file mode 100644 index 0000000000..13c886fcd1 --- /dev/null +++ b/obd2-lib/src/com/android/car/obd2/commands/EngineRuntime.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.car.obd2.commands; + +import com.android.car.obd2.IntegerArrayStream; +import com.android.car.obd2.Obd2Command; +import java.util.Optional; + +public class EngineRuntime implements Obd2Command.OutputSemanticHandler<Integer> { + @Override + public int getPid() { + return 0x1F; + } + + @Override + public Optional<Integer> consume(IntegerArrayStream data) { + return data.hasAtLeast( + 2, + theData -> Optional.of(theData.consume() * 256 + theData.consume()), + theData -> Optional.empty()); + } +} diff --git a/obd2-lib/src/com/android/car/obd2/commands/FuelGaugePressure.java b/obd2-lib/src/com/android/car/obd2/commands/FuelGaugePressure.java new file mode 100644 index 0000000000..fc7aacea29 --- /dev/null +++ b/obd2-lib/src/com/android/car/obd2/commands/FuelGaugePressure.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.car.obd2.commands; + +import com.android.car.obd2.IntegerArrayStream; +import com.android.car.obd2.Obd2Command; +import java.util.Optional; + +public class FuelGaugePressure implements Obd2Command.OutputSemanticHandler<Integer> { + @Override + public int getPid() { + return 0x0A; + } + + @Override + public Optional<Integer> consume(IntegerArrayStream data) { + return data.hasAtLeast( + 1, theData -> Optional.of(theData.consume() * 3), theData -> Optional.empty()); + } +} diff --git a/obd2-lib/src/com/android/car/obd2/commands/FuelSystemStatus.java b/obd2-lib/src/com/android/car/obd2/commands/FuelSystemStatus.java new file mode 100644 index 0000000000..65001f8c89 --- /dev/null +++ b/obd2-lib/src/com/android/car/obd2/commands/FuelSystemStatus.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.car.obd2.commands; + +import com.android.car.obd2.IntegerArrayStream; +import com.android.car.obd2.Obd2Command; +import java.util.Optional; + +public class FuelSystemStatus implements Obd2Command.OutputSemanticHandler<Integer> { + @Override + public int getPid() { + return 0x03; + } + + @Override + public Optional<Integer> consume(IntegerArrayStream data) { + return data.hasAtLeast( + 1, theData -> Optional.of(theData.consume()), theData -> Optional.empty()); + } +} diff --git a/obd2-lib/src/com/android/car/obd2/commands/FuelTankLevel.java b/obd2-lib/src/com/android/car/obd2/commands/FuelTankLevel.java new file mode 100644 index 0000000000..190b554678 --- /dev/null +++ b/obd2-lib/src/com/android/car/obd2/commands/FuelTankLevel.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.car.obd2.commands; + +import com.android.car.obd2.IntegerArrayStream; +import com.android.car.obd2.Obd2Command; +import java.util.Optional; + +public class FuelTankLevel implements Obd2Command.OutputSemanticHandler<Float> { + @Override + public int getPid() { + return 0x2F; + } + + @Override + public Optional<Float> consume(IntegerArrayStream data) { + return data.hasAtLeast( + 1, + theData -> Optional.of(theData.consume() * (100.0f / 255.0f)), + theData -> Optional.empty()); + } +} diff --git a/obd2-lib/src/com/android/car/obd2/commands/FuelTrimCommand.java b/obd2-lib/src/com/android/car/obd2/commands/FuelTrimCommand.java new file mode 100644 index 0000000000..5f22a6e544 --- /dev/null +++ b/obd2-lib/src/com/android/car/obd2/commands/FuelTrimCommand.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.car.obd2.commands; + +import com.android.car.obd2.IntegerArrayStream; +import com.android.car.obd2.Obd2Command; +import java.util.Optional; + +public abstract class FuelTrimCommand implements Obd2Command.OutputSemanticHandler<Float> { + @Override + public Optional<Float> consume(IntegerArrayStream data) { + return data.hasAtLeast( + 1, + theData -> Optional.of(3 * theData.consume() / 1.28f - 100), + theData -> Optional.empty()); + } + + public static class Bank1ShortTermFuelTrimCommand extends FuelTrimCommand { + @Override + public int getPid() { + return 0x06; + } + } + + public static class Bank1LongTermFuelTrimCommand extends FuelTrimCommand { + @Override + public int getPid() { + return 0x07; + } + } + + public static class Bank2ShortTermFuelTrimCommand extends FuelTrimCommand { + @Override + public int getPid() { + return 0x08; + } + } + + public static class Bank2LongTermFuelTrimCommand extends FuelTrimCommand { + @Override + public int getPid() { + return 0x09; + } + } +} diff --git a/obd2-lib/src/com/android/car/obd2/commands/RPM.java b/obd2-lib/src/com/android/car/obd2/commands/RPM.java new file mode 100644 index 0000000000..c4bb91fdf6 --- /dev/null +++ b/obd2-lib/src/com/android/car/obd2/commands/RPM.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.car.obd2.commands; + +import com.android.car.obd2.IntegerArrayStream; +import com.android.car.obd2.Obd2Command; +import java.util.Optional; + +public class RPM implements Obd2Command.OutputSemanticHandler<Integer> { + @Override + public int getPid() { + return 0x0C; + } + + @Override + public Optional<Integer> consume(IntegerArrayStream data) { + return data.hasAtLeast( + 2, + theData -> Optional.of(theData.consume() * 256 + theData.consume() / 4), + theData -> Optional.empty()); + } +} diff --git a/obd2-lib/src/com/android/car/obd2/commands/Speed.java b/obd2-lib/src/com/android/car/obd2/commands/Speed.java new file mode 100644 index 0000000000..c797ce5c2a --- /dev/null +++ b/obd2-lib/src/com/android/car/obd2/commands/Speed.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.car.obd2.commands; + +import com.android.car.obd2.IntegerArrayStream; +import com.android.car.obd2.Obd2Command; +import java.util.Optional; + +public class Speed implements Obd2Command.OutputSemanticHandler<Integer> { + @Override + public int getPid() { + return 0x0D; + } + + @Override + public Optional<Integer> consume(IntegerArrayStream data) { + return data.hasAtLeast( + 1, theData -> Optional.of(theData.consume()), theData -> Optional.empty()); + } +} diff --git a/obd2-lib/src/com/android/car/obd2/commands/ThrottlePosition.java b/obd2-lib/src/com/android/car/obd2/commands/ThrottlePosition.java new file mode 100644 index 0000000000..71f4fee92f --- /dev/null +++ b/obd2-lib/src/com/android/car/obd2/commands/ThrottlePosition.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.car.obd2.commands; + +import com.android.car.obd2.IntegerArrayStream; +import com.android.car.obd2.Obd2Command; +import java.util.Optional; + +public class ThrottlePosition implements Obd2Command.OutputSemanticHandler<Float> { + @Override + public int getPid() { + return 0x11; + } + + @Override + public Optional<Float> consume(IntegerArrayStream data) { + return data.hasAtLeast( + 1, + theData -> Optional.of(theData.consume() * 0.392157f), + theData -> Optional.empty()); + } +} diff --git a/tests/VmsPublisherClientSample/src/com/google/android/car/vms/publisher/VmsPublisherClientSampleService.java b/tests/VmsPublisherClientSample/src/com/google/android/car/vms/publisher/VmsPublisherClientSampleService.java index 9f96ac2087..1677eafe85 100644 --- a/tests/VmsPublisherClientSample/src/com/google/android/car/vms/publisher/VmsPublisherClientSampleService.java +++ b/tests/VmsPublisherClientSample/src/com/google/android/car/vms/publisher/VmsPublisherClientSampleService.java @@ -22,6 +22,7 @@ import android.os.Handler; import android.os.Message; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; /** * This service is launched during the initialization of the VMS publisher service. @@ -32,7 +33,8 @@ public class VmsPublisherClientSampleService extends VmsPublisherClientService { public static final int TEST_LAYER_ID = 0; public static final int TEST_LAYER_VERSION = 0; - private byte counter = 0; + private byte mCounter = 0; + private AtomicBoolean mInitialized = new AtomicBoolean(false); private final Handler mHandler = new Handler() { @Override @@ -49,21 +51,22 @@ public class VmsPublisherClientSampleService extends VmsPublisherClientService { */ @Override public void onVmsPublisherServiceReady() { - // Notify to the application that everything is ready to start publishing. - Message message = mHandler.obtainMessage(PUBLISH_EVENT); - mHandler.sendMessage(message); } @Override public void onVmsSubscriptionChange(List<VmsLayer> layers, long sequence) { - // TODO(b/35327656): implement sample logic once the routing is ready (e.g. move the code in - // onVmsPublisherServiceReady to this function). + if (mInitialized.compareAndSet(false, true)) { + for (VmsLayer layer : layers) { + if (layer.getId() == TEST_LAYER_ID && layer.getVersion() == TEST_LAYER_VERSION) { + mHandler.sendEmptyMessage(PUBLISH_EVENT); + } + } + } } private void periodicPublish() { - publish(TEST_LAYER_ID, TEST_LAYER_VERSION, new byte[]{counter}); - ++counter; - Message message = mHandler.obtainMessage(PUBLISH_EVENT); - mHandler.sendMessageDelayed(message, 1000); + publish(TEST_LAYER_ID, TEST_LAYER_VERSION, new byte[]{mCounter}); + ++mCounter; + mHandler.sendEmptyMessageDelayed(PUBLISH_EVENT, 1000); } } diff --git a/tests/obd2_test/src/com/android/car/obd2/test/Obd2CommandTest.java b/tests/obd2_test/src/com/android/car/obd2/test/Obd2CommandTest.java new file mode 100644 index 0000000000..b342cbc8c6 --- /dev/null +++ b/tests/obd2_test/src/com/android/car/obd2/test/Obd2CommandTest.java @@ -0,0 +1,233 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.car.obd2.test; + +import static com.android.car.obd2.test.Utils.concatIntArrays; +import static com.android.car.obd2.test.Utils.stringsToIntArray; +import static org.junit.Assert.*; + +import com.android.car.obd2.Obd2Command; +import com.android.car.obd2.Obd2Connection; +import java.util.Optional; +import org.junit.Test; + +public class Obd2CommandTest { + private static final String[] EXPECTED_INIT_COMMANDS = + new String[] { + "ATD\r", "ATZ\r", "AT E0\r", "AT L0\r", "AT S0\r", "AT H0\r", "AT SP 0\r" + }; + + private static final String OBD2_PROMPT = ">"; + + private static final String[] EXPECTED_INIT_RESPONSES = + new String[] { + OBD2_PROMPT, + OBD2_PROMPT, + OBD2_PROMPT, + OBD2_PROMPT, + OBD2_PROMPT, + OBD2_PROMPT, + OBD2_PROMPT + }; + + private static final float FLOAT_EQUALITY_DELTA = 0.0001f; + + void checkLiveFrameIntCommand(int pid, String responseBytes, int expectedResponse) { + String[] commandToSend = new String[] {String.format("01%02X\r", pid)}; + + String[] responseToGet = + new String[] {String.format("41 %02X %s", pid, responseBytes), OBD2_PROMPT}; + + MockObd2UnderlyingTransport transport = + new MockObd2UnderlyingTransport( + concatIntArrays( + stringsToIntArray(EXPECTED_INIT_COMMANDS), + stringsToIntArray(commandToSend)), + concatIntArrays( + stringsToIntArray(EXPECTED_INIT_RESPONSES), + stringsToIntArray(responseToGet))); + Obd2Connection obd2Connection = new Obd2Connection(transport); + Obd2Command<Integer> commandObject = + Obd2Command.getLiveFrameCommand(Obd2Command.getIntegerCommand(pid)); + assertNotNull(commandObject); + Optional<Integer> receivedResponse = Optional.empty(); + try { + receivedResponse = commandObject.run(obd2Connection); + } catch (Exception e) { + assertTrue("live frame command " + pid + " caused an exception: " + e, false); + } + assertTrue("live frame contains a response", receivedResponse.isPresent()); + assertEquals(expectedResponse, (int) receivedResponse.get()); + } + + void checkLiveFrameFloatCommand(int pid, String responseBytes, float expectedResponse) { + String[] commandToSend = new String[] {String.format("01%02X\r", pid)}; + + String[] responseToGet = + new String[] {String.format("41 %02X %s", pid, responseBytes), OBD2_PROMPT}; + + MockObd2UnderlyingTransport transport = + new MockObd2UnderlyingTransport( + concatIntArrays( + stringsToIntArray(EXPECTED_INIT_COMMANDS), + stringsToIntArray(commandToSend)), + concatIntArrays( + stringsToIntArray(EXPECTED_INIT_RESPONSES), + stringsToIntArray(responseToGet))); + Obd2Connection obd2Connection = new Obd2Connection(transport); + Obd2Command<Float> commandObject = + Obd2Command.getLiveFrameCommand(Obd2Command.getFloatCommand(pid)); + assertNotNull(commandObject); + Optional<Float> receivedResponse = Optional.empty(); + try { + receivedResponse = commandObject.run(obd2Connection); + } catch (Exception e) { + assertTrue("live frame command " + pid + " caused an exception: " + e, false); + } + assertTrue("live frame contains a response", receivedResponse.isPresent()); + assertEquals(expectedResponse, (float) receivedResponse.get(), FLOAT_EQUALITY_DELTA); + } + + void checkFreezeFrameIntCommand(int pid, String responseBytes, int expectedResponse) { + String[] commandToSend = new String[] {String.format("02%02X 01\r", pid)}; + + String[] responseToGet = + new String[] {String.format("02 %02X 01 %s", pid, responseBytes), OBD2_PROMPT}; + + MockObd2UnderlyingTransport transport = + new MockObd2UnderlyingTransport( + concatIntArrays( + stringsToIntArray(EXPECTED_INIT_COMMANDS), + stringsToIntArray(commandToSend)), + concatIntArrays( + stringsToIntArray(EXPECTED_INIT_RESPONSES), + stringsToIntArray(responseToGet))); + Obd2Connection obd2Connection = new Obd2Connection(transport); + Obd2Command<Integer> commandObject = + Obd2Command.getFreezeFrameCommand(Obd2Command.getIntegerCommand(pid), 0x1); + assertNotNull(commandObject); + Optional<Integer> receivedResponse = Optional.empty(); + try { + receivedResponse = commandObject.run(obd2Connection); + } catch (Exception e) { + assertTrue("freeze frame command " + pid + " caused an exception: " + e, false); + } + assertTrue("freeze frame contains a response", receivedResponse.isPresent()); + assertEquals(expectedResponse, (int) receivedResponse.get()); + } + + void checkFreezeFrameFloatCommand(int pid, String responseBytes, float expectedResponse) { + String[] commandToSend = new String[] {String.format("02%02X 01\r", pid)}; + + String[] responseToGet = + new String[] {String.format("02 %02X 01 %s", pid, responseBytes), OBD2_PROMPT}; + + MockObd2UnderlyingTransport transport = + new MockObd2UnderlyingTransport( + concatIntArrays( + stringsToIntArray(EXPECTED_INIT_COMMANDS), + stringsToIntArray(commandToSend)), + concatIntArrays( + stringsToIntArray(EXPECTED_INIT_RESPONSES), + stringsToIntArray(responseToGet))); + Obd2Connection obd2Connection = new Obd2Connection(transport); + Obd2Command<Float> commandObject = + Obd2Command.getFreezeFrameCommand(Obd2Command.getFloatCommand(pid), 0x1); + assertNotNull(commandObject); + Optional<Float> receivedResponse = Optional.empty(); + try { + receivedResponse = commandObject.run(obd2Connection); + } catch (Exception e) { + assertTrue("freeze frame command " + pid + " caused an exception: " + e, false); + } + assertTrue("freeze frame contains a response", receivedResponse.isPresent()); + assertEquals(expectedResponse, (float) receivedResponse.get(), FLOAT_EQUALITY_DELTA); + } + + void checkCommand(int pid, String responseBytes, int expectedResponse) { + checkLiveFrameIntCommand(pid, responseBytes, expectedResponse); + checkFreezeFrameIntCommand(pid, responseBytes, expectedResponse); + } + + void checkCommand(int pid, String responseBytes, float expectedResponse) { + checkLiveFrameFloatCommand(pid, responseBytes, expectedResponse); + checkFreezeFrameFloatCommand(pid, responseBytes, expectedResponse); + } + + @Test + public void testEngineOilTemperature() { + checkCommand(0x5C, "87", 95); + } + + @Test + public void testAmbientAirTemperature() { + checkCommand(0x46, "A1", 63.137257f); + } + + @Test + public void testCalculatedEngineLoad() { + checkCommand(0x04, "34", 23.1111f); + } + + @Test + public void testEngineCoolantTemperature() { + checkCommand(0x05, "63", 59); + } + + @Test + public void testFuelGaugePressure() { + checkCommand(0x0A, "12", 54); + } + + @Test + public void testFuelSystemStatus() { + checkCommand(0x03, "08", 8); + } + + @Test + public void testFuelTankLevel() { + checkCommand(0x2F, "5F", 37.2549f); + } + + @Test + public void testFuelTrim() { + checkCommand(0x06, "42", 54.6875f); + checkCommand(0x07, "42", 54.6875f); + checkCommand(0x08, "42", 54.6875f); + checkCommand(0x09, "42", 54.6875f); + } + + @Test + public void testRpm() { + checkCommand(0x0C, "12 0F", 4611); + } + + @Test + public void testEngineRuntime() { + checkCommand(0x1F, "04 10", 1040); + } + + @Test + public void testSpeed() { + checkCommand(0x0D, "82", 130); + } + + @Test + public void testThrottlePosition() { + checkCommand(0x11, "3D", 23.921576f); + } +} diff --git a/tests/obd2_test/src/com/android/car/obd2/test/Obd2ConnectionTest.java b/tests/obd2_test/src/com/android/car/obd2/test/Obd2ConnectionTest.java deleted file mode 100644 index a5f06e1591..0000000000 --- a/tests/obd2_test/src/com/android/car/obd2/test/Obd2ConnectionTest.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.car.obd2.test; - -import static org.junit.Assert.*; - -import com.android.car.obd2.Obd2Command; -import com.android.car.obd2.Obd2Connection; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Optional; -import org.junit.Test; - -public class Obd2ConnectionTest { - private static int[] stringsToIntArray(String... strings) { - ArrayList<Integer> arrayList = new ArrayList<>(); - for (String string : strings) { - string.chars().forEach(arrayList::add); - } - return arrayList.stream().mapToInt(Integer::intValue).toArray(); - } - - private static int[] concatIntArrays(int[] array1, int[] array2) { - int[] newArray = Arrays.copyOf(array1, array1.length + array2.length); - System.arraycopy(array2, 0, newArray, array1.length, array2.length); - return newArray; - } - - private static final String[] EXPECTED_INIT_COMMANDS = - new String[] { - "ATD\r", "ATZ\r", "AT E0\r", "AT L0\r", "AT S0\r", "AT H0\r", "AT SP 0\r" - }; - - private static final int AIR_TEMPERATURE_PID = 0x46; - private static final int ENGINE_OIL_TEMPERATURE_PID = 0x5C; - - private static final String[] EXPECTED_AIR_TEMPERATURE_COMMANDS = new String[] {"0146\r"}; - private static final String[] EXPECTED_ENGINE_OIL_TEMPERATURE_COMMANDS = - new String[] {"015C\r"}; - - private static final String OBD2_PROMPT = ">"; - - private static final String[] EXPECTED_INIT_RESPONSES = - new String[] { - OBD2_PROMPT, - OBD2_PROMPT, - OBD2_PROMPT, - OBD2_PROMPT, - OBD2_PROMPT, - OBD2_PROMPT, - OBD2_PROMPT - }; - - private static final String[] EXPECTED_AIR_TEMPERATURE_RESPONSES = - new String[] {"41 46 A1", OBD2_PROMPT}; - private static final String[] EXPECTED_ENGINE_OIL_TEMPERATURE_RESPONSES = - new String[] {"41 5C 87", OBD2_PROMPT}; - - @Test - public void testEstablishConnection() { - MockObd2UnderlyingTransport transport = - new MockObd2UnderlyingTransport( - stringsToIntArray(EXPECTED_INIT_COMMANDS), - stringsToIntArray(EXPECTED_INIT_RESPONSES)); - Obd2Connection obd2Connection = new Obd2Connection(transport); - } - - @Test - public void testAmbientAirTemperature() { - MockObd2UnderlyingTransport transport = - new MockObd2UnderlyingTransport( - concatIntArrays( - stringsToIntArray(EXPECTED_INIT_COMMANDS), - stringsToIntArray(EXPECTED_AIR_TEMPERATURE_COMMANDS)), - concatIntArrays( - stringsToIntArray(EXPECTED_INIT_RESPONSES), - stringsToIntArray(EXPECTED_AIR_TEMPERATURE_RESPONSES))); - Obd2Connection obd2Connection = new Obd2Connection(transport); - Obd2Command<Float> airTemperatureCommand = - Obd2Command.getLiveFrameCommand(Obd2Command.getFloatCommand(AIR_TEMPERATURE_PID)); - Optional<Float> airTemperature = Optional.empty(); - try { - airTemperature = airTemperatureCommand.run(obd2Connection); - } catch (Exception e) { - assertTrue("airTemperature caused an exception: " + e, false); - } - assertTrue(airTemperature.isPresent()); - assertEquals(63.137257, (double) airTemperature.get(), 0.001); - } - - @Test - public void testEngineOilTemperature() { - MockObd2UnderlyingTransport transport = - new MockObd2UnderlyingTransport( - concatIntArrays( - stringsToIntArray(EXPECTED_INIT_COMMANDS), - stringsToIntArray(EXPECTED_ENGINE_OIL_TEMPERATURE_COMMANDS)), - concatIntArrays( - stringsToIntArray(EXPECTED_INIT_RESPONSES), - stringsToIntArray(EXPECTED_ENGINE_OIL_TEMPERATURE_RESPONSES))); - Obd2Connection obd2Connection = new Obd2Connection(transport); - Obd2Command<Integer> engineOilTemperatureCommand = - Obd2Command.getLiveFrameCommand( - Obd2Command.getIntegerCommand(ENGINE_OIL_TEMPERATURE_PID)); - Optional<Integer> engineOilTemperature = Optional.empty(); - try { - engineOilTemperature = engineOilTemperatureCommand.run(obd2Connection); - } catch (Exception e) { - assertTrue("engineOilTemperature caused an exception: " + e, false); - } - assertTrue(engineOilTemperature.isPresent()); - assertEquals(95, (int) engineOilTemperature.get()); - } -} diff --git a/tests/obd2_test/src/com/android/car/obd2/test/Utils.java b/tests/obd2_test/src/com/android/car/obd2/test/Utils.java new file mode 100644 index 0000000000..63bebe78f1 --- /dev/null +++ b/tests/obd2_test/src/com/android/car/obd2/test/Utils.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.car.obd2.test; + +import java.util.ArrayList; +import java.util.Arrays; + +public class Utils { + private Utils() {} + + static int[] stringsToIntArray(String... strings) { + ArrayList<Integer> arrayList = new ArrayList<>(); + for (String string : strings) { + string.chars().forEach(arrayList::add); + } + return arrayList.stream().mapToInt(Integer::intValue).toArray(); + } + + static int[] concatIntArrays(int[] array1, int[] array2) { + int[] newArray = Arrays.copyOf(array1, array1.length + array2.length); + System.arraycopy(array2, 0, newArray, array1.length, array2.length); + return newArray; + } +} diff --git a/tools/bootanalyze/bootanalyze.py b/tools/bootanalyze/bootanalyze.py index d685209309..d91c56d0e4 100755 --- a/tools/bootanalyze/bootanalyze.py +++ b/tools/bootanalyze/bootanalyze.py @@ -47,6 +47,8 @@ ADB_CMD = "adb" TIMING_THRESHOLD = 5.0 BOOT_PROP = "\[ro\.boottime\.([^\]]+)\]:\s+\[(\d+)\]" +max_wait_time = BOOT_TIME_TOO_BIG + def main(): global ADB_CMD @@ -65,6 +67,9 @@ def main(): error_time = BOOT_TIME_TOO_BIG * 10 if args.errortime: error_time = float(args.errortime) + if args.maxwaittime: + global max_wait_time + max_wait_time = float(args.maxwaittime) components_to_monitor = {} if args.componentmonitor: @@ -169,15 +174,16 @@ def capture_bugreport(bugreport_hint, boot_complete_time): def iterate(args, search_events, timings, cfg, error_time, components_to_monitor): if args.reboot: - reboot() + reboot(args.fs_check) dmesg_events, e = collect_events(search_events, ADB_CMD + ' shell su root dmesg -w', {},\ [ KERNEL_BOOT_COMPLETE ]) + logcat_stop_events = [ LOGCAT_BOOT_COMPLETE, KERNEL_BOOT_COMPLETE, LAUNCHER_START] + if args.fs_check: + logcat_stop_events.append("FsStat") logcat_events, logcat_timing_events = collect_events( - search_events, ADB_CMD + ' logcat -b all -v epoch', timings, [ LOGCAT_BOOT_COMPLETE,\ - KERNEL_BOOT_COMPLETE, \ - LAUNCHER_START ]) + search_events, ADB_CMD + ' logcat -b all -v epoch', timings, logcat_stop_events) logcat_event_time = extract_time( logcat_events, TIME_LOGCAT, float); logcat_original_time = extract_time( @@ -308,7 +314,6 @@ def iterate(args, search_events, timings, cfg, error_time, components_to_monitor if events[LOGCAT_BOOT_COMPLETE] > error_time and not args.ignore: capture_bugreport("bootuptoolong", events[LOGCAT_BOOT_COMPLETE]) - return None, None, None for k, v in components_to_monitor.iteritems(): value_measured = timing_points.get(k) @@ -316,6 +321,18 @@ def iterate(args, search_events, timings, cfg, error_time, components_to_monitor capture_bugreport(k + "-" + str(value_measured), events[LOGCAT_BOOT_COMPLETE]) break + if args.fs_check: + fs_stat = None + if logcat_events.get("FsStat"): + fs_stat_pattern = cfg["events"]["FsStat"] + m = re.search(fs_stat_pattern, logcat_events.get("FsStat")) + if m: + fs_stat = m.group(1) + print 'fs_stat:', fs_stat + + if fs_stat and fs_stat != "0x5" and fs_stat != "0x15": + capture_bugreport("fs_stat_" + fs_stat, events[LOGCAT_BOOT_COMPLETE]) + return data_points, timing_points, boottime_events def debug(string): @@ -348,6 +365,12 @@ def init_arguments(): help='android device serial number') parser.add_argument('-e', '--errortime', dest='errortime', action='store', help='handle bootup time bigger than this as error') + parser.add_argument('-w', '--maxwaittime', dest='maxwaittime', action='store', + help='wait for up to this time to collect logs. Retry after this time.' +\ + ' Default is 200 sec.') + parser.add_argument('-f', '--fs_check', dest='fs_check', + action='store_true', + help='check fs_stat after reboot', ) parser.add_argument('-m', '--componentmonitor', dest='componentmonitor', action='store', help='capture bugreport if specified timing component is taking more than ' +\ 'certain time. Unlike errortime, the result will not be rejected in' +\ @@ -394,6 +417,7 @@ def collect_events(search_events, command, timings, stop_events): out = process.stdout data_available = stop_events is None zygote_pids = [] + start_time = time.time() for line in out: if not data_available: @@ -418,6 +442,11 @@ def collect_events(search_events, command, timings, stop_events): timing_events[timing_event].append(line) debug("timing_event[{0}] captured: {1}".format(timing_event, line)) + time_passed = time.time() - start_time + if time_passed > max_wait_time: + print "timeout waiting for event, continue" + break + process.terminate() return events, timing_events @@ -461,9 +490,15 @@ def extract_time(events, pattern, date_transform_function): print "Failed to find time for event: ", event, data return result -def reboot(): - print 'Rebooting the device' - subprocess.call(ADB_CMD + ' shell su root svc power reboot', shell=True) + + +def reboot(use_adb_reboot): + if use_adb_reboot: + print 'Rebooting the device using adb reboot' + subprocess.call(ADB_CMD + ' reboot', shell=True) + else: + print 'Rebooting the device using svc power reboot' + subprocess.call(ADB_CMD + ' shell su root svc power reboot', shell=True) print 'Waiting the device' subprocess.call(ADB_CMD + ' wait-for-device', shell=True) diff --git a/tools/bootanalyze/config.yaml b/tools/bootanalyze/config.yaml index 1adec00cba..f8e9fc47a4 100644 --- a/tools/bootanalyze/config.yaml +++ b/tools/bootanalyze/config.yaml @@ -2,6 +2,7 @@ time_correction_key: correction timings: system_server: SystemServerTiming(Async)?\s*:\s*(?P<name>[^\s]+) took to complete:\s(?P<time>[0-9]+)ms + fs_shutdown: (?P<name>boot_fs_shutdown),(?P<time>[0-9]+),([0-9]+) events: kernel: Linux version @@ -43,3 +44,5 @@ events: BootComplete: Starting phase 1000 BootComplete_kernel: processing action \(sys\.boot_completed=1\) LauncherStart: START.*HOME.*(NexusLauncherActivity|GEL) + FsStat: fs_stat, partition:userdata stat:(0x\S+) + |