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

Commit 2061ebb1 authored by Michael W's avatar Michael W
Browse files

Dialer: Remove some static java libraries

* com.android.vcard is unused
* libbackup was used - but in unused code, which is also removed here
* zxing: Was used for barcode generation - simply existed for
  TMO USA. Make it the same for everyone: no barcodes
  * Also remove the decimal + hex variants (only VZW)

Change-Id: Iaddfce6c4e507c94dd99e68b0a082872d512c711
parent 73ee40fe
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ LOCAL_AAPT_FLAGS += \
LOCAL_STATIC_JAVA_LIBRARIES := \
	android-common \
	android-support-dynamic-animation \
	com.android.vcard \
	dialer-commons-io-target \
	dialer-dagger2-target \
	dialer-disklrucache-target \
@@ -70,10 +69,8 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
	dialer-guava-target \
	dialer-glide-target \
	dialer-glide-annotation-target \
	dialer-zxing-target \
	error_prone_annotations \
	jsr305 \
	libbackup \
	libphonenumber \
	volley \
	org.lineageos.lib.phone \
@@ -323,19 +320,6 @@ include $(BUILD_PREBUILT)

include $(CLEAR_VARS)

LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE := dialer-zxing-target
LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
LOCAL_LICENSE_CONDITIONS := notice
LOCAL_NOTICE_FILE := $(LOCAL_PATH)/LICENSE
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := ../../../external/zxing/core/core.jar
LOCAL_UNINSTALLABLE_MODULE := true

include $(BUILD_PREBUILT)

include $(CLEAR_VARS)

LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE := dialer-j2objc-annotations-target
LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
+0 −25
Original line number Diff line number Diff line
<!--
 ~ Copyright (C) 2017 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
 -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.dialer.backup">


  <!-- Android backup service key -->
  <!-- https://developer.android.com/google/backup/signup.html -->
  <meta-data
      android:name="com.google.android.backup.api_key"
      android:value="AEdPqrEAAAAIn3-Y3JKit1mrzfvcdbVhUiJn2ICtKfhGYLy0Bg"/>
</manifest>
 No newline at end of file
+0 −85
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.dialer.backup;

import android.app.backup.BackupDataInput;
import android.app.backup.BackupDataOutput;
import android.os.ParcelFileDescriptor;
import android.util.ArrayMap;

import androidx.annotation.NonNull;

import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.google.android.libraries.backup.BackupKeyPredicate;
import com.google.android.libraries.backup.BackupKeyPredicates;
import com.google.android.libraries.backup.PersistentBackupAgentHelper;
import java.io.IOException;
import java.util.Map;

/** Implementation of Key/Value Backup that powers Dialer's backup and restore. */
public class DialerPersistentBackupAgent extends PersistentBackupAgentHelper {

  private static final String[] BACKUP_NAMED_SHARED_PREFS = {
    "com.google.android.dialer_preferences", "com.google.android.dialer", "com.android.dialer"
  };

  @NonNull
  private final String[] sharedPreferencesToBackup;

  DialerPersistentBackupAgent(@NonNull String[] sharedPrefs) {
    this.sharedPreferencesToBackup = Assert.isNotNull(sharedPrefs);
  }

  public DialerPersistentBackupAgent() {
    this(BACKUP_NAMED_SHARED_PREFS);
  }

  @Override
  public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor stateFile)
      throws IOException {
    LogUtil.i("DialerPersistentBackupAgent.onRestore", "restore from version: " + appVersionCode);
    super.onRestore(data, appVersionCode, stateFile);
  }

  @Override
  public void onBackup(
      ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState)
      throws IOException {
    LogUtil.i("DialerPersistentBackupAgent.onBackup", "onBackup being performed");
    super.onBackup(oldState, data, newState);
  }

  @Override
  public Map<String, BackupKeyPredicate> getBackupSpecification() {
    LogUtil.i(
        "DialerPersistentBackupAgent.getBackupSpecification",
        "number of files being backed up: " + sharedPreferencesToBackup.length);

    Map<String, BackupKeyPredicate> arrayMap = new ArrayMap<>();
    for (String fileName : sharedPreferencesToBackup) {
      LogUtil.i("DialerPersistentBackupAgent.getBackupSpecification", "arrayMap.put: " + fileName);
      arrayMap.put(fileName, BackupKeyPredicates.alwaysTrue());
    }

    return arrayMap;
  }

  @Override
  public void onRestoreFinished() {
    super.onRestoreFinished();
  }
}
+4 −88
Original line number Diff line number Diff line
@@ -29,9 +29,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Color;
import android.net.Uri;
import android.provider.Settings;
import android.telecom.PhoneAccount;
@@ -43,10 +40,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

@@ -66,11 +61,6 @@ import com.android.dialer.oem.MotorolaUtils;
import com.android.dialer.oem.TranssionUtils;
import com.android.dialer.telecom.TelecomUtil;
import com.android.dialer.util.PermissionsUtil;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

@@ -330,22 +320,11 @@ public class SpecialCharSequenceMgr {
        for (int slot = 0; slot < telephonyManager.getPhoneCount(); slot++) {
          String deviceId = telephonyManager.getDeviceId(slot);
          if (!TextUtils.isEmpty(deviceId)) {
            addDeviceIdRow(
                holder,
                deviceId,
                /* showDecimal */
                context.getResources().getBoolean(R.bool.show_device_id_in_hex_and_decimal),
                /* showBarcode */ false);
            addDeviceIdRow(holder, deviceId);
          }
        }
      } else {
        addDeviceIdRow(
            holder,
            telephonyManager.getDeviceId(),
            /* showDecimal */
            context.getResources().getBoolean(R.bool.show_device_id_in_hex_and_decimal),
            /* showBarcode */
            context.getResources().getBoolean(R.bool.show_device_id_as_barcode));
        addDeviceIdRow(holder, telephonyManager.getDeviceId());
      }

      new AlertDialog.Builder(context)
@@ -361,8 +340,7 @@ public class SpecialCharSequenceMgr {
    return false;
  }

  private static void addDeviceIdRow(
      ViewGroup holder, String deviceId, boolean showDecimal, boolean showBarcode) {
  private static void addDeviceIdRow(ViewGroup holder, String deviceId) {
    if (TextUtils.isEmpty(deviceId)) {
      return;
    }
@@ -372,45 +350,9 @@ public class SpecialCharSequenceMgr {
            LayoutInflater.from(holder.getContext()).inflate(R.layout.row_deviceid, holder, false);
    holder.addView(row);

    // Remove the check digit, if exists. This digit is a checksum of the ID.
    // See https://en.wikipedia.org/wiki/International_Mobile_Equipment_Identity
    // and https://en.wikipedia.org/wiki/Mobile_equipment_identifier
    String hex = deviceId.length() == 15 ? deviceId.substring(0, 14) : deviceId;

    // If this is the valid length IMEI or MEID (14 digits), show it in all formats, otherwise fall
    // back to just showing the raw hex
    if (hex.length() == 14 && showDecimal) {
      ((TextView) row.findViewById(R.id.deviceid_hex)).setText(hex);
      ((TextView) row.findViewById(R.id.deviceid_dec)).setText(getDecimalFromHex(hex));
      row.findViewById(R.id.deviceid_dec_label).setVisibility(View.VISIBLE);
    } else {
      row.findViewById(R.id.deviceid_hex_label).setVisibility(View.GONE);
    ((TextView) row.findViewById(R.id.deviceid_hex)).setText(deviceId);
  }

    final ImageView barcode = row.findViewById(R.id.deviceid_barcode);
    if (showBarcode) {
      // Wait until the layout pass has completed so we the barcode is measured before drawing. We
      // do this by adding a layout listener and setting the bitmap after getting the callback.
      barcode
          .getViewTreeObserver()
          .addOnGlobalLayoutListener(
              new OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                  barcode.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                  Bitmap barcodeBitmap =
                      generateBarcode(hex, barcode.getWidth(), barcode.getHeight());
                  if (barcodeBitmap != null) {
                    barcode.setImageBitmap(barcodeBitmap);
                  }
                }
              });
    } else {
      barcode.setVisibility(View.GONE);
    }
  }

  private static String getDecimalFromHex(String hex) {
    final String part1 = hex.substring(0, 8);
    final String part2 = hex.substring(8);
@@ -447,32 +389,6 @@ public class SpecialCharSequenceMgr {
    return builder.toString();
  }

  /**
   * This method generates a 2d barcode using the zxing library. Each pixel of the bitmap is either
   * black or white painted vertically. We determine which color using the BitMatrix.get(x, y)
   * method.
   */
  private static Bitmap generateBarcode(String hex, int width, int height) {
    MultiFormatWriter writer = new MultiFormatWriter();
    String data = Uri.encode(hex);

    try {
      BitMatrix bitMatrix = writer.encode(data, BarcodeFormat.CODE_128, width, 1);
      Bitmap bitmap = Bitmap.createBitmap(bitMatrix.getWidth(), height, Config.RGB_565);

      for (int i = 0; i < bitMatrix.getWidth(); i++) {
        // Paint columns of width 1
        int[] column = new int[height];
        Arrays.fill(column, bitMatrix.get(i, 0) ? Color.BLACK : Color.WHITE);
        bitmap.setPixels(column, 0, 1, i, 0, 1, height);
      }
      return bitmap;
    } catch (WriterException e) {
      LogUtil.e("SpecialCharSequenceMgr.generateBarcode", "error generating barcode", e);
    }
    return null;
  }

  private static boolean handleRegulatoryInfoDisplay(Context context, String input) {
    if (input.equals(MMI_REGULATORY_INFO_DISPLAY)) {
      LogUtil.i(
+0 −25
Original line number Diff line number Diff line
@@ -18,35 +18,10 @@
    android:layout_height="wrap_content"
    android:layout_marginTop="?dialogPreferredPadding"
    android:orientation="vertical">
  <TextView
      android:id="@+id/deviceid_hex_label"
      style="@style/DeviceIdBody"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/hex"/>
  <TextView
      android:id="@+id/deviceid_hex"
      style="@style/DeviceIdBody"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textIsSelectable="true"/>
  <TextView
      android:id="@+id/deviceid_dec_label"
      style="@style/DeviceIdBody"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/dec"
      android:visibility="gone"/>
  <TextView
      android:id="@+id/deviceid_dec"
      style="@style/DeviceIdBody"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textIsSelectable="true"/>
  <ImageView
      android:id="@+id/deviceid_barcode"
      android:layout_width="match_parent"
      android:layout_height="@dimen/barcode_height"
      android:layout_margin="24dp"
      android:layout_gravity="center_horizontal"/>
</LinearLayout>
Loading