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

Commit 7db570e4 authored by Songchun Fan's avatar Songchun Fan
Browse files

[SettingsProvider] use new atom to log setting changed

BUG: 228619157
Test: m statsd_testdrive
Test: statsd_testdrive 474
Test: (in another terminal) adb shell settings put system volume_voice 3
Test: Observe the output of statsd_testdrive which contains:
  data {
    aggregated_atom_info {
      atom {
        settings_provider_setting_changed {
          user_id: 0
          name: "volume_voice"
          type: 1
          change_type: 0
        }
      }
      elapsed_timestamp_nanos: 162651078691
    }
  }

Change-Id: I40e889bdc96f8142228fdb1bc1ee29884b2f7986
parent ea8df765
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ import android.util.proto.ProtoOutputStream;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.content.PackageMonitor;
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.FrameworkStatsLog;
import com.android.providers.settings.SettingsState.Setting;
import com.android.server.SystemConfig;

@@ -224,6 +225,11 @@ public class SettingsProvider extends ContentProvider {
    public static final int SETTINGS_TYPE_SSAID = SettingsState.SETTINGS_TYPE_SSAID;
    public static final int SETTINGS_TYPE_CONFIG = SettingsState.SETTINGS_TYPE_CONFIG;

    private static final int CHANGE_TYPE_INSERT = 0;
    private static final int CHANGE_TYPE_DELETE = 1;
    private static final int CHANGE_TYPE_UPDATE = 2;
    private static final int CHANGE_TYPE_RESET = 3;

    private static final Bundle NULL_SETTING_BUNDLE = Bundle.forPair(
            Settings.NameValueTable.VALUE, null);

@@ -3020,6 +3026,9 @@ public class SettingsProvider extends ContentProvider {
            if (forceNotify || success) {
                notifyForSettingsChange(key, name);
            }
            if (success) {
                logSettingChanged(userId, name, type, CHANGE_TYPE_INSERT);
            }
            return success;
        }

@@ -3063,6 +3072,9 @@ public class SettingsProvider extends ContentProvider {
            if (forceNotify || success) {
                notifyForSettingsChange(key, name);
            }
            if (success) {
                logSettingChanged(userId, name, type, CHANGE_TYPE_DELETE);
            }
            return success;
        }

@@ -3085,7 +3097,9 @@ public class SettingsProvider extends ContentProvider {
            if (forceNotify || success) {
                notifyForSettingsChange(key, name);
            }

            if (success) {
                logSettingChanged(userId, name, type, CHANGE_TYPE_UPDATE);
            }
            return success;
        }

@@ -3129,6 +3143,7 @@ public class SettingsProvider extends ContentProvider {
                            if (settingsState.resetSettingLocked(name)) {
                                someSettingChanged = true;
                                notifyForSettingsChange(key, name);
                                logSettingChanged(userId, name, type, CHANGE_TYPE_RESET);
                            }
                        }
                        if (someSettingChanged) {
@@ -3149,6 +3164,7 @@ public class SettingsProvider extends ContentProvider {
                            if (settingsState.resetSettingLocked(name)) {
                                someSettingChanged = true;
                                notifyForSettingsChange(key, name);
                                logSettingChanged(userId, name, type, CHANGE_TYPE_RESET);
                            }
                        }
                        if (someSettingChanged) {
@@ -3170,10 +3186,12 @@ public class SettingsProvider extends ContentProvider {
                                if (settingsState.resetSettingLocked(name)) {
                                    someSettingChanged = true;
                                    notifyForSettingsChange(key, name);
                                    logSettingChanged(userId, name, type, CHANGE_TYPE_RESET);
                                }
                            } else if (settingsState.deleteSettingLocked(name)) {
                                someSettingChanged = true;
                                notifyForSettingsChange(key, name);
                                logSettingChanged(userId, name, type, CHANGE_TYPE_DELETE);
                            }
                        }
                        if (someSettingChanged) {
@@ -3193,10 +3211,12 @@ public class SettingsProvider extends ContentProvider {
                            if (settingsState.resetSettingLocked(name)) {
                                someSettingChanged = true;
                                notifyForSettingsChange(key, name);
                                logSettingChanged(userId, name, type, CHANGE_TYPE_RESET);
                            }
                        } else if (settingsState.deleteSettingLocked(name)) {
                            someSettingChanged = true;
                            notifyForSettingsChange(key, name);
                            logSettingChanged(userId, name, type, CHANGE_TYPE_DELETE);
                        }
                        if (someSettingChanged) {
                            settingsState.persistSyncLocked();
@@ -3438,6 +3458,11 @@ public class SettingsProvider extends ContentProvider {
            mHandler.obtainMessage(MyHandler.MSG_NOTIFY_DATA_CHANGED).sendToTarget();
        }

        private void logSettingChanged(int userId, String name, int type, int changeType) {
            FrameworkStatsLog.write(FrameworkStatsLog.SETTINGS_PROVIDER_SETTING_CHANGED, userId,
                    name, type, changeType);
        }

        private void notifyForConfigSettingsChangeLocked(int key, String prefix,
                List<String> changedSettings) {