Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7ee99be authored by Zoey Chen's avatar Zoey Chen
Browse files

[ToA] Do not copy grammatical gender from admin user, we should get grammatical gender by userId

Bug: 328599280
Test: atest GrammaticalInflectionManagerTest
Test: atest FrameworksCoreTests
Change-Id: I50f63fc0cbdc4ef2c055f054e7809b0186b7d516
parent be87f2e4
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -143,4 +143,24 @@ public class GrammaticalInflectionManager {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Peeks the current grammatical gender of privileged application from the specific user's
     * encrypted file.
     *
     * @return the value of system grammatical gender.
     * @hide
     * @see Configuration#getGrammaticalGender
     */
    @RequiresPermission(Manifest.permission.READ_SYSTEM_GRAMMATICAL_GENDER)
    @FlaggedApi(Flags.FLAG_SYSTEM_TERMS_OF_ADDRESS_ENABLED)
    @Configuration.GrammaticalGender
    public int peekSystemGrammaticalGenderByUserId(int userId) {
        try {
            return mService.peekSystemGrammaticalGenderByUserId(mContext.getAttributionSource(),
                    userId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -43,4 +43,10 @@ import android.content.AttributionSource;
      * Gets the grammatical gender from system.
      */
     int getSystemGrammaticalGender(in AttributionSource attributionSource, int userId);

     /**
      * Peeks the grammatical gender from system by user Id.
      */
     int peekSystemGrammaticalGenderByUserId(in AttributionSource attributionSource, int userId);

 }
+10 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
package android.provider;
import static android.app.Flags.systemTermsOfAddressEnabled;
import android.Manifest;
import android.annotation.CallbackExecutor;
import android.annotation.FlaggedApi;
@@ -37,6 +39,7 @@ import android.app.ActivityThread;
import android.app.AppOpsManager;
import android.app.Application;
import android.app.AutomaticZenRule;
import android.app.GrammaticalInflectionManager;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.SearchManager;
@@ -4594,6 +4597,13 @@ public final class Settings {
            }
            outConfig.fontWeightAdjustment = Settings.Secure.getIntForUser(
                    cr, Settings.Secure.FONT_WEIGHT_ADJUSTMENT, DEFAULT_FONT_WEIGHT, userHandle);
            if (systemTermsOfAddressEnabled()) {
                GrammaticalInflectionManager manager =
                        ActivityThread.currentApplication().getApplicationContext()
                                .getSystemService(GrammaticalInflectionManager.class);
                outConfig.setGrammaticalGender(
                        manager.peekSystemGrammaticalGenderByUserId(userHandle));
            }
            final String localeValue =
                    Settings.System.getStringForUser(cr, SYSTEM_LOCALES, userHandle);
+9 −0
Original line number Diff line number Diff line
@@ -142,6 +142,15 @@ public class GrammaticalInflectionService extends SystemService {
                    : GRAMMATICAL_GENDER_NOT_SPECIFIED;
        }

        @Override
        public int peekSystemGrammaticalGenderByUserId(AttributionSource attributionSource,
                int userId) {
            return canGetSystemGrammaticalGender(attributionSource)
                    ? GrammaticalInflectionService.this.getSystemGrammaticalGender(
                    attributionSource, userId)
                    : GRAMMATICAL_GENDER_NOT_SPECIFIED;
        }

        @Override
        public void onShellCommand(FileDescriptor in, FileDescriptor out,
                FileDescriptor err, String[] args, ShellCallback callback,