1 /* 2 * Copyright (C) 2021 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 17 package com.android.server.locales; 18 19 import static android.content.res.Configuration.GRAMMATICAL_GENDER_NOT_SPECIFIED; 20 21 import android.annotation.Nullable; 22 import android.os.LocaleList; 23 24 import com.android.server.wm.ActivityTaskManagerInternal.PackageConfigurationUpdater; 25 26 /** 27 * Test double for the {@link PackageConfigurationUpdater}. For use in 28 * {@link LocaleManagerServiceTest}s to stub out storage and check for state-based changes. 29 */ 30 class FakePackageConfigurationUpdater implements PackageConfigurationUpdater { 31 FakePackageConfigurationUpdater()32 FakePackageConfigurationUpdater() {} 33 34 private int mGender = GRAMMATICAL_GENDER_NOT_SPECIFIED; 35 36 LocaleList mLocales = null; 37 38 @Override setNightMode(int nightMode)39 public PackageConfigurationUpdater setNightMode(int nightMode) { 40 return this; 41 } 42 43 @Override setLocales(LocaleList locales)44 public PackageConfigurationUpdater setLocales(LocaleList locales) { 45 mLocales = locales; 46 return this; 47 } 48 49 @Override setGrammaticalGender(int gender)50 public PackageConfigurationUpdater setGrammaticalGender(int gender) { 51 mGender = gender; 52 return this; 53 } 54 55 @Override commit()56 public boolean commit() { 57 return mLocales != null; 58 } 59 60 /** 61 * Returns the locales that were stored during the test run. Returns {@code null} if no locales 62 * were set. 63 */ 64 @Nullable getStoredLocales()65 LocaleList getStoredLocales() { 66 return mLocales; 67 } 68 69 /** 70 * Returns the gender that were stored during the test run. 71 */ getGender()72 int getGender() { 73 return mGender; 74 } 75 } 76