diff options
author | Adnan Begovic <adnan@cyngn.com> | 2015-10-26 15:48:47 -0700 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-10-26 16:12:36 -0700 |
commit | fb6fd3df017838c62f19a6ebd23d61c94f2782ba (patch) | |
tree | c85fc2ac9a966695067691db6a82ab5372a54457 /src/com/android/settings/profiles | |
parent | f258f533ec1633dd78194705ae71fde57301d007 (diff) | |
download | packages_apps_Settings-fb6fd3df017838c62f19a6ebd23d61c94f2782ba.zip packages_apps_Settings-fb6fd3df017838c62f19a6ebd23d61c94f2782ba.tar.gz packages_apps_Settings-fb6fd3df017838c62f19a6ebd23d61c94f2782ba.tar.bz2 |
Profiles: Point at cmsdk, fix metrics logging.
Change-Id: Ic1f3a349c8aa54836128cc91e57e9d31eaca81d3
Diffstat (limited to 'src/com/android/settings/profiles')
14 files changed, 108 insertions, 68 deletions
diff --git a/src/com/android/settings/profiles/AppGroupConfig.java b/src/com/android/settings/profiles/AppGroupConfig.java index fb5af22..a34f180 100644 --- a/src/com/android/settings/profiles/AppGroupConfig.java +++ b/src/com/android/settings/profiles/AppGroupConfig.java @@ -193,6 +193,11 @@ public class AppGroupConfig extends SettingsPreferenceFragment } @Override + protected int getMetricsCategory() { + return 0; + } + + @Override public void onPause() { if (mNotificationGroup != null) { mProfileManager.addNotificationGroup(mNotificationGroup); diff --git a/src/com/android/settings/profiles/AppGroupList.java b/src/com/android/settings/profiles/AppGroupList.java index 2dfb654..968d88c 100644 --- a/src/com/android/settings/profiles/AppGroupList.java +++ b/src/com/android/settings/profiles/AppGroupList.java @@ -21,6 +21,7 @@ import java.util.UUID; import android.annotation.Nullable; import android.app.AlertDialog; import android.app.NotificationGroup; +import com.android.internal.logging.MetricsLogger; import cyanogenmod.app.ProfileManager; import android.content.Context; import android.content.DialogInterface; @@ -34,7 +35,7 @@ import android.view.ViewGroup; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; -import com.android.internal.util.cm.ScreenType; +//import com.android.internal.util.cm.ScreenType; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; @@ -58,14 +59,19 @@ public class AppGroupList extends SettingsPreferenceFragment { } @Override + protected int getMetricsCategory() { + return MetricsLogger.DONT_TRACK_ME_BRO; + } + + @Override public void onResume() { super.onResume(); refreshList(); // On tablet devices remove the padding - if (ScreenType.isTablet(getActivity())) { - getListView().setPadding(0, 0, 0, 0); - } + //if (ScreenType.isTablet(getActivity())) { + // getListView().setPadding(0, 0, 0, 0); + //} } @Override diff --git a/src/com/android/settings/profiles/NFCProfile.java b/src/com/android/settings/profiles/NFCProfile.java index b4bfe8c..74aec53 100644 --- a/src/com/android/settings/profiles/NFCProfile.java +++ b/src/com/android/settings/profiles/NFCProfile.java @@ -27,11 +27,11 @@ import android.nfc.NdefRecord; import android.nfc.NfcAdapter; import android.os.Bundle; import android.os.Parcelable; -import android.provider.Settings; import android.widget.Toast; import cyanogenmod.app.Profile; import cyanogenmod.app.ProfileManager; +import cyanogenmod.providers.CMSettings; import com.android.settings.R; @@ -86,8 +86,8 @@ public class NFCProfile extends Activity { private void handleProfileMimeType(byte[] payload) { UUID profileUuid = NFCProfileUtils.toUUID(payload); - boolean enabled = Settings.System.getInt(getContentResolver(), - Settings.System.SYSTEM_PROFILES_ENABLED, 1) == 1; + boolean enabled = CMSettings.System.getInt(getContentResolver(), + CMSettings.System.SYSTEM_PROFILES_ENABLED, 1) == 1; if (enabled) { // Only do NFC profile changing if System Profile support is enabled diff --git a/src/com/android/settings/profiles/ProfileEnabler.java b/src/com/android/settings/profiles/ProfileEnabler.java index 487adc9..8bf450c 100644 --- a/src/com/android/settings/profiles/ProfileEnabler.java +++ b/src/com/android/settings/profiles/ProfileEnabler.java @@ -16,7 +16,7 @@ package com.android.settings.profiles; -import android.app.ProfileManager; +import cyanogenmod.app.ProfileManager; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; @@ -30,7 +30,6 @@ import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Handler; import android.os.Message; -import android.provider.Settings; import android.widget.Switch; import android.widget.Toast; import com.android.settings.R; @@ -39,6 +38,8 @@ import com.android.settings.search.Index; import com.android.settings.widget.SwitchBar; import com.android.settings.wifi.WifiSettings; +import cyanogenmod.providers.CMSettings; + import java.util.concurrent.atomic.AtomicBoolean; public class ProfileEnabler implements SwitchBar.OnSwitchChangeListener { @@ -99,8 +100,8 @@ public class ProfileEnabler implements SwitchBar.OnSwitchChangeListener { } private void setSwitchState() { - boolean enabled = Settings.System.getInt(mContext.getContentResolver(), - Settings.System.SYSTEM_PROFILES_ENABLED, 1) == 1; + boolean enabled = CMSettings.System.getInt(mContext.getContentResolver(), + CMSettings.System.SYSTEM_PROFILES_ENABLED, 1) == 1; mStateMachineEvent = true; setSwitchBarChecked(enabled); mStateMachineEvent = false; @@ -114,8 +115,8 @@ public class ProfileEnabler implements SwitchBar.OnSwitchChangeListener { } // Handle a switch change - Settings.System.putInt(mContext.getContentResolver(), - Settings.System.SYSTEM_PROFILES_ENABLED, isChecked ? 1 : 0); + CMSettings.System.putInt(mContext.getContentResolver(), + CMSettings.System.SYSTEM_PROFILES_ENABLED, isChecked ? 1 : 0); // Send a broadcast intent to the world // TODO Enabling or disabling profiles should be at ProfileManager, not here @@ -135,8 +136,8 @@ public class ProfileEnabler implements SwitchBar.OnSwitchChangeListener { void observe() { ContentResolver resolver = mContext.getContentResolver(); - resolver.registerContentObserver(Settings.System.getUriFor( - Settings.System.SYSTEM_PROFILES_ENABLED), false, this); + resolver.registerContentObserver(CMSettings.System.getUriFor( + CMSettings.System.SYSTEM_PROFILES_ENABLED), false, this); update(); } @@ -150,11 +151,6 @@ public class ProfileEnabler implements SwitchBar.OnSwitchChangeListener { update(); } - @Override - public void onChange(boolean selfChange, Uri uri) { - update(); - } - public void update() { setSwitchState(); } diff --git a/src/com/android/settings/profiles/ProfileGroupConfig.java b/src/com/android/settings/profiles/ProfileGroupConfig.java index 8edd3d6..9219967 100644 --- a/src/com/android/settings/profiles/ProfileGroupConfig.java +++ b/src/com/android/settings/profiles/ProfileGroupConfig.java @@ -53,6 +53,11 @@ public class ProfileGroupConfig extends SettingsPreferenceFragment implements ProfileGroup mProfileGroup; + @Override + protected int getMetricsCategory() { + return 0; + } + private ListPreference mSoundMode; private ListPreference mRingerMode; diff --git a/src/com/android/settings/profiles/ProfilesList.java b/src/com/android/settings/profiles/ProfilesList.java index 9b07b7d..7cc2048 100644 --- a/src/com/android/settings/profiles/ProfilesList.java +++ b/src/com/android/settings/profiles/ProfilesList.java @@ -18,8 +18,9 @@ package com.android.settings.profiles; import java.util.UUID; -import android.app.Profile; -import android.app.ProfileManager; +import com.android.internal.logging.MetricsLogger; +import cyanogenmod.app.Profile; +import cyanogenmod.app.ProfileManager; import android.content.Context; import android.os.Bundle; import android.preference.Preference; @@ -44,7 +45,12 @@ public class ProfilesList extends SettingsPreferenceFragment implements super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.profiles_settings); - mProfileManager = (ProfileManager) getActivity().getSystemService(Context.PROFILE_SERVICE); + mProfileManager = ProfileManager.getInstance(getActivity()); + } + + @Override + protected int getMetricsCategory() { + return MetricsLogger.DONT_TRACK_ME_BRO; } @Override diff --git a/src/com/android/settings/profiles/ProfilesSettings.java b/src/com/android/settings/profiles/ProfilesSettings.java index 846dd1f..811c207 100644 --- a/src/com/android/settings/profiles/ProfilesSettings.java +++ b/src/com/android/settings/profiles/ProfilesSettings.java @@ -19,6 +19,8 @@ package com.android.settings.profiles; import android.app.ActionBar; import android.app.Activity; import android.app.AlertDialog; +import android.app.Fragment; +import android.app.FragmentManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; @@ -41,6 +43,7 @@ import android.widget.ImageView; import android.widget.Switch; import android.widget.TextView; +import com.android.internal.logging.MetricsLogger; import cyanogenmod.app.Profile; import cyanogenmod.app.ProfileManager; @@ -49,6 +52,7 @@ import com.android.settings.SettingsActivity; import com.android.settings.SettingsPreferenceFragment; import com.android.settings.SubSettings; import com.android.settings.Utils; +import cyanogenmod.providers.CMSettings; import java.util.UUID; @@ -125,6 +129,11 @@ public class ProfilesSettings extends SettingsPreferenceFragment { } @Override + protected int getMetricsCategory() { + return MetricsLogger.DONT_TRACK_ME_BRO; + } + + @Override public void onResume() { super.onResume(); if (mProfileEnabler != null) { @@ -205,7 +214,7 @@ public class ProfilesSettings extends SettingsPreferenceFragment { .setTitle(R.string.profile_reset_title) .setIconAttribute(android.R.attr.alertDialogIcon) .setMessage(R.string.profile_reset_message) - .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { + .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { mProfileManager.resetAll(); @@ -219,8 +228,8 @@ public class ProfilesSettings extends SettingsPreferenceFragment { private void updateProfilesEnabledState() { Activity activity = getActivity(); - mEnabled = Settings.System.getInt(activity.getContentResolver(), - Settings.System.SYSTEM_PROFILES_ENABLED, 1) == 1; + mEnabled = CMSettings.System.getInt(activity.getContentResolver(), + CMSettings.System.SYSTEM_PROFILES_ENABLED, 1) == 1; activity.invalidateOptionsMenu(); mAddProfileFab.setVisibility(mEnabled ? View.VISIBLE : View.GONE); diff --git a/src/com/android/settings/profiles/ProfilesUtils.java b/src/com/android/settings/profiles/ProfilesUtils.java index 4f59dd9..03e9d33 100644 --- a/src/com/android/settings/profiles/ProfilesUtils.java +++ b/src/com/android/settings/profiles/ProfilesUtils.java @@ -18,6 +18,8 @@ import android.provider.Settings; import android.telephony.TelephonyManager; import android.text.TextUtils; +import cyanogenmod.providers.CMSettings; + import com.android.internal.telephony.PhoneConstants; public class ProfilesUtils { @@ -41,7 +43,7 @@ public class ProfilesUtils { } public static boolean systemProfilesEnabled(ContentResolver resolver) { - return (Settings.System.getInt(resolver, Settings.System.SYSTEM_PROFILES_ENABLED, 1) == 1); + return (CMSettings.System.getInt(resolver, CMSettings.System.SYSTEM_PROFILES_ENABLED, 1) == 1); } public static boolean deviceSupportsNfc(Context ctx) { diff --git a/src/com/android/settings/profiles/SetupActionsFragment.java b/src/com/android/settings/profiles/SetupActionsFragment.java index 7285c94..bc7cad1 100644 --- a/src/com/android/settings/profiles/SetupActionsFragment.java +++ b/src/com/android/settings/profiles/SetupActionsFragment.java @@ -16,12 +16,14 @@ package com.android.settings.profiles; import android.app.Activity; +import com.android.internal.logging.MetricsLogger; import cyanogenmod.profiles.AirplaneModeSettings; import android.app.AlertDialog; import cyanogenmod.profiles.BrightnessSettings; import cyanogenmod.profiles.ConnectionSettings; import android.app.Dialog; import android.app.NotificationGroup; +import cyanogenmod.profiles.LockSettings; import cyanogenmod.profiles.RingModeSettings; import cyanogenmod.profiles.StreamSettings; import android.bluetooth.BluetoothAdapter; @@ -34,7 +36,7 @@ import android.media.AudioManager; import android.media.RingtoneManager; import android.net.ConnectivityManager; import android.net.wifi.WifiManager; -import android.net.wimax.WimaxHelper; +//import android.net.wimax.WimaxHelper; import android.nfc.NfcManager; import android.os.AsyncTask; import android.os.Bundle; @@ -218,9 +220,9 @@ public class SetupActionsFragment extends SettingsPreferenceFragment mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_2G3G4G)); } } - if (WimaxHelper.isWimaxSupported(getActivity())) { - mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_WIMAX)); - } + //if (WimaxHelper.isWimaxSupported(getActivity())) { + // mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_WIMAX)); + //} if (DeviceUtils.deviceSupportsNfc(getActivity())) { mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_NFC)); } @@ -245,39 +247,37 @@ public class SetupActionsFragment extends SettingsPreferenceFragment } // app groups - if (SettingsActivity.showAdvancedPreferences(getActivity())) { - mItems.add(new Header(getString(R.string.profile_app_group_category_title))); - - int groupsAdded = 0; - ProfileGroup[] profileGroups = mProfile.getProfileGroups(); - if (profileGroups != null && profileGroups.length > 1) { // it will always have "other" - for (ProfileGroup profileGroup : profileGroups) { - // only display profile group if there's a matching notification group - // and don't' show the wildcard group - if (mProfileManager.getNotificationGroup(profileGroup.getUuid()) != null - && !mProfile.getDefaultGroup().getUuid().equals( - profileGroup.getUuid())) { - mItems.add(new AppGroupItem(mProfile, profileGroup, - mProfileManager.getNotificationGroup( - profileGroup.getUuid()))); - groupsAdded++; - } - } - if (groupsAdded > 0) { - // add "Other" at the end - mItems.add(new AppGroupItem(mProfile, mProfile.getDefaultGroup(), + mItems.add(new Header(getString(R.string.profile_app_group_category_title))); + + int groupsAdded = 0; + ProfileGroup[] profileGroups = mProfile.getProfileGroups(); + if (profileGroups != null && profileGroups.length > 1) { // it will always have "other" + for (ProfileGroup profileGroup : profileGroups) { + // only display profile group if there's a matching notification group + // and don't' show the wildcard group + if (mProfileManager.getNotificationGroup(profileGroup.getUuid()) != null + && !mProfile.getDefaultGroup().getUuid().equals( + profileGroup.getUuid())) { + mItems.add(new AppGroupItem(mProfile, profileGroup, mProfileManager.getNotificationGroup( - mProfile.getDefaultGroup().getUuid()))); + profileGroup.getUuid()))); + groupsAdded++; } } if (groupsAdded > 0) { - // add dummy "add/remove app groups" entry - mItems.add(new AppGroupItem()); - } else { - // remove the header since there are no options - mItems.remove(mItems.get(mItems.size() - 1)); + // add "Other" at the end + mItems.add(new AppGroupItem(mProfile, mProfile.getDefaultGroup(), + mProfileManager.getNotificationGroup( + mProfile.getDefaultGroup().getUuid()))); } } + if (groupsAdded > 0) { + // add dummy "add/remove app groups" entry + mItems.add(new AppGroupItem()); + } else { + // remove the header since there are no options + mItems.remove(mItems.get(mItems.size() - 1)); + } mAdapter.notifyDataSetChanged(); } @@ -580,7 +580,7 @@ public class SetupActionsFragment extends SettingsPreferenceFragment int defaultIndex = 0; // no action for (int i = 0; i < LOCKMODE_MAPPING.length; i++) { - if (LOCKMODE_MAPPING[i] == mProfile.getScreenLockMode()) { + if (LOCKMODE_MAPPING[i] == mProfile.getScreenLockMode().getValue()) { defaultIndex = i; break; } @@ -591,7 +591,7 @@ public class SetupActionsFragment extends SettingsPreferenceFragment new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { - mProfile.setScreenLockMode(LOCKMODE_MAPPING[item]); + mProfile.setScreenLockMode(new LockSettings(LOCKMODE_MAPPING[item])); updateProfile(); mAdapter.notifyDataSetChanged(); dialog.dismiss(); @@ -998,7 +998,7 @@ public class SetupActionsFragment extends SettingsPreferenceFragment AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()) .setMultiChoiceItems(items, checked, listener) .setTitle(R.string.profile_appgroups_title) - .setPositiveButton(R.string.ok, null); + .setPositiveButton(android.R.string.ok, null); builder.show(); } @@ -1086,4 +1086,9 @@ public class SetupActionsFragment extends SettingsPreferenceFragment pa.startPreferencePanel(SetupTriggersFragment.class.getCanonicalName(), args, R.string.profile_profile_manage, null, this, NEW_TRIGGER_REQUEST_CODE); } + + @Override + protected int getMetricsCategory() { + return MetricsLogger.DONT_TRACK_ME_BRO; + } } diff --git a/src/com/android/settings/profiles/SetupDefaultProfileReceiver.java b/src/com/android/settings/profiles/SetupDefaultProfileReceiver.java index ea43d18..4d82499 100644 --- a/src/com/android/settings/profiles/SetupDefaultProfileReceiver.java +++ b/src/com/android/settings/profiles/SetupDefaultProfileReceiver.java @@ -3,10 +3,10 @@ package com.android.settings.profiles; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.provider.Settings; import cyanogenmod.app.Profile; import cyanogenmod.app.ProfileManager; +import cyanogenmod.providers.CMSettings; import java.util.UUID; @@ -14,8 +14,8 @@ public class SetupDefaultProfileReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - if (Settings.System.getInt(context.getContentResolver(), - Settings.System.SYSTEM_PROFILES_ENABLED, 1) == 1) { + if (CMSettings.System.getInt(context.getContentResolver(), + CMSettings.System.SYSTEM_PROFILES_ENABLED, 1) == 1) { ProfileManager profileManager = ProfileManager.getInstance(context); Profile defaultProfile = profileManager.getProfile( UUID.fromString("0230226d-0d05-494a-a9bd-d222a1117655")); diff --git a/src/com/android/settings/profiles/SetupTriggersFragment.java b/src/com/android/settings/profiles/SetupTriggersFragment.java index 1fa6428..9584a5f 100644 --- a/src/com/android/settings/profiles/SetupTriggersFragment.java +++ b/src/com/android/settings/profiles/SetupTriggersFragment.java @@ -29,6 +29,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import com.android.internal.logging.MetricsLogger; import cyanogenmod.app.Profile; import cyanogenmod.app.ProfileManager; @@ -76,6 +77,11 @@ public class SetupTriggersFragment extends SettingsPreferenceFragment { } @Override + protected int getMetricsCategory() { + return MetricsLogger.DONT_TRACK_ME_BRO; + } + + @Override public void onResume() { super.onResume(); } diff --git a/src/com/android/settings/profiles/actions/item/LockModeItem.java b/src/com/android/settings/profiles/actions/item/LockModeItem.java index 5c27de2..e89bcc8 100644 --- a/src/com/android/settings/profiles/actions/item/LockModeItem.java +++ b/src/com/android/settings/profiles/actions/item/LockModeItem.java @@ -62,7 +62,7 @@ public class LockModeItem implements Item { } public static int getSummaryString(Profile profile) { - switch (profile.getScreenLockMode()) { + switch (profile.getScreenLockMode().getValue()) { case Profile.LockMode.DEFAULT: return R.string.profile_lockmode_default_summary; case Profile.LockMode.DISABLE: diff --git a/src/com/android/settings/profiles/triggers/BluetoothTriggerFragment.java b/src/com/android/settings/profiles/triggers/BluetoothTriggerFragment.java index b3478e8..e2967de 100644 --- a/src/com/android/settings/profiles/triggers/BluetoothTriggerFragment.java +++ b/src/com/android/settings/profiles/triggers/BluetoothTriggerFragment.java @@ -179,7 +179,7 @@ public class BluetoothTriggerFragment extends ListFragment { for (BluetoothDevice device : pairedDevices) { BluetoothTrigger bt = new BluetoothTrigger(device); - int state = mProfile.getTrigger(Profile.TriggerType.BLUETOOTH, bt.getAddress()); + int state = mProfile.getTriggerState(Profile.TriggerType.BLUETOOTH, bt.getAddress()); initPreference(bt, state, res, R.drawable.ic_settings_bluetooth); mTriggers.add(bt); } diff --git a/src/com/android/settings/profiles/triggers/WifiTriggerFragment.java b/src/com/android/settings/profiles/triggers/WifiTriggerFragment.java index dc91cec..c34808d 100644 --- a/src/com/android/settings/profiles/triggers/WifiTriggerFragment.java +++ b/src/com/android/settings/profiles/triggers/WifiTriggerFragment.java @@ -174,7 +174,7 @@ public class WifiTriggerFragment extends ListFragment { WifiTrigger accessPoint = new WifiTrigger(config); int state = mProfile.getTriggerState( Profile.TriggerType.WIFI, accessPoint.getSSID()); - initPreference(accessPoint, state, res, R.drawable.ic_wifi_signal_4_teal); + initPreference(accessPoint, state, res, R.drawable.ic_wifi_signal_4); mTriggers.add(accessPoint); } } else { @@ -183,7 +183,7 @@ public class WifiTriggerFragment extends ListFragment { for (Profile.ProfileTrigger trigger : triggers) { WifiTrigger accessPoint = new WifiTrigger(trigger.getName()); initPreference(accessPoint, trigger.getState(), res, - R.drawable.ic_wifi_signal_4_teal); + R.drawable.ic_wifi_signal_4); mTriggers.add(accessPoint); } } |