将QRcode扫描仪从非相机SKU的快速设置中删除

Issue:
"

Reproduction Steps:

  1. Take a Non-Camera sku and flash the latest image build
  2. Slide down the quick settings panel
  3. Check the "QR code scanner" option should not listed.

"



frameworks/base/packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java
frameworks/base/

packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java

 

diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java
index a96a8c8..ecbc78e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2020 The Android Open Source Project
- * Copyright (C) 2022 XXX Technologies Corporation and/or its affiliates. All rights reserved.
+ * Copyright (C) 2022-2023 XXX Technologies Corporation and/or its affiliates. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -350,6 +350,11 @@
                 possibleTiles.add(spec);
             }
         }
+
+        // remove QRCode scanner from Quick settings
+        if ((XXXUtils.getFrontCamera().orElse(-1) == 0) && (XXXUtils.getRearCamera().orElse(-1) == 0)) {
+            possibleTiles.remove("qr_code_scanner");
+        }
         return possibleTiles;
     }
     //OSX Changes End Here
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
index 986de3a..fef329f 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2021-2022 XXX Technologies Corporation and/or its affiliates. All rights reserved.
  * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (c) 2021-2023 XXX Technologies Corporation and/or its affiliates. All rights reserved.
  *
  * 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
@@ -682,8 +682,19 @@
         final ArrayList tiles = new ArrayList();
 
         final Resources res = context.getResources();
-        final String defaultTileList = res.getString(R.string.quick_settings_tiles_default);
-
+        String defaultTileList = res.getString(R.string.quick_settings_tiles_default);
+        // remove QRCode scanner from Quick settings
+        final ArrayList removeTiles = new ArrayList<>();
+        removeTiles.add("qr_code_scanner");
+        if ((XXXUtils.getFrontCamera().orElse(-1) == 0) && (XXXUtils.getRearCamera().orElse(-1) == 0)) {
+            for (String tile : removeTiles) {
+                if (defaultTileList.contains(tile + ",")) {
+                    defaultTileList = defaultTileList.replace(tile + ",", "");
+                } else if (defaultTileList.contains(tile)) {
+                    defaultTileList = defaultTileList.replace(tile, "");
+                }
+            }
+        }
         tiles.addAll(Arrays.asList(defaultTileList.split(",")));
         if (Build.IS_DEBUGGABLE
                 && GarbageMonitor.ADD_MEMORY_TILE_TO_DEFAULT_ON_DEBUGGABLE_BUILDS) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java b/packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java
index fd72f92..4775e62 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java
@@ -134,6 +134,11 @@
         }
         //add for BSPA-233247 20230419 end
 
+        // remove QRCode scanner from Quick settings
+        if ((XXXUtils.getFrontCamera().orElse(-1) == 0) && (XXXUtils.getRearCamera().orElse(-1) == 0)) {
+            possibleTiles.remove("qr_code_scanner");
+        }
+
         for (String spec : possibleTiles) {
             // Only add current and stock tiles that can be created from QSFactoryImpl.
             // Do not include CustomTile. Those will be created by `addPackageTiles`.

你可能感兴趣的:(数码相机,android)