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

Commit 8e28132b authored by Hani Kazmi's avatar Hani Kazmi Committed by Android (Google) Code Review
Browse files

Revert "Revert "[AAPM] Add advanced protection dialog according ..."

Revert submission 31078830-revert-30767017-aapm-dialog-api-feedback-TBLFTCNTUN

Reason for revert: Addressed failing test

Reverted changes: /q/submissionid:31078830-revert-30767017-aapm-dialog-api-feedback-TBLFTCNTUN

Change-Id: I3321b4f5baaca9dd270350b9201998ffe0d40473
parent 2574343b
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -4443,6 +4443,19 @@
            </intent-filter>
        </activity>

        <activity android:name=".security.ActionDisabledByAdvancedProtectionDialog"
            android:theme="@style/Theme.AlertDialog"
            android:taskAffinity="com.android.settings.security"
            android:excludeFromRecents="true"
            android:exported="false"
            android:launchMode="singleTop"
            android:featureFlag="android.security.aapm_api">
            <intent-filter android:priority="1">
                <action android:name="android.security.advancedprotection.action.SHOW_ADVANCED_PROTECTION_SUPPORT_DIALOG" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity
            android:name="Settings$ManageExternalStorageActivity"
            android:knownActivityEmbeddingCerts="@array/config_known_host_certs"
+5 −0
Original line number Diff line number Diff line
@@ -10631,6 +10631,11 @@
    <string name="admin_financed_message">Your device administrator may be able to access data
        associated with this device, manage apps, and change this device\’s settings.</string>
    <!-- Title for dialog displayed when user taps a setting on their phone that's blocked by Advanced Protection. [CHAR LIMIT=50] -->
    <string name="disabled_by_advanced_protection_title">Prevented by Advanced Protection</string>
    <!-- Short summary for dialog displayed when user taps a setting on their phone that's blocked by Advanced Protection. [CHAR LIMIT=NONE] -->
    <string name="disabled_by_advanced_protection_message">This action is not allowed because Advanced Protection is on for your device.</string>
    <!-- Turn off a conditional state of the device (e.g. airplane mode, or hotspot) [CHAR LIMIT=30] -->
    <string name="condition_turn_off">Turn off</string>
+3 −6
Original line number Diff line number Diff line
@@ -109,12 +109,9 @@ public class ActionDisabledByAdminDialog extends Activity
        }
        if (enforcingAdmin.getAuthority() instanceof UnknownAuthority authority
                && ADVANCED_PROTECTION_SYSTEM_ENTITY.equals(authority.getName())) {
            AdvancedProtectionManager apm = getSystemService(AdvancedProtectionManager.class);
            if (apm == null) {
                return;
            }
            Intent apmSupportIntent = apm.createSupportIntentForPolicyIdentifierOrRestriction(
                    restriction, /* type */ null);
            Intent apmSupportIntent = AdvancedProtectionManager
                    .createSupportIntentForPolicyIdentifierOrRestriction(restriction,
                            AdvancedProtectionManager.SUPPORT_DIALOG_TYPE_UNKNOWN);
            startActivityAsUser(apmSupportIntent, UserHandle.of(userId));
            finish();
        } else {
+59 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.
 */

package com.android.settings.security;

import android.app.Activity
import android.content.DialogInterface
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.android.settings.R

import androidx.appcompat.app.AlertDialog;

class ActionDisabledByAdvancedProtectionDialog : Activity(), DialogInterface.OnDismissListener {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val dialogView = layoutInflater.inflate(R.layout.support_details_dialog, null) as ViewGroup
        val builder = AlertDialog.Builder(this)
            .setPositiveButton(R.string.okay, null)
            .setView(dialogView)
            .setOnDismissListener(this)
        initializeDialogView(dialogView)
        builder.show()
    }

    override fun onDismiss(dialog: DialogInterface) {
        finish()
    }

    private fun initializeDialogView(dialogView: View) {
        setSupportTitle(dialogView)
        setSupportDetails(dialogView)
    }

    private fun setSupportTitle(root: View) {
        val titleView: TextView = root.findViewById(R.id.admin_support_dialog_title) ?: return
        titleView.setText(R.string.disabled_by_advanced_protection_title)
    }

    private fun setSupportDetails(root: View) {
        val textView: TextView = root.findViewById(R.id.admin_support_msg)
        textView.setText(R.string.disabled_by_advanced_protection_message)
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -162,10 +162,10 @@ class WepNetworksPreferenceController(context: Context, preferenceKey: String) :
        emit(aapmManager?.isAdvancedProtectionEnabled ?: false) }.flowOn(Dispatchers.Default)

    private fun startSupportIntent() {
        aapmManager?.createSupportIntent(
        AdvancedProtectionManager.createSupportIntent(
            AdvancedProtectionManager.FEATURE_ID_DISALLOW_WEP,
            AdvancedProtectionManager.SUPPORT_DIALOG_TYPE_DISABLED_SETTING
        )?.let { mContext.startActivity(it) }
        ).let { mContext.startActivity(it) }
    }

    val wepAllowedFlow =
Loading