google上架合規(guī)2.0

1.APP又一次因?yàn)橥ㄓ嶄泦栴}被下架了

已經(jīng)做到了這四點(diǎn)了
1.通訊錄的應(yīng)用場景必須合適,使用時(shí)彈窗提示用戶我們拿通訊錄的用途
2.上傳之前必須能夠提示用戶要上傳通訊錄了,讓用戶能夠做出選擇
3.上傳不能太頻繁
4.隱私政策聲明
根據(jù)審核小組的發(fā)來的郵件,這次的理由是我們使用通訊錄的理由不夠充分,修改了彈窗和隱私申明相關(guān)文案再次提審就沒問題了。

2.關(guān)于Google強(qiáng)制把compileSdkVersion升級到30帶來的問題。

由于google在android 10進(jìn)行了分區(qū)的操作,之前有權(quán)限直接操作非私有目錄下的文件已經(jīng)不行了,當(dāng)時(shí)使用的是臨時(shí)替代方案使用android:requestLegacyExternalStorage="true"。但是在compileSdkVersion升級到30的時(shí)候這個(gè)標(biāo)簽會自動忽略。還好我們自己應(yīng)用使用到操作的文件并不多,主要是一個(gè)第三方的sdk,包含拍照和選圖以及壓縮功能,由于作者已經(jīng)很久沒有更新了,只能自己下完包一個(gè)個(gè)去改了。主要的問題:
1.應(yīng)用創(chuàng)建文件使用外部存儲空間
2.應(yīng)用操作外部文件。
解決辦法:
第一個(gè)問題主要是在一些緩存文件的地方放在了外部存儲目錄,后面就統(tǒng)一使用getExternalCacheDir創(chuàng)建目錄了
第二個(gè)問題主要是會在圖片的壓縮還是直接用的絕對路徑,這個(gè)時(shí)候需要拿到文件的Uri,然后將文件復(fù)制到我們自己的目錄下進(jìn)行操作。附上我自己的代碼

public static File from(Context context, Uri uri) throws IOException {
        InputStream inputStream = context.getContentResolver().openInputStream(uri);
        String fileName = getFileName(context, uri);
        String[] splitName = splitFileName(fileName);
        File tempFile = File.createTempFile(splitName[0], splitName[1]);
        tempFile = rename(tempFile, fileName);
        tempFile.deleteOnExit();
        FileOutputStream out = null;
        try {
            out = new FileOutputStream(tempFile);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        if (inputStream != null) {
            copy(inputStream, out);
            inputStream.close();
        }

        if (out != null) {
            out.close();
        }
        return tempFile;
    }

    private static String[] splitFileName(String fileName) {
        String name = fileName;
        String extension = "";
        int i = fileName.lastIndexOf(".");
        if (i != -1) {
            name = fileName.substring(0, i);
            extension = fileName.substring(i);
        }

        return new String[]{name, extension};
    }

    private static String getFileName(Context context, Uri uri) {
        String result = null;
        if (uri.getScheme().equals("content")) {
            Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
            try {
                if (cursor != null && cursor.moveToFirst()) {
                    result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (cursor != null) {
                    cursor.close();
                }
            }
        }
        if (result == null) {
            result = uri.getPath();
            int cut = result.lastIndexOf(File.separator);
            if (cut != -1) {
                result = result.substring(cut + 1);
            }
        }
        return result;
    }

    private static File rename(File file, String newName) {
        File newFile = new File(file.getParent(), newName);
        if (!newFile.equals(file)) {
            if (newFile.exists() && newFile.delete()) {
                Log.d("FileUtil", "Delete old " + newName + " file");
            }
            if (file.renameTo(newFile)) {
                Log.d("FileUtil", "Rename file to " + newName);
            }
        }
        return newFile;
    }

    private static long copy(InputStream input, OutputStream output) throws IOException {
        long count = 0;
        int n;
        byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
        while (EOF != (n = input.read(buffer))) {
            output.write(buffer, 0, n);
            count += n;
        }
        return count;
    }

3.APP獲取應(yīng)用Android列表的問題。

在需要加上android 11android:name="android.permission.QUERY_ALL_PACKAGES"android:name="android.permission.QUERY_ALL_PACKAGES"申明否者無法直接獲取應(yīng)用的安裝列表了。并且google明確提出明年這個(gè)也會被限制。
解決辦法:
1.在google管理后臺去提交申請
2.拿到你想查詢的應(yīng)用的包名放到你的androidManifest文件里,在Android11沒有權(quán)限的情況是可以查到的

4.Unencrypted traffic allowed on all domains

Configure your application's network security to allow unencrypted traffic across all domains. Eavesdroppers can take advantage of this to intercept the data your application sends.If such data is sensitive or could be used to identify a user,this could compromisse user privacy. It is best to allow only encrypted traffic by setting the cleartextTrafficPermitted flag to false,or by adding an encryption policy for specific domains.

由于本身是一個(gè)老的項(xiàng)目,本身還有訪問一些http外鏈,所以基本都是明文請求,google play上架為了數(shù)據(jù)的安全性要求統(tǒng)一使用cleartextTrafficPermitted為false.但是這導(dǎo)致了http鏈接無法訪問,但是你可以在networkSecurityConfig配置文件中配置你信任的CA 如

<?xml version="1.0" encoding="utf-8"?>
    <network-security-config>
        <domain-config>
            <domain includeSubdomains="true">example.com</domain>
            <trust-anchors>
                <certificates src="@raw/my_ca"/>
            </trust-anchors>
        </domain-config>
    </network-security-config>
    

具體一些其他的配置可以參考Android網(wǎng)絡(luò)安全配置

5.Encryption is not secure

Your application uses insecure encryption.

google play給了一個(gè)鏈接針對不安全加密問題的解決方法
看了下項(xiàng)目中設(shè)計(jì)到加密的地方就一個(gè) 接口的全局加密,用的是aes的對稱加密,對比google play的文檔應(yīng)該指出的是加密的密鑰太容易獲取了,可以使用 AndroidKeystore 存儲密鑰。由于用官方的方法要額外引用三個(gè)包,我就沒采用官方的方法,直接寫了一個(gè)jni編譯成so用來獲取加密的key,再次提審也沒有這個(gè)問題了。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容