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

Commit 680df213 authored by Haijie Hong's avatar Haijie Hong Committed by Android (Google) Code Review
Browse files

Merge "Show a dialog if bluetooth key is missing when reconnecting" into main

parents 3ed2123b f93aaada
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -3227,6 +3227,19 @@
            </intent-filter>
        </activity>

        <activity android:name=".bluetooth.BluetoothKeyMissingDialog"
                  android:permission="android.permission.BLUETOOTH_PRIVILEGED"
                  android:excludeFromRecents="true"
                  android:windowSoftInputMode="stateVisible|adjustResize"
                  android:theme="@style/Theme.AlertDialog"
                  android:exported="false"
                  android:taskAffinity=".bluetooth.BluetoothKeyMissingDialog">
            <intent-filter android:priority="1">
                <action android:name="android.bluetooth.device.action.KEY_MISSING" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity android:name=".bluetooth.RequestPermissionActivity"
                  android:excludeFromRecents="true"
                  android:permission="android.permission.BLUETOOTH_CONNECT"
@@ -3281,6 +3294,13 @@
            </intent-filter>
        </receiver>

        <receiver android:name=".bluetooth.BluetoothKeyMissingReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.device.action.KEY_MISSING" />
            </intent-filter>
        </receiver>

        <receiver android:name=".bluetooth.BluetoothPermissionRequest"
                  android:exported="true"
                  android:permission="android.permission.BLUETOOTH_CONNECT">
+10 −0
Original line number Diff line number Diff line
@@ -34,3 +34,13 @@ flag {
      purpose: PURPOSE_BUGFIX
  }
}

flag {
  name: "enable_bluetooth_key_missing_dialog"
  namespace: "cross_device_experiences"
  description: "Show a dialog if the bluetooth key is missing when reconnecting"
  bug: "360031750"
  metadata {
      purpose: PURPOSE_BUGFIX
  }
}
+58 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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.
-->

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="@dimen/bluetooth_dialog_padding_top">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingStart="24dp"
        android:paddingEnd="24dp">

        <ImageView
            android:id="@id/preview_placeholder"
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:layout_gravity="center"
            android:importantForAccessibility="no"
            android:src="@drawable/ic_warning_24dp"
            android:tint="@color/settingslib_materialColorOutline" />

        <TextView
            android:id="@+id/bluetooth_key_missing_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Title" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:text="@string/bluetooth_key_missing_message"
            android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1" />

    </LinearLayout>


</ScrollView>
 No newline at end of file
+9 −0
Original line number Diff line number Diff line
@@ -1860,6 +1860,15 @@
    <!-- Bluetooth settings. Link text to bring the user to "scanning settings" screen. [CHAR LIMIT=NONE]-->
    <string name="bluetooth_scan_change">Change</string>
    <!-- Dialog title when key is missing in a Bluetooth device -->
    <string name="bluetooth_key_missing_title"><xliff:g id="device_name">%1$s</xliff:g> not connected</string>
    <!-- Dialog content when key is missing in a Bluetooth device -->
    <string name="bluetooth_key_missing_message">For your security, forget this device, then pair it again</string>
    <!-- Button text to forget device when bluetooth key is missing -->
    <string name="bluetooth_key_missing_forget">Forget device</string>
    <!-- Button text to cancel when bluetooth key is missing-->
    <string name="bluetooth_key_missing_cancel">Cancel</string>
    <!-- Title of device details screen [CHAR LIMIT=28]-->
    <string name="device_details_title">Device details</string>
    <!-- Title for keyboard settings preferences. [CHAR LIMIT=50] -->
+47 −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.bluetooth;

import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;

import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;

/** A dialog to ask the user to forget a bluetooth device when the key is missing. */
public class BluetoothKeyMissingDialog extends FragmentActivity {
    public static final String FRAGMENT_TAG = "BtKeyMissingFrg";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
        Intent intent = getIntent();
        BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
        if (device == null) {
            finish();
            return;
        }
        BluetoothKeyMissingDialogFragment fragment = new BluetoothKeyMissingDialogFragment(device);
        fragment.show(getSupportFragmentManager(), FRAGMENT_TAG);
        closeSystemDialogs();
    }
}
Loading