Skip to content
Snippets Groups Projects
Commit d57687df authored by Calvin Pan's avatar Calvin Pan Committed by Android (Google) Code Review
Browse files

Merge changes I7ee8cd9f,Id8bc42cc

* changes:
  Clearing the user settings when feature flag off
  Log grammatical inflection API usage
parents 58af2f25 f9899e94
No related branches found
No related tags found
No related merge requests found
......@@ -21,11 +21,14 @@ import static android.content.res.Configuration.GRAMMATICAL_GENDER_NOT_SPECIFIED
import android.annotation.Nullable;
import android.app.IGrammaticalInflectionManager;
import android.content.Context;
import android.content.pm.PackageManagerInternal;
import android.os.Binder;
import android.os.IBinder;
import android.os.Process;
import android.os.SystemProperties;
import android.util.Log;
import com.android.internal.util.FrameworkStatsLog;
import com.android.server.LocalServices;
import com.android.server.SystemService;
import com.android.server.wm.ActivityTaskManagerInternal;
......@@ -36,9 +39,10 @@ import com.android.server.wm.ActivityTaskManagerInternal;
* <p>This service is API entry point for storing app-specific grammatical inflection.
*/
public class GrammaticalInflectionService extends SystemService {
private final String TAG = "GrammaticalInflection";
private final GrammaticalInflectionBackupHelper mBackupHelper;
private final ActivityTaskManagerInternal mActivityTaskManagerInternal;
private PackageManagerInternal mPackageManagerInternal;
private static final String GRAMMATICAL_INFLECTION_ENABLED =
"i18n.grammatical_Inflection.enabled";
......@@ -55,6 +59,7 @@ public class GrammaticalInflectionService extends SystemService {
public GrammaticalInflectionService(Context context) {
super(context);
mActivityTaskManagerInternal = LocalServices.getService(ActivityTaskManagerInternal.class);
mPackageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
mBackupHelper = new GrammaticalInflectionBackupHelper(
this, context.getPackageManager());
}
......@@ -110,13 +115,25 @@ public class GrammaticalInflectionService extends SystemService {
protected void setRequestedApplicationGrammaticalGender(
String appPackageName, int userId, int gender) {
int preValue = getApplicationGrammaticalGender(appPackageName, userId);
final ActivityTaskManagerInternal.PackageConfigurationUpdater updater =
mActivityTaskManagerInternal.createPackageConfigurationUpdater(appPackageName,
userId);
if (!SystemProperties.getBoolean(GRAMMATICAL_INFLECTION_ENABLED, true)) {
if (preValue != GRAMMATICAL_GENDER_NOT_SPECIFIED) {
Log.d(TAG, "Clearing the user's grammatical gender setting");
updater.setGrammaticalGender(GRAMMATICAL_GENDER_NOT_SPECIFIED).commit();
}
return;
}
final ActivityTaskManagerInternal.PackageConfigurationUpdater updater =
mActivityTaskManagerInternal.createPackageConfigurationUpdater(appPackageName,
userId);
final int uid = mPackageManagerInternal.getPackageUid(appPackageName, 0, userId);
FrameworkStatsLog.write(FrameworkStatsLog.GRAMMATICAL_INFLECTION_CHANGED,
FrameworkStatsLog.APPLICATION_GRAMMATICAL_INFLECTION_CHANGED__SOURCE_ID__OTHERS,
uid,
gender != GRAMMATICAL_GENDER_NOT_SPECIFIED,
preValue != GRAMMATICAL_GENDER_NOT_SPECIFIED);
updater.setGrammaticalGender(gender).commit();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment