From 8b93ba74714532887548d8baf2c9a00dd1efa758 Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Thu, 28 May 2020 00:10:42 +0100 Subject: Add shadow for PersistentDataBlockManager Bug: 157451551 Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.password Change-Id: I269889309fd11adfa65195e3a6608f164af2abb2 --- .../shadows/ShadowPersistentDataBlockManager.java | 42 ++++++++++++++++++++++ .../robolectric/shadows/ShadowServiceManager.java | 6 ++++ 2 files changed, 48 insertions(+) create mode 100644 shadows/framework/src/main/java/org/robolectric/shadows/ShadowPersistentDataBlockManager.java diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPersistentDataBlockManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPersistentDataBlockManager.java new file mode 100644 index 000000000..a48480df1 --- /dev/null +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowPersistentDataBlockManager.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 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 org.robolectric.shadows; + +import android.service.persistentdata.PersistentDataBlockManager; + +import org.robolectric.annotation.Implementation; +import org.robolectric.annotation.Implements; +import org.robolectric.annotation.Resetter; + +@Implements(PersistentDataBlockManager.class) +public class ShadowPersistentDataBlockManager { + private static int sDataBlockSize = 0; + + @Resetter + public static void reset() { + sDataBlockSize = 0; + } + + @Implementation + protected int getDataBlockSize() { + return sDataBlockSize; + } + + public static void setDataBlockSize(int dataBlockSize) { + sDataBlockSize = dataBlockSize; + } +} diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowServiceManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowServiceManager.java index 41b3f9cb0..d7dae9b36 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowServiceManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowServiceManager.java @@ -52,6 +52,8 @@ import android.os.IUserManager; import android.os.RemoteException; import android.os.ServiceManager; import android.os.storage.IStorageManager; +import android.service.persistentdata.IPersistentDataBlockService; + import com.android.internal.app.IAppOpsService; import com.android.internal.app.IBatteryStats; import com.android.internal.appwidget.IAppWidgetService; @@ -166,6 +168,10 @@ public class ShadowServiceManager { map.put( Context.MEDIA_SESSION_SERVICE, createDeepBinder(ISessionManager.class, "android.media.session.ISessionManager")); + map.put( + Context.PERSISTENT_DATA_BLOCK_SERVICE, + createBinder(IPersistentDataBlockService.class, + "android.service.persistentdata.IPersistentDataBlockService")); } if (RuntimeEnvironment.getApiLevel() >= M) { map.put( -- cgit v1.2.3