• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.launcher3.shadows;
17 
18 import android.app.backup.BackupManager;
19 import android.os.UserHandle;
20 import android.util.LongSparseArray;
21 
22 import androidx.annotation.Nullable;
23 
24 import org.robolectric.annotation.Implementation;
25 import org.robolectric.annotation.Implements;
26 import org.robolectric.shadows.ShadowBackupManager;
27 
28 /**
29  * Extension of {@link ShadowBackupManager} with missing shadow methods
30  */
31 @Implements(value = BackupManager.class)
32 public class LShadowBackupManager extends ShadowBackupManager {
33 
34     private LongSparseArray<UserHandle> mProfileMapping = new LongSparseArray<>();
35 
addProfile(long userSerial, UserHandle userHandle)36     public void addProfile(long userSerial, UserHandle userHandle) {
37         mProfileMapping.put(userSerial, userHandle);
38     }
39 
40     @Implementation
41     @Nullable
getUserForAncestralSerialNumber(long ancestralSerialNumber)42     public UserHandle getUserForAncestralSerialNumber(long ancestralSerialNumber) {
43         return mProfileMapping.get(ancestralSerialNumber);
44     }
45 }
46