[TeseCase] unify the getResourcesString
Bug: 173099559 Test: atest PreferredNetworkModePreferenceControllerTest (PASS) atest OpenNetworkSelectPagePreferenceControllerTest (PASS) atest MobilePlanPreferenceControllerTest (PASS) atest MobileDataPreferenceControllerTest (PASS) atest Enhanced4gLteSliceHelperTest (PASS) atest AutoSelectPreferenceControllerTest (PASS) Change-Id: I9a2e3d69cbd933a1282d51b7d8869e6a1ec4cb14
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 com.android.settings.testutils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public final class ResourcesUtils {
|
||||
public static int getResourcesId(Context context, String type, String name) {
|
||||
return context.getResources().getIdentifier(name, type, context.getPackageName());
|
||||
}
|
||||
|
||||
public static String getResourcesString(Context context, String name) {
|
||||
return context.getResources().getString(getResourcesId(context, "string", name));
|
||||
}
|
||||
|
||||
public static String getResourcesString(Context context, String name, Object value) {
|
||||
return context.getResources().getString(getResourcesId(context, "string", name), value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user