Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a6de64a7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes If58d648d,Iec51a349 am: de246e16 am: f5075fb1

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1566903

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I913f264d55280bcec9d7b2e86f2b30090840d26a
parents 1bba2cda f5075fb1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ ogunwale@google.com
jjaggi@google.com
roosa@google.com
per-file usagestatsservice.proto, usagestatsservice_v2.proto = mwachens@google.com
per-file apphibernationservice.proto = file:/core/java/android/apphibernation/OWNERS

# Biometrics
kchyn@google.com
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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 = "proto2";
package com.android.server.apphibernation;

option java_multiple_files = true;

// Proto for hibernation states for all packages for a user.
message UserLevelHibernationStatesProto {
  repeated UserLevelHibernationStateProto hibernation_state = 1;
}

// Proto for com.android.server.apphibernation.UserLevelState.
message UserLevelHibernationStateProto {
  optional string package_name = 1;
  optional bool hibernated = 2;
}

// Proto for global hibernation states for all packages.
message GlobalLevelHibernationStatesProto {
  repeated GlobalLevelHibernationStateProto hibernation_state = 1;
}

// Proto for com.android.server.apphibernation.GlobalLevelState
message GlobalLevelHibernationStateProto {
  optional string package_name = 1;
  optional bool hibernated = 2;
}
 No newline at end of file
+228 −56

File changed.

Preview size limit exceeded, changes collapsed.

+78 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.apphibernation;


import android.annotation.NonNull;
import android.annotation.Nullable;
import android.util.Slog;
import android.util.proto.ProtoInputStream;
import android.util.proto.ProtoOutputStream;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Reads and writes protos for {@link GlobalLevelState} hiberation states.
 */
final class GlobalLevelHibernationProto implements ProtoReadWriter<List<GlobalLevelState>> {
    private static final String TAG = "GlobalLevelHibernationProtoReadWriter";

    @Override
    public void writeToProto(@NonNull ProtoOutputStream stream,
            @NonNull List<GlobalLevelState> data) {
        for (int i = 0, size = data.size(); i < size; i++) {
            long token = stream.start(GlobalLevelHibernationStatesProto.HIBERNATION_STATE);
            GlobalLevelState state = data.get(i);
            stream.write(GlobalLevelHibernationStateProto.PACKAGE_NAME, state.packageName);
            stream.write(GlobalLevelHibernationStateProto.HIBERNATED, state.hibernated);
            stream.end(token);
        }
    }

    @Override
    public @Nullable List<GlobalLevelState> readFromProto(@NonNull ProtoInputStream stream)
            throws IOException {
        List<GlobalLevelState> list = new ArrayList<>();
        while (stream.nextField() != ProtoInputStream.NO_MORE_FIELDS) {
            if (stream.getFieldNumber()
                    != (int) GlobalLevelHibernationStatesProto.HIBERNATION_STATE) {
                continue;
            }
            GlobalLevelState state = new GlobalLevelState();
            long token = stream.start(GlobalLevelHibernationStatesProto.HIBERNATION_STATE);
            while (stream.nextField() != ProtoInputStream.NO_MORE_FIELDS) {
                switch (stream.getFieldNumber()) {
                    case (int) GlobalLevelHibernationStateProto.PACKAGE_NAME:
                        state.packageName =
                                stream.readString(GlobalLevelHibernationStateProto.PACKAGE_NAME);
                        break;
                    case (int) GlobalLevelHibernationStateProto.HIBERNATED:
                        state.hibernated =
                                stream.readBoolean(GlobalLevelHibernationStateProto.HIBERNATED);
                        break;
                    default:
                        Slog.w(TAG, "Undefined field in proto: " + stream.getFieldNumber());
                }
            }
            stream.end(token);
            list.add(state);
        }
        return list;
    }
}
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.apphibernation;

/**
 * Data class that contains global hibernation state for a package.
 */
final class GlobalLevelState {
    public String packageName;
    public boolean hibernated;
}
Loading