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

Commit 5efb70ac authored by Andrew Sapperstein's avatar Andrew Sapperstein Committed by Doris Ling
Browse files

Separate OTA data usage from SYSTEM_UID.

Prior to this CL, Process.OTA_UPDATE_UID was included with SYSTEM_UID
for the purposes of per-app data usage in the DataUsageList. With this
change, it is now separated into its own category.

This change also deletes the duplicate ic_system_update* icons and
moves the one implementation into SettingsLib.

Fixes: 70640191
Test: manually verified locally that there is an item in the list
with the proper title. Required setting up a custom OTA for my
test device.

Change-Id: Iecc45648f68a12c9f8e2370577ab017863e7fcb2
parent 7d257171
Loading
Loading
Loading
Loading

res/drawable/ic_system_update.xml

deleted100644 → 0
+0 −25
Original line number Diff line number Diff line
<!--
    Copyright (C) 2017 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0"
        android:tint="?android:attr/colorControlNormal">
    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="M17,1.01L7,1C5.9,1 5,1.9 5,3v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3C19,1.9 18.1,1.01 17,1.01zM17,21H7l0,-1h10V21zM17,18H7V6h10V18zM7,4V3h10v1H7zM16,12.5l-4,4l-4,-4l1.41,-1.41L11,12.67V8.5V8h2v0.5v4.17l1.59,-1.59L16,12.5z"/>
</vector>
+0 −25
Original line number Diff line number Diff line
<!--
    Copyright (C) 2017 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0"
        android:tint="?android:attr/colorControlNormal">
    <path
        android:fillColor="@android:color/white"
        android:pathData="M17,1.01L7,1C5.9,1 5,1.9 5,3v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3C19,1.9 18.1,1.01 17,1.01zM17,21H7l0,-1h10V21zM17,18H7V6h10V18zM7,4V3h10v1H7zM16,12.5l-4,4l-4,-4l1.41,-1.41L11,12.67V8.5V8h2v0.5v4.17l1.59,-1.59L16,12.5z"/>
</vector>
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@
    <com.android.settings.deviceinfo.StorageItemPreference
        android:key="pref_system"
        android:title="@string/storage_detail_system"
        android:icon="@drawable/ic_system_update_vd_theme_24"
        android:icon="@drawable/ic_system_update"
        android:order="100" />
    <PreferenceCategory
        android:key="pref_secondary_users"
+31 −21
Original line number Diff line number Diff line
@@ -84,8 +84,10 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
    private PreferenceCategory mAppList;

    private Drawable mIcon;
    private CharSequence mLabel;
    private String mPackageName;
    @VisibleForTesting
    CharSequence mLabel;
    @VisibleForTesting
    String mPackageName;
    private CycleAdapter mCycleAdapter;

    private List<NetworkCycleDataForUid> mUsageData;
@@ -133,13 +135,22 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
        mForegroundUsage = findPreference(KEY_FOREGROUND_USAGE);
        mBackgroundUsage = findPreference(KEY_BACKGROUND_USAGE);

        mCycle = (SpinnerPreference) findPreference(KEY_CYCLE);
        mCycle = findPreference(KEY_CYCLE);
        mCycleAdapter = new CycleAdapter(mContext, mCycle, mCycleListener);

        final UidDetailProvider uidDetailProvider = getUidDetailProvider();

        if (mAppItem.key > 0) {
            if (!UserHandle.isApp(mAppItem.key)) {
                final UidDetail uidDetail = uidDetailProvider.getUidDetail(mAppItem.key, true);
                mIcon = uidDetail.icon;
                mLabel = uidDetail.label;
                removePreference(KEY_UNRESTRICTED_DATA);
                removePreference(KEY_RESTRICT_BACKGROUND);
            } else {
                if (mPackages.size() != 0) {
                    try {
                    ApplicationInfo info = mPackageManager.getApplicationInfoAsUser(
                        final ApplicationInfo info = mPackageManager.getApplicationInfoAsUser(
                            mPackages.valueAt(0), 0, UserHandle.getUserId(mAppItem.key));
                        mIcon = IconDrawableFactory.newInstance(getActivity()).getBadgedIcon(info);
                        mLabel = info.loadLabel(mPackageManager);
@@ -147,15 +158,9 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
                    } catch (PackageManager.NameNotFoundException e) {
                    }
                }
            if (!UserHandle.isApp(mAppItem.key)) {
                removePreference(KEY_UNRESTRICTED_DATA);
                removePreference(KEY_RESTRICT_BACKGROUND);
            } else {
                mRestrictBackground = (RestrictedSwitchPreference) findPreference(
                        KEY_RESTRICT_BACKGROUND);
                mRestrictBackground = findPreference(KEY_RESTRICT_BACKGROUND);
                mRestrictBackground.setOnPreferenceChangeListener(this);
                mUnrestrictedData = (RestrictedSwitchPreference) findPreference(
                        KEY_UNRESTRICTED_DATA);
                mUnrestrictedData = findPreference(KEY_UNRESTRICTED_DATA);
                mUnrestrictedData.setOnPreferenceChangeListener(this);
            }
            mDataSaverBackend = new DataSaverBackend(mContext);
@@ -164,7 +169,7 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
            mAppSettingsIntent = new Intent(Intent.ACTION_MANAGE_NETWORK_USAGE);
            mAppSettingsIntent.addCategory(Intent.CATEGORY_DEFAULT);

            PackageManager pm = getPackageManager();
            final PackageManager pm = getPackageManager();
            boolean matchFound = false;
            for (String packageName : mPackages) {
                mAppSettingsIntent.setPackage(packageName);
@@ -179,7 +184,7 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
            }

            if (mPackages.size() > 1) {
                mAppList = (PreferenceCategory) findPreference(KEY_APP_LIST);
                mAppList = findPreference(KEY_APP_LIST);
                LoaderManager.getInstance(this).restartLoader(LOADER_APP_PREF, Bundle.EMPTY,
                        mAppPrefCallbacks);
            } else {
@@ -187,7 +192,7 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
            }
        } else {
            final Context context = getActivity();
            UidDetail uidDetail = new UidDetailProvider(context).getUidDetail(mAppItem.key, true);
            final UidDetail uidDetail = uidDetailProvider.getUidDetail(mAppItem.key, true);
            mIcon = uidDetail.icon;
            mLabel = uidDetail.label;
            mPackageName = context.getPackageName();
@@ -257,6 +262,11 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
        updatePrefs(getAppRestrictBackground(), getUnrestrictData());
    }

    @VisibleForTesting
    UidDetailProvider getUidDetailProvider() {
        return new UidDetailProvider(mContext);
    }

    private void updatePrefs(boolean restrictBackground, boolean unrestrictData) {
        final EnforcedAdmin admin = RestrictedLockUtilsInternal.checkIfMeteredDataRestricted(
                mContext, mPackageName, UserHandle.getUserId(mAppItem.key));
@@ -276,7 +286,7 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
    }

    private void addUid(int uid) {
        String[] packages = getPackageManager().getPackagesForUid(uid);
        String[] packages = mPackageManager.getPackagesForUid(uid);
        if (packages != null) {
            for (int i = 0; i < packages.length; i++) {
                mPackages.add(packages[i]);
+3 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.net.ConnectivityManager;
import android.net.NetworkPolicy;
import android.net.NetworkTemplate;
import android.os.Bundle;
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -362,7 +363,8 @@ public class DataUsageList extends DataUsageBaseFragment {
                        category = AppItem.CATEGORY_USER;
                    }
                }
            } else if (uid == UID_REMOVED || uid == UID_TETHERING) {
            } else if (uid == UID_REMOVED || uid == UID_TETHERING
                    || uid == Process.OTA_UPDATE_UID) {
                collapseKey = uid;
                category = AppItem.CATEGORY_APP;
            } else {
Loading