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

Commit f38c5394 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of [19423651, 19634561] into tm-release.

Change-Id: I395fc4d63ef9a03042fd257fb46d285c1f2b3c5a
parents 79eeb2d7 de334805
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -617,4 +617,10 @@

    <!-- Whether to put the apps with system UID into system component bucket or not -->
    <bool name="config_battery_combine_system_components">false</bool>

    <!-- An array of uid name for which packages exempt from Wi-Fi permission check. -->
    <string-array name="config_exempt_wifi_permission_uid_name" translatable="false">
        <item>@string/config_settingsintelligence_package_name</item>
        <item>android.uid.system:1000</item>
    </string-array>
</resources>
+6 −2
Original line number Diff line number Diff line
@@ -86,10 +86,14 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPairingController.getDialogType()
                != BluetoothPairingController.DISPLAY_PASSKEY_DIALOG) {
            /* Cancel pairing unless explicitly accepted by user */
            if (!mPositiveClicked) {
                mPairingController.onCancel();
            }
        }
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+16 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ public class WifiSlice implements CustomSliceable {
    public Slice getSlice() {
        // If external calling package doesn't have Wi-Fi permission.
        final boolean isPermissionGranted =
                Utils.isSettingsIntelligence(mContext) || isPermissionGranted(mContext);
                isCallerExemptUid(mContext) || isPermissionGranted(mContext);
        final boolean isWifiEnabled = isWifiEnabled();
        ListBuilder listBuilder = getListBuilder(isWifiEnabled, null /* wifiSliceItem */,
                isPermissionGranted);
@@ -139,6 +139,21 @@ public class WifiSlice implements CustomSliceable {
        return listBuilder.build();
    }

    private boolean isCallerExemptUid(Context context) {
        final String[] allowedUidNames = context.getResources().getStringArray(
                R.array.config_exempt_wifi_permission_uid_name);
        final String uidName =
                context.getPackageManager().getNameForUid(Binder.getCallingUid());
        Log.d(TAG, "calling uid name : " + uidName);

        for (String allowedUidName : allowedUidNames) {
            if (TextUtils.equals(uidName, allowedUidName)) {
                return true;
            }
        }
        return false;
    }

    private static boolean isPermissionGranted(Context settingsContext) {
        final int callingUid = Binder.getCallingUid();
        final String callingPackage = settingsContext.getPackageManager()
+1 −0
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ public class ContextualWifiSliceTest {
                mContext.getString(R.string.config_settingsintelligence_package_name);
        ShadowBinder.setCallingUid(1);
        when(mPackageManager.getPackagesForUid(1)).thenReturn(new String[]{siPackageName});
        when(mPackageManager.getNameForUid(1)).thenReturn(siPackageName);
        ShadowWifiSlice.setWifiPermissible(true);
        mWifiSlice = new ContextualWifiSlice(mContext);
    }
+4 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ public class WifiSliceTest {
        mSIPackageName = mContext.getString(R.string.config_settingsintelligence_package_name);
        ShadowBinder.setCallingUid(USER_ID);
        when(mPackageManager.getPackagesForUid(USER_ID)).thenReturn(new String[]{mSIPackageName});
        when(mPackageManager.getNameForUid(USER_ID)).thenReturn(mSIPackageName);
        ShadowWifiSlice.setWifiPermissible(true);
        mWifiSlice = new WifiSlice(mContext, mWifiRestriction);
    }
@@ -116,6 +117,7 @@ public class WifiSliceTest {
    @Test
    public void getWifiSlice_fromSIPackage_shouldHaveTitleAndToggle() {
        when(mPackageManager.getPackagesForUid(USER_ID)).thenReturn(new String[]{mSIPackageName});
        when(mPackageManager.getNameForUid(USER_ID)).thenReturn(mSIPackageName);
        ShadowWifiSlice.setWifiPermissible(false);

        final Slice wifiSlice = mWifiSlice.getSlice();
@@ -131,6 +133,7 @@ public class WifiSliceTest {
    @Test
    public void getWifiSlice_notFromSIPackageAndWithWifiPermission_shouldHaveTitleAndToggle() {
        when(mPackageManager.getPackagesForUid(USER_ID)).thenReturn(new String[]{"com.test"});
        when(mPackageManager.getNameForUid(USER_ID)).thenReturn("com.test");
        ShadowWifiSlice.setWifiPermissible(true);

        final Slice wifiSlice = mWifiSlice.getSlice();
@@ -145,6 +148,7 @@ public class WifiSliceTest {
    @Test
    public void getWifiSlice_notFromSIPackageAndWithoutWifiPermission_shouldReturnNoToggle() {
        when(mPackageManager.getPackagesForUid(USER_ID)).thenReturn(new String[]{"com.test"});
        when(mPackageManager.getNameForUid(USER_ID)).thenReturn("com.test");
        ShadowWifiSlice.setWifiPermissible(false);

        final Slice wifiSlice = mWifiSlice.getSlice();