1 /* 2 * Copyright (C) 2022 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.grammaticalinflection; 18 19 import android.annotation.Nullable; 20 import android.content.res.Configuration; 21 22 /** 23 * System-server internal interface to the {@link android.app.GrammaticalInflectionManager}. 24 * 25 * @hide Only for use within the system server. 26 */ 27 public abstract class GrammaticalInflectionManagerInternal { 28 /** 29 * Returns the app-gender to be backed up as a data-blob. 30 */ getBackupPayload(int userId)31 public abstract @Nullable byte[] getBackupPayload(int userId); 32 33 /** 34 * Restores the app-gender that were previously backed up. 35 * 36 * <p>This method will parse the input data blob and restore the gender for apps which are 37 * present on the device. It will stage the gender data for the apps which are not installed 38 * at the time this is called, to be referenced later when the app is installed. 39 */ stageAndApplyRestoredPayload(byte[] payload, int userId)40 public abstract void stageAndApplyRestoredPayload(byte[] payload, int userId); 41 42 /** 43 * Get the current system grammatical gender for the particular user. 44 * 45 * @return the value of grammatical gender 46 * 47 * @see Configuration#getGrammaticalGender 48 */ getSystemGrammaticalGender(int userId)49 public abstract @Configuration.GrammaticalGender int getSystemGrammaticalGender(int userId); 50 51 /** 52 * Get the final merged value of the global grammatical gender, user- or devsettings-set. 53 * 54 * @return the value of grammatical gender 55 * 56 */ mergedFinalSystemGrammaticalGender()57 public abstract @Configuration.GrammaticalGender int mergedFinalSystemGrammaticalGender(); 58 59 /** 60 * Get the grammatical gender from developer settings global override. 61 * 62 * @return the value of grammatical gender 63 */ 64 public abstract getGrammaticalGenderFromDeveloperSettings()65 @Configuration.GrammaticalGender int getGrammaticalGenderFromDeveloperSettings(); 66 67 /** 68 * Whether the package can get the system grammatical gender or not. 69 */ canGetSystemGrammaticalGender(int uid)70 public abstract boolean canGetSystemGrammaticalGender(int uid); 71 72 73 /** 74 * Returns the system-gender to be backed up as a data-blob. 75 */ getSystemBackupPayload(int userId)76 public abstract @Nullable byte[] getSystemBackupPayload(int userId); 77 78 /** 79 * Restores the system-gender that were previously backed up. 80 */ applyRestoredSystemPayload(byte[] payload, int userId)81 public abstract void applyRestoredSystemPayload(byte[] payload, int userId); 82 } 83