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

Commit c28b2bbb authored by David Chen's avatar David Chen
Browse files

Adds logging to push settings changed to statsd.

Introduces atom and logging for every time a setting is updated.
We also include the previous value to validate our logging
data quality. We need to add the INTERACT_ACROSS_USERS_FULL
permission to prevent a security exception during testing; since the
logging occurs from system_server uid, this security exception should
not occur normally.

Test: Manual by inspecting the statsd output while toggling settings.
Change-Id: I92ca2afa596e54e61936e22611d749bb60ccb364
parent aaad26df
Loading
Loading
Loading
Loading
+45 −12
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ message StatsEvent {
        WifiSignalStrengthChanged wifi_signal_strength_changed = 38;
        WifiScanStateChanged wifi_scan_state_changed = 39;
        PhoneSignalStrengthChanged phone_signal_strength_changed = 40;

        SettingChanged setting_changed = 41;
        // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
    }
}
@@ -646,3 +646,36 @@ message PhoneSignalStrengthChanged {
    }
    optional SignalStrength signal_strength = 1;
}

/**
 * Logs that a setting was updated.
 * Logged from:
 *   frameworks/base/core/java/android/provider/Settings.java
 * The tag and is_default allow resetting of settings to default values based on the specified
 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
 */
message SettingChanged {
    // The name of the setting.
    optional string setting = 1;

    // The change being imposed on this setting. May represent a number, eg "3".
    optional string value = 2;

    // The new value of this setting. For most settings, this is same as value. For some settings,
    // value is +X or -X where X represents an element in a set. For example, if the previous value
    // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
    // The +/- feature is currently only used for location_providers_allowed.
    optional string new_value = 3;

    // The previous value of this setting.
    optional string prev_value = 4;

    // The tag used with the is_default for resetting sets of settings. This is generally null.
    optional string tag = 5;

    // 1 indicates that this setting with tag should be resettable.
    optional int32 is_default = 6;

    // The user ID associated. Defined in android/os/UserHandle.java
    optional int32 user = 7;
}
+5 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
import android.util.MemoryIntArray;
import android.util.StatsLog;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.ArrayUtils;
@@ -1886,7 +1887,11 @@ public final class Settings {
                    arg.putBoolean(CALL_METHOD_MAKE_DEFAULT_KEY, true);
                }
                IContentProvider cp = mProviderHolder.getProvider(cr);
                String prevValue = getStringForUser(cr, name, userHandle);
                cp.call(cr.getPackageName(), mCallSetCommand, name, arg);
                String newValue = getStringForUser(cr, name, userHandle);
                StatsLog.write(StatsLog.SETTING_CHANGED, name, value, newValue, prevValue, tag,
                        makeDefault ? 1 : 0, userHandle);
            } catch (RemoteException e) {
                Log.w(TAG, "Can't set key " + name + " in " + mUri, e);
                return false;
+3 −1
Original line number Diff line number Diff line
@@ -15,9 +15,11 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.testables">
    package="com.android.testables" android:sharedUserId="android.uid.system">

    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
    <uses-permission android:name="android.permission.MANAGE_USERS" />

    <application>
        <uses-library android:name="android.test.runner" />