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

Commit 3abcdc3c authored by android-build-team Robot's avatar android-build-team Robot
Browse files

release-request-c8b8af6b-4899-402a-9ff7-72255ba5300b-for-git_oc-mr1-release-42...

release-request-c8b8af6b-4899-402a-9ff7-72255ba5300b-for-git_oc-mr1-release-4253898 snap-temp-L09600000090287887

Change-Id: I2413f8b2fd5ad15a2ce0f0f6193c92f6e0f893f3
parents 0cea3ab9 b1c0e382
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -210,12 +210,7 @@ public final class BluetoothEnabler implements SwitchWidgetController.OnSwitchCh
     */
    @VisibleForTesting
    boolean maybeEnforceRestrictions() {
        EnforcedAdmin admin = mRestrictionUtils.checkIfRestrictionEnforced(
                mContext, UserManager.DISALLOW_BLUETOOTH);
        if (admin == null) {
            admin = mRestrictionUtils.checkIfRestrictionEnforced(
                    mContext, UserManager.DISALLOW_CONFIG_BLUETOOTH);
        }
        EnforcedAdmin admin = getEnforcedAdmin(mRestrictionUtils, mContext);
        mSwitchWidget.setDisabledByAdmin(admin);
        if (admin != null) {
            mSwitchWidget.setChecked(false);
@@ -227,4 +222,15 @@ public final class BluetoothEnabler implements SwitchWidgetController.OnSwitchCh
        return admin != null;
    }

    public static EnforcedAdmin getEnforcedAdmin(RestrictionUtils mRestrictionUtils,
            Context mContext) {
        EnforcedAdmin admin = mRestrictionUtils.checkIfRestrictionEnforced(
                mContext, UserManager.DISALLOW_BLUETOOTH);
        if (admin == null) {
            admin = mRestrictionUtils.checkIfRestrictionEnforced(
                    mContext, UserManager.DISALLOW_CONFIG_BLUETOOTH);
        }
        return admin;
    }

}
+3 −1
Original line number Diff line number Diff line
@@ -49,7 +49,9 @@ public class LocationCheckAction extends AnomalyAction {
    public void handlePositiveAction(Anomaly anomaly, int contextMetricsKey) {
        super.handlePositiveAction(anomaly, contextMetricsKey);
        mRuntimePermissionPresenter.revokeRuntimePermission(anomaly.packageName,
                Manifest.permission_group.LOCATION);
                Manifest.permission.ACCESS_COARSE_LOCATION);
        mRuntimePermissionPresenter.revokeRuntimePermission(anomaly.packageName,
                Manifest.permission.ACCESS_FINE_LOCATION);
    }

    @Override
+16 −9
Original line number Diff line number Diff line
@@ -85,13 +85,23 @@ public abstract class LocationSettingsBase extends SettingsPreferenceFragment {
    /** Called when location mode has changed. */
    public abstract void onModeChanged(int mode, boolean restricted);

    private boolean isRestricted() {
        final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
    public static boolean isRestricted(Context context) {
        final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
        return um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION);
    }

    public static boolean updateLocationMode(Context context, int oldMode, int newMode) {
        Intent intent = new Intent(MODE_CHANGING_ACTION);
        intent.putExtra(CURRENT_MODE_KEY, oldMode);
        intent.putExtra(NEW_MODE_KEY, newMode);
        context.sendBroadcast(intent, android.Manifest.permission.WRITE_SECURE_SETTINGS);
        return Settings.Secure.putInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE,
                newMode);
    }

    public void setLocationMode(int mode) {
        if (isRestricted()) {
        Context context = getActivity();
        if (isRestricted(context)) {
            // Location toggling disabled by user restriction. Read the current location mode to
            // update the location master switch.
            if (Log.isLoggable(TAG, Log.INFO)) {
@@ -104,11 +114,8 @@ public abstract class LocationSettingsBase extends SettingsPreferenceFragment {
            }
            return;
        }
        Intent intent = new Intent(MODE_CHANGING_ACTION);
        intent.putExtra(CURRENT_MODE_KEY, mCurrentMode);
        intent.putExtra(NEW_MODE_KEY, mode);
        getActivity().sendBroadcast(intent, android.Manifest.permission.WRITE_SECURE_SETTINGS);
        Settings.Secure.putInt(getContentResolver(), Settings.Secure.LOCATION_MODE, mode);

        updateLocationMode(context, mCurrentMode, mode);
        refreshLocationMode();
    }

@@ -120,7 +127,7 @@ public abstract class LocationSettingsBase extends SettingsPreferenceFragment {
            if (Log.isLoggable(TAG, Log.INFO)) {
                Log.i(TAG, "Location mode has been changed");
            }
            onModeChanged(mode, isRestricted());
            onModeChanged(mode, isRestricted(getActivity()));
        }
    }
}
+45 −0
Original line number Diff line number Diff line
@@ -35,8 +35,10 @@ import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
@@ -108,6 +110,8 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
    protected NotificationBackend.AppRow mAppRow;
    protected boolean mShowLegacyChannelConfig = false;

    protected boolean mListeningToPackageRemove;

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
@@ -159,6 +163,13 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
        }

        mUserId = UserHandle.getUserId(mUid);
        startListeningToPackageRemove();
    }

    @Override
    public void onDestroy() {
        stopListeningToPackageRemove();
        super.onDestroy();
    }

    @Override
@@ -456,4 +467,38 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
        return channel.isBlockableSystem()
                || channel.getImportance() == NotificationManager.IMPORTANCE_NONE;
    }

    protected void startListeningToPackageRemove() {
        if (mListeningToPackageRemove) {
            return;
        }
        mListeningToPackageRemove = true;
        final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_REMOVED);
        filter.addDataScheme("package");
        getContext().registerReceiver(mPackageRemovedReceiver, filter);
    }

    protected void stopListeningToPackageRemove() {
        if (!mListeningToPackageRemove) {
            return;
        }
        mListeningToPackageRemove = false;
        getContext().unregisterReceiver(mPackageRemovedReceiver);
    }

    protected void onPackageRemoved() {
        getActivity().finishAndRemoveTask();
    }

    protected final BroadcastReceiver mPackageRemovedReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String packageName = intent.getData().getSchemeSpecificPart();
            if (mPkgInfo == null || TextUtils.equals(mPkgInfo.packageName, packageName)) {
                if (DEBUG) Log.d(TAG, "Package (" + packageName + ") removed. Removing"
                        + "NotificationSettingsBase.");
                onPackageRemoved();
            }
        }
    };
}
+9 −2
Original line number Diff line number Diff line
@@ -70,7 +70,8 @@ public class ResultPayload implements Parcelable {
            Availability.DISABLED_DEPENDENT_APP,
            Availability.DISABLED_UNSUPPORTED,
            Availability.RESOURCE_CONTENTION,
            Availability.INTENT_ONLY,})
            Availability.INTENT_ONLY,
            Availability.DISABLED_FOR_USER,})
    @Retention(RetentionPolicy.SOURCE)
    public @interface Availability {
        /**
@@ -96,7 +97,7 @@ public class ResultPayload implements Parcelable {
        int RESOURCE_CONTENTION = 3;

        /**
         * The setting is disabled because corresponding app is disabled
         * The setting is disabled because corresponding app is disabled.
         */
        int DISABLED_DEPENDENT_APP = 4;

@@ -104,6 +105,12 @@ public class ResultPayload implements Parcelable {
         * This setting is supported on the device but cannot be changed inline.
         */
        int INTENT_ONLY = 5;

        /**
         * The setting cannot be changed by the current user.
         * ex: MobileNetworkTakeMeThereSetting should not be available to a secondary user.
         */
        int DISABLED_FOR_USER = 6;
    }

    @IntDef({SettingsSource.UNKNOWN, SettingsSource.SYSTEM, SettingsSource.SECURE,
Loading