[Android] Calin:
Packages

​

As i stated in the OP i will make also a little part about the Packages which are included in the ROM sources before going to the Settings sources.

Well first of all let's take the packages folder from the ROM dir:

So we've got these folders.

In these folders there are several packages which you don't need it (most of it)

So these packages can be easily removed, but remember to remove also the entru from the default.xml from platform manifest in order to don't fetch the project again.

In apps

You can easily remove these projects:

CMBugReport

HTML Viewer

Speech recorder

TVSettings (Optional)

In experimental

Here i suggest you to maintain all the projects because you need them all

The same also for the providers

In screensavers

The screensavers folder instead can be entirely removed because they are also outdated and i think you don't need it for your sources.

The same also for the wallpapers folder.

Add apps to the sources

Now if you have an app and want to include it to your ROM you can add the app sources to the apps folder including in the app folder the Android.mk file.

But wait what is it?

Android.mk can be found in almost every folder of the ROM sources and represent an identity for the build environment in order know what to do with files located inside that folder.

So basically the Android.mk just tell to the build environment what to do with the files contained in that folder.

So how you can make an Android.mk ?

Simply, usually if you include basic apps, i mean apps which not require special build process by including special flags then the basic Android.mk used for the compilation of an app is this:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := $(call all-subdir-java-files)

LOCAL_PACKAGE_NAME := YourApp name

include $(BUILD_PACKAGE)

So if you want to include an app made for your own to the ROM sources and as i said is a basic app which not requires special flags for the compilation this is the Android.mk schema to use ;)

Before jumping and going to work on the Settings sources, another thing which in my opinion can be easily added is an OTA Updater app.

Don't worry you don't need to make an app for this but i can suggest you one made by an XDA User , it's tested by and i can asure you that is working very well, but you need to follow a bit some instructions which i think aren't so difficult to follow.

Once you red the instructions, you can fork the repo to your repo organization and start working on the sources files. I'm not going to make a guide of this but i will just tell you to be careful with the sources and to don't modify the Android.mk contained in the app sources.

And the link is this: https://github.com/Kryten2k35/OTAUpdates

That's it!

Now we can proceed with the Settings part :)

Settings Part

​

So here we are guys, finally we arrived to the Settings sources part, which in my opinion is one of the most featured part of all.

As usual we will split the post in two parts:

CM Removable Part

Features part

But before we continue, make sure to have forked and cloned the repo to your PC.

CM Removable part

​

Ok so let's begin with the CM removable stuff part.

Open the sources and go and find Android Manifest , open it, now find this activity :

<activity android:name="SettingsCMLicenseActivity"

Now delete the etire activity.

After, find also these activities, and remove them all:

<activity android:name="Settings$AnonymousStatsActivity"
<activity android:name=".cyanogenmod.ChangeLog" />
<activity android:name=".cyanogenmod.ContributorsCloud" />

Now go to res/values/cm_strings

And remove all these lines:

<!-- Anonymous Statistics #CM -->
<!-- About device screen, list item title. Takes the user to the screen about opting in or out of anonymous statistics. -->
<string name="anonymous_statistics_title">CyanogenMod statistics</string>
<string name="anonymous_statistics_summary">Help make CyanogenMod better by opting into anonymous statistics reporting</string>
<string name="anonymous_statistics_warning_title">About</string>
<string name="anonymous_statistics_warning">Opting into CyanogenMod Statistics will allow non-personal data to be submitted to the
developers of CyanogenMod to track unique installations across devices. The information submitted includes an unique identifier,
which does not compromise your privacy or personal data. The data is submitted during each boot.\n\nFor an example of the data that is submitted, tap on Preview Data.</string>
<string name="enable_reporting_title">Enable reporting</string>
<string name="preview_data_title">Preview data</string>
<string name="view_stats_title">View stats</string>
<string name="anonymous_learn_more">Learn more</string>

Now go to res/drawable-hdpi

And remove this png:

ic_cm_stats_notif.png

Now go to res/drawable-mdpi

And remove the same png also here.

And finally the same also for drawable/xhdpi

After go to res/xml/device_info_settings

And delete this whole preference screen:

<!-- System update settings - launches activity -->
<PreferenceScreen android:key="system_update_settings"
android:title="@string/system_update_settings_list_item_title"
android:summary="@string/system_update_settings_list_item_summary">
<intent android:action="android.settings.SYSTEM_UPDATE_SETTINGS"
android:targetPackage="com.cyngn.fota"
android:targetClass="com.cyngn.fota.SystemUpdateActivity" />
</PreferenceScreen>
<PreferenceScreen android:key="additional_system_update_settings"
android:title="@string/additional_system_update_settings_list_item_title">
<intent android:action="android.intent.action.MAIN"
android:targetPackage="@string/additional_system_update"
android:targetClass="@string/additional_system_update_menu" />
</PreferenceScreen>
<!-- CyanogenMod Updates -->
<PreferenceScreen android:key="cm_updates"
android:title="@string/cmupdate_settings_title"
android:summary="@string/system_update_settings_list_item_summary">
<intent android:action="android.intent.action.MAIN"
android:targetPackage="com.cyanogenmod.updater"
android:targetClass="com.cyanogenmod.updater.UpdatesSettings" />
</PreferenceScreen>

This one also:

<!-- Contributors cloud -->
<PreferenceScreen android:key="contributor_cloud"
android:title="@string/contributor_cloud_title"
android:fragment="com.android.settings.cyanogenmod.ContributorsCloud" >
</PreferenceScreen>

This one also:

<!-- CM License information -->
<PreferenceScreen
android:key="cmlicense"
android:title="@string/cmlicense_title">
<intent android:action="android.settings.CMLICENSE" />
</PreferenceScreen>

And also this one:

<!-- Change Log -->
<PreferenceScreen android:key="changelog"
android:title="@string/changelog_title"
android:fragment="com.android.settings.cyanogenmod.ChangeLog" >
</PreferenceScreen>

Now find also these xml files: which are located in the same folder:

anonymous_stats.xml
preview_data.xml

And delete them.

Now return to the main directory of settings and go to src/com/android/settings/Settings

Find:

CMLicenseActivity.java

And delete it.

Now go here: src/com/android/settings/cyanogenmod/

Find:

ContributorsCloud.java

And delete it.

Now go here: src/com/android/settings

Open:

DeviceInfoSettings.java

And delete the following lines (in order):

import android.content.pm.PackageManager.NameNotFoundException;
private static final String KEY_CM_UPDATES = "cm_updates";

// Only the owner should see the Updater settings, if it exists
if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
removePreferenceIfPackageNotInstalled(findPreference(KEY_CM_UPDATES));
} else {
getPreferenceScreen().removePreference(findPreference(KEY_CM_UPDATES));
}

private boolean removePreferenceIfPackageNotInstalled(Preference preference) {
String intentUri=((PreferenceScreen) preference).getIntent().toUri(1);
Pattern pattern = Pattern.compile("component=([^/]+)/");
Matcher matcher = pattern.matcher(intentUri);
String packageName=matcher.find()?matcher.group(1):null;
if(packageName != null) {
try {
PackageInfo pi = getPackageManager().getPackageInfo(packageName,
PackageManager.GET_ACTIVITIES);
if (!pi.applicationInfo.enabled) {
Log.e(LOG_TAG,"package "+packageName+" is disabled, hiding preference.");
getPreferenceScreen().removePreference(preference);
return true;
}
} catch (NameNotFoundException e) {
Log.e(LOG_TAG,"package "+packageName+" not installed, hiding preference.");
getPreferenceScreen().removePreference(preference);
return true;
}
}
return false;
}

Now save and close it.

After that go here: src/com/android/settings/

Open

Settings.java

And delete this line:

public static class AnonymousStatsActivity extends Settings { /* empty */ }

Save and close it.

Now the last part delete these java files:

src/com/android/settings/cmstats/AnonymousStats.java
src/com/android/settings/cmstats/PreviewData.java
src/com/android/settings/cmstats/ReportingService.java
src/com/android/settings/cmstats/ReportingServiceManager.java
src/com/android/settings/cmstats/Utilities.java

Now the very last part of these modifications....

Go here: src/com/android/settings/cyanogenmod/

And cut the ChangeLog.java file because we will need it to your Desktop.

So that's it.

Mostly these are the files to be deleted but as always if you consider that some other CM stuff needs to be deleted just write it on the Thread and i will add them ;)

Now let's move on to the second part!

Features part

​

Ok so finally we can talk about the features in Settings.

Here you can add plenty of things, and i will try now to include now to most important ones but as always if you got some new ones that you consider that can be added to the Guide just write it on the thread and i will looking forward to add them ;)

I will add also here a difficulty level exactly as i did in the Extra Features part.

So let's start guys :)

Add more info about phone like Hardware etc...

​

Difficulty level:

Difficulty level: (*°°°°)

This is optionally but if you want to include more hardware informations just follow this mini guide .

First go to res/values

Now create a new strings xml fine starting in this way:

romname_strings.xml (all lowercase)

Ok, now open it and include the following strings:

<!-- About device screen, Hardware info -->
<string name="hardware_info">Hardware info</string>
<!-- About device Screen, hardware info, rear camera -->
<string name="device_rear_camera">Rear camera</string>
<!-- About device Screen, hardware info, front camera -->
<string name="device_front_camera">Front facing camera</string>
<!-- About device Screen, hardware info, screen res -->
<string name="device_screen_resolution">Screen resolution</string>
<!-- About device Screen, hardware info, GPU info -->
<string name="gpu_info">GPU</string>
<!-- About device screen, Cpu info. -->
<string name="cpu_info">CPU</string>
<!-- About phone screen, Free memory info -->
<string name="mem_info">Memory</string>

Ok, now save and close it.

Now go to the xml folder

And open:

device_info_settings.xml

And add the following lines at the bottom:

<PreferenceScreen
android:key="hardware_info"
android:title="@string/hardware_info">
<!-- Device cpu info -->
<Preference android:key="device_cpu"
style="?android:preferenceInformationStyle"
android:title="@string/cpu_info"
android:summary="@string/device_info_default"/>
<!-- Device gpu info -->
<Preference android:key="device_gpu"
style="?android:preferenceInformationStyle"
android:title="@string/gpu_info"
android:summary="@string/device_info_default"/>
<!-- Device mem info -->
<Preference android:key="device_memory"
style="?android:preferenceInformationStyle"
android:title="@string/mem_info"
android:summary="@string/device_info_default"/>
<!-- Device rear camera -->
<Preference android:key="device_rear_camera"
style="?android:preferenceInformationStyle"
android:title="@string/device_rear_camera"/>
<!-- Device front camera -->
<Preference android:key="device_front_camera"
style="?android:preferenceInformationStyle"
android:title="@string/device_front_camera"/>
<!-- Device screen resolution -->
<Preference android:key="device_screen_resolution"
style="?android:preferenceInformationStyle"
android:title="@string/device_screen_resolution"/>
</PreferenceScreen>

And remove the following lines:

<!-- Device cpu info -->
<Preference android:key="device_cpu"
style="?android:preferenceInformationStyle"
android:title="@string/cpu_info"
android:summary="@string/device_info_default"/>
<!-- Device mem info -->
<Preference android:key="device_memory"
style="?android:preferenceInformationStyle"
android:title="@string/mem_info"
android:summary="@string/device_info_default"/>

Ok now save and close it.

Now go to the main dir of Settings and go to src/com/android/settings

And open:

DeviceInfoSettings.java

Now remove the following lines:

private static final String KEY_DEVICE_CPU = "device_cpu";
private static final String KEY_DEVICE_MEMORY = "device_memory";

And instead add these ones:

private static final String KEY_DEVICE_CPU = "device_cpu";
private static final String KEY_DEVICE_GPU = "device_gpu";
private static final String KEY_DEVICE_MEMORY = "device_memory";
private static final String KEY_DEVICE_REAR_CAMERA = "device_rear_camera";
private static final String KEY_DEVICE_FRONT_CAMERA = "device_front_camera";
private static final String KEY_DEVICE_SCREEN_RESOLUTION = "device_screen_resolution";

Now add these lines after this one:

setValueSummary(KEY_MOD_BUILD_DATE, "ro.build.date");

addStringPreference(KEY_DEVICE_CPU,
SystemProperties.get("ro.device.cpu", getCPUInfo()));
addStringPreference(KEY_DEVICE_GPU,
SystemProperties.get("ro.device.gpu", null));
addStringPreference(KEY_DEVICE_MEMORY, getMemInfo());
addStringPreference(KEY_DEVICE_FRONT_CAMERA,
SystemProperties.get("ro.device.front_cam", null));
addStringPreference(KEY_DEVICE_REAR_CAMERA,
SystemProperties.get("ro.device.rear_cam", null));
addStringPreference(KEY_DEVICE_SCREEN_RESOLUTION,
SystemProperties.get("ro.device.screen_res", null));

Then the last ones need to be added at the end of file:

private void addStringPreference(String key, String value) {
if (value != null) {
setStringSummary(key, value);
} else {
getPreferenceScreen().removePreference(findPreference(key));
}
}
}

That's it! Now you will be able to see more info about your phon in device info settings.

Just make sure that you add also these lines to your build.prop:

ro.device.cpu
re.device.gpu
ro.device.front_cam
ro.device.rear_cam
ro.device.screen_res

Add your own ROM banner in Settings

​

Difficulty level: (*°°°°)

This one is very simple to follow and i think in my opinion everyone should add a banner to their Settings app :D

So first take the res folder and go to the layout folder.

And create a new xml file by adding these lines into it:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:layout_width="fill_parent" android:layout_height="wrap_content" android:src="@drawable/banner" />
</LinearLayout>

And save it as banner for example.

Now for the banner size, in my opinion you should resize you banner to a size like a : 480x180

This should fit perfectly.

Then after you prepared your banner copy it to the drawable folder and make sure that the image is saved with the "banner" name.

Now the last thing to do is to display it in Settings.

So now go to res/xml

And open:

device_info_settings.xml

And copy this line after the third line:

<PreferenceScreen android:layout="@layout/banner" android:key="od_logo" />

That's it now your logo is added in Settings!