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

Commit 1119bb93 authored by Inseob Kim's avatar Inseob Kim
Browse files

Remove unused system properties

Properties ro.config.license_path and ro.config.manual_path are not set
from anywhere but only from a test.

Bug: N/A
Test: mma -j
Change-Id: I651405f3a201f5129bf37059e96e7bcc5efa73bf
Merged-In: I651405f3a201f5129bf37059e96e7bcc5efa73bf
parent cc24a22d
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
@@ -35,8 +34,7 @@ import java.io.File;
public class ManualDisplayActivity extends Activity {
    private static final String TAG = "SettingsManualActivity";

    private static final String DEFAULT_MANUAL_PATH = "/system/etc/MANUAL.html.gz";
    private static final String PROPERTY_MANUAL_PATH = "ro.config.manual_path";
    private static final String MANUAL_PATH = "/system/etc/MANUAL.html.gz";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -47,16 +45,9 @@ public class ManualDisplayActivity extends Activity {
            finish();   // No manual to display for this device
        }

        final String path = SystemProperties.get(PROPERTY_MANUAL_PATH, DEFAULT_MANUAL_PATH);
        if (TextUtils.isEmpty(path)) {
            Log.e(TAG, "The system property for the manual is empty");
            showErrorAndFinish();
            return;
        }

        final File file = new File(path);
        final File file = new File(MANUAL_PATH);
        if (!file.exists() || file.length() == 0) {
            Log.e(TAG, "Manual file " + path + " does not exist");
            Log.e(TAG, "Manual file " + MANUAL_PATH + " does not exist");
            showErrorAndFinish();
            return;
        }
+4 −27
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.content.Intent;
import android.content.Loader;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemProperties;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.FileProvider;
import android.text.TextUtils;
@@ -43,8 +42,7 @@ public class SettingsLicenseActivity extends Activity implements
            LoaderManager.LoaderCallbacks<File> {
    private static final String TAG = "SettingsLicenseActivity";

    private static final String DEFAULT_LICENSE_PATH = "/system/etc/NOTICE.html.gz";
    private static final String PROPERTY_LICENSE_PATH = "ro.config.license_path";
    private static final String LICENSE_PATH = "/system/etc/NOTICE.html.gz";

    private static final int LOADER_ID_LICENSE_HTML_LOADER = 0;

@@ -52,10 +50,9 @@ public class SettingsLicenseActivity extends Activity implements
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final String licenseHtmlPath =
                SystemProperties.get(PROPERTY_LICENSE_PATH, DEFAULT_LICENSE_PATH);
        if (isFilePathValid(licenseHtmlPath)) {
            showSelectedFile(licenseHtmlPath);
        File file = new File(LICENSE_PATH);
        if (isFileValid(file)) {
            showHtmlFromUri(Uri.fromFile(file));
        } else {
            showHtmlFromDefaultXmlFiles();
        }
@@ -94,22 +91,6 @@ public class SettingsLicenseActivity extends Activity implements
        }
    }

    private void showSelectedFile(final String path) {
        if (TextUtils.isEmpty(path)) {
            Log.e(TAG, "The system property for the license file is empty");
            showErrorAndFinish();
            return;
        }

        final File file = new File(path);
        if (!isFileValid(file)) {
            Log.e(TAG, "License file " + path + " does not exist");
            showErrorAndFinish();
            return;
        }
        showHtmlFromUri(Uri.fromFile(file));
    }

    private void showHtmlFromUri(Uri uri) {
        // Kick off external viewer due to WebView security restrictions; we
        // carefully point it at HTMLViewer, since it offers to decompress
@@ -138,10 +119,6 @@ public class SettingsLicenseActivity extends Activity implements
        finish();
    }

    private boolean isFilePathValid(final String path) {
        return !TextUtils.isEmpty(path) && isFileValid(new File(path));
    }

    @VisibleForTesting
    boolean isFileValid(final File file) {
        return file.exists() && file.length() != 0;
+0 −3
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import static org.robolectric.Shadows.shadowOf;
import android.app.Application;
import android.content.Intent;
import android.net.Uri;
import android.os.SystemProperties;

import com.android.settings.testutils.SettingsRobolectricTestRunner;

@@ -67,8 +66,6 @@ public class SettingsLicenseActivityTest {

    @Test
    public void testOnCreateWithValidHtmlFile() {
        SystemProperties.set("ro.config.license_path", "/system/etc/NOTICE.html.gz");

        doReturn(true).when(mActivity).isFileValid(any());
        mActivity.onCreate(null);