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

Commit 66ff1d62 authored by Artem Iglikov's avatar Artem Iglikov
Browse files

Add unit tests for com.android.server.backup.utils

Also add missing javadocs to some new classes.

Bug: 37939902
Test: runtest -p com.android.server.backup frameworks-services
Change-Id: I7c24cec754af9ea6caee7791a11085b8c174c427
parent 6c2f7870
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
/*
 * 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.server.backup.restore;

import android.content.pm.IPackageDeleteObserver;
+16 −0
Original line number Diff line number Diff line
/*
 * 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.server.backup.restore;

import android.app.IBackupAgent;
+16 −0
Original line number Diff line number Diff line
/*
 * 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.server.backup.restore;

import android.app.PackageInstallObserver;
+16 −0
Original line number Diff line number Diff line
/*
 * 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.server.backup.utils;

import android.content.pm.ApplicationInfo;
+43 −8
Original line number Diff line number Diff line
/*
 * 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.server.backup.utils;

import static android.app.backup.BackupManagerMonitor.EXTRA_LOG_EVENT_PACKAGE_NAME;
@@ -54,6 +70,15 @@ public class BackupManagerMonitorUtils {
        return null;
    }

    /**
     * Adds given key-value pair in the bundle and returns the bundle. If bundle was null it will
     * be created.
     *
     * @param extras - bundle where to add key-value to, if null a new bundle will be created.
     * @param key - key.
     * @param value - value.
     * @return extras if it was not null and new bundle otherwise.
     */
    public static Bundle putMonitoringExtra(Bundle extras, String key, String value) {
        if (extras == null) {
            extras = new Bundle();
@@ -62,14 +87,15 @@ public class BackupManagerMonitorUtils {
        return extras;
    }

    private static Bundle putMonitoringExtra(Bundle extras, String key, int value) {
        if (extras == null) {
            extras = new Bundle();
        }
        extras.putInt(key, value);
        return extras;
    }

    /**
     * Adds given key-value pair in the bundle and returns the bundle. If bundle was null it will
     * be created.
     *
     * @param extras - bundle where to add key-value to, if null a new bundle will be created.
     * @param key - key.
     * @param value - value.
     * @return extras if it was not null and new bundle otherwise.
     */
    public static Bundle putMonitoringExtra(Bundle extras, String key, long value) {
        if (extras == null) {
            extras = new Bundle();
@@ -78,6 +104,15 @@ public class BackupManagerMonitorUtils {
        return extras;
    }

    /**
     * Adds given key-value pair in the bundle and returns the bundle. If bundle was null it will
     * be created.
     *
     * @param extras - bundle where to add key-value to, if null a new bundle will be created.
     * @param key - key.
     * @param value - value.
     * @return extras if it was not null and new bundle otherwise.
     */
    public static Bundle putMonitoringExtra(Bundle extras, String key, boolean value) {
        if (extras == null) {
            extras = new Bundle();
Loading