1 /* 2 * Copyright (C) 2023 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.server.wm; 17 18 import android.annotation.IntDef; 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.content.res.CompatibilityInfo.CompatScale; 22 23 import java.lang.annotation.Retention; 24 import java.lang.annotation.RetentionPolicy; 25 26 /** 27 * An interface for services that need to provide compatibility scale different than 28 * the default android compatibility. 29 */ 30 public interface CompatScaleProvider { 31 32 /** 33 * The unique id of each provider registered by a system service which determines the order 34 * it will execute in. 35 */ 36 @IntDef(prefix = { "COMPAT_SCALE_MODE_" }, value = { 37 // Order Ids for system services 38 COMPAT_SCALE_MODE_SYSTEM_FIRST, 39 COMPAT_SCALE_MODE_GAME, 40 COMPAT_SCALE_MODE_PRODUCT, 41 COMPAT_SCALE_MODE_SYSTEM_LAST, // Update this when adding new ids 42 }) 43 @Retention(RetentionPolicy.SOURCE) 44 @interface CompatScaleModeOrderId {} 45 46 /** 47 * The first id, used by the framework to determine the valid range of ids. 48 * @hide 49 */ 50 int COMPAT_SCALE_MODE_SYSTEM_FIRST = 0; 51 52 /** 53 * TODO(b/295207384) 54 * The identifier for {@link android.app.GameManagerInternal} provider 55 * @hide 56 */ 57 int COMPAT_SCALE_MODE_GAME = 1; 58 59 /** 60 * The identifier for a provider which is specific to the type of android product like 61 * Automotive, Wear, TV etc. 62 * @hide 63 */ 64 int COMPAT_SCALE_MODE_PRODUCT = 2; 65 66 /** 67 * The final id, used by the framework to determine the valid range of ids. Update this when 68 * adding new ids. 69 * @hide 70 */ 71 int COMPAT_SCALE_MODE_SYSTEM_LAST = COMPAT_SCALE_MODE_PRODUCT; 72 73 /** 74 * Returns {@code true} if the id is in the range of valid system services 75 * @hide 76 */ isValidOrderId(int id)77 static boolean isValidOrderId(int id) { 78 return (id >= COMPAT_SCALE_MODE_SYSTEM_FIRST && id <= COMPAT_SCALE_MODE_SYSTEM_LAST); 79 } 80 81 /** 82 * @return an instance of {@link CompatScale} to apply for the given package 83 */ 84 @Nullable getCompatScale(@onNull String packageName, int uid)85 CompatScale getCompatScale(@NonNull String packageName, int uid); 86 } 87