Moving from GitHub to GitLab!

gitlab

I’m really not a conspiracy theorist. I don’t truly believe that Microsoft embodies all things evil. But after the announcement of GitHub’s purchase by Microsoft, I still decided to move away from GitHub and copy all my repositories over to GitLab.

I had several choices when making the move from GitHub, but I felt that GitLab’s open source platform was best in keeping with my goals as an (unskilled but learning) open source programmer. I also appreciate that you can download the GitLab software and run it yourself on your own server, which is something that I may look into in the future.

I have already copied all of my repositories to GitLab, and they have the same name and kept all of the commit history as well, thanks to GitLab’s great import tool. Over the next few weeks, I will be considering how to appropriately close and/or mark my GitHub repositories so that people will use the GitLab issue tracker and look to GitLab for updates. Thank you for your patience.

Going forward on this blog, I will be using GitLab and not GitHub. However, due to the volume of old posts I cannot take the time to change all of the old posts links. If you are looking for something older, and you can’t find it on GitHub, then try looking at GitLab, where the same repositories, issue trackers, and history of commits reside. I do apologize for any inconvenience that may cause.

In any event, agreed or not, you can still check out all of my work at https://gitlab.com/alaskalinuxuser , and thanks for reading my post.

Linux – keep it simple.

Edited Hourglass app manual time entry function.

ss5

Last week GitHub user spaetz brought forward a great idea for the Hourglass Android timer app that I made a while back. He recommended that the manual time entry be adjusted so that entering any number without a colon (:) would be counted as minutes. Here you can see his issue in the tracker:

https://github.com/alaskalinuxuser/app_hourglass/issues/7

After a quick review of the code, I came up with a simple fix, which you can see in my commit here:

https://github.com/alaskalinuxuser/app_hourglass/commit/fb28250c74e59582e887ede69cf75c1f061caf3c

Essentially, I just check to see if the entered time includes a colon. If it does, then I check it as usual. If not, then I take it as minutes only. Nothing spectacular here, but this is the main portion of the change:

// We wrap this in try, so the app can’t crash if they put in some weird number….
 try {
 –
 + int sec,min,math;
 // Alright, let’s split that time based on colon.
 – String[] foundSplit = manualTime.split(“:”);
 + if (manualTime.contains(“:”)) {
 + String[] foundSplit = manualTime.split(“:”);
 + // Testing only // Log.i(“WJH”, foundSplit[0]);
 + // Testing only // Log.i(“WJH”, foundSplit[1]);

 – // And let’s get the seconds from the split.
 – String seconds = foundSplit[1];
 + // And let’s get the seconds from the split.
 + String seconds = foundSplit[1];

 – // And the minutes from the split.
 – String minutes = foundSplit[0];
 + // And the minutes from the split.
 + String minutes = foundSplit[0];

 – // Then we convert them to integers.
 – int sec = Integer.parseInt(seconds);
 – int min = Integer.parseInt(minutes);
 + // Then we convert them to integers.
 + sec = Integer.parseInt(seconds);
 + min = Integer.parseInt(minutes);
 + } else {
 + sec = 0;
 + min = Integer.parseInt(manualTime);
 + // Testing only // Log.i(“WJH”, String.valueOf(min));
 + }

 // And do some basic math to turn them into milliseconds.
 – int math = (min * 60 * 1000) + (sec * 1000);
 + math = (min * 60 * 1000) + (sec * 1000);

Note that the – symbol is a line deleted, and the + symbol is a line added.

But that’s what’s great about open source apps. Not only could someone suggest a change, someone could also make changes and offer up improvements. Either way, the Hourglass app is better for it with this addition.

Linux – keep it simple.

Breaking down a voltage control app

I learned so many things while making the S4 GPU voltage control app, that I thought it would be appropriate to break it down into groups.

Here is the source on GitHub:

https://github.com/alaskalinuxuser/S4_GPU_voltage_control_app

And a download link for the app itself: http://www.mediafire.com/file/hk5vcce0s5r6kb7/GpuVoltageControl_1.0.apk

Since, by nature of the app, it was inherently dangerous, I wanted to make sure that people without the appropriate files would not be able to use this app. That part was pretty simple. First, I declared the needed file. If you don’t have this file, there is no reason to use this app.

[CODE]
// declare the gpu file
File gpu = new File(“/sys/devices/system/cpu/cpufreq/vdd_table/gpu_vdd_levels”);

// check if the file exists
if(gpu.exists()){
System.out.println(“gpu exists”);
} else {
Toast.makeText(this, “This kernel does not support this action!”, Toast.LENGTH_SHORT).show();
finish();
}
[/CODE]

So, if the file exists, then it pints out “gpu exists” to no where, which does nothing, but allows the program to continue. If not, or “else” it creates a pop-up (toast) that tells the user they don’t have the file and thus the kernel doesn’t support this app, and the app closes with the “finish();” command.

Then, I needed a way to tell the user what the current state of the GPU voltage was. Is it set to the default values? Is it over volted? Under volted? They needed to know so they could decide what they wanted to do next. Remember, above we already declared the file in question as “gpu”.

[CODE]
// read the file for the current status
try {
FileInputStream fIn = new FileInputStream(gpu);
BufferedReader myReader = new BufferedReader(
new InputStreamReader(fIn));
String aDataRow = “”;
String aBuffer = “”;
while ((aDataRow = myReader.readLine()) != null) {
aBuffer += aDataRow + “\n”;
}
// get first 3 characters
String result = aBuffer.toString().substring(0, 3);

// if overvolted, tell the user
if (result.equals(“955”)) {
Toast.makeText(getBaseContext(),
“GPU is currently overvolted.”,
Toast.LENGTH_LONG).show();
} else {
// do nothing
}

// if undervolted, tell the user
if (result.equals(“935”)) {
Toast.makeText(getBaseContext(),
“GPU is currently undervolted.”,
Toast.LENGTH_LONG).show();
} else {
System.out.println(result);
}

// if default, tell the user
if (result.equals(“945”)) {
Toast.makeText(getBaseContext(),
“GPU is currently set to default.”,
Toast.LENGTH_LONG).show();
} else {
System.out.println(result);
}

myReader.close();
} catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_SHORT).show();
}
[/CODE]

Here we see that the reader will take a file input stream (the gpu file) and read the first few bytes of the file. This is because the file is laid out like this:

[CODE]
945000
1050000
1150000
[/CODE]

With each line being the voltage of the corresponding frequency stage. Honestly, now that I have progressed farther in my course, I could have done this part better, to check for options that were outside of my program, say, if the user had manually set the voltages. What I did, though, was knowing what my pre-set over/under/default voltages would be, I tailored this part of the code to look for one of my presets, and to tell the user what it is set to with a toast. It works well within the confines of the app, if the user only uses this app to control the voltages.

However, if the user were to use a different app (although one does not exist at present) to control the voltages, their changes may fall outside of the limited choices of my app, so this could have been done better, but for this app, it works well enough, provided this app is the only means the user uses to control the GPU voltage.

Now that the user knows the current status of the GPU voltage, I present them with buttons to choose their own voltage options. There are only 4 options, so it is a very limited selection, but they were voltage choices that seemed to work safely, and hence why I chose them. We will only look at one for brevity, but you can check them all out on my GitHub if you would like.

[CODE]
// first up, the over volt button
oVButton = (Button) findViewById(R.id.ovButton);
oVButton.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
try {
// the command to run
String[] pwrUp = { “su”, “-c”, “echo ‘955000\n1150000\n1250000’ > /sys/devices/system/cpu/cpufreq/vdd_table/gpu_vdd_levels” };
Runtime.getRuntime().exec(pwrUp);
// tell the user
Toast.makeText(getBaseContext(),
“GPU overvolted by 10 mV!”,
Toast.LENGTH_SHORT).show();

} catch (IOException e) {
// tell the user the problem
e.printStackTrace();
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_LONG).show();
}
}
});
[/CODE]

The real magic here was how to run a command as the superuser so the program would be able to write to that system file.

Runtime.getRuntime().exec(pwrUp); // This line actually runs the command.

String[] pwrUp = { “su”, “-c”, “echo ‘955000\n1150000\n1250000’ > /sys/devices/system/cpu/cpufreq/vdd_table/gpu_vdd_levels” }; // This line is the command. If printed, it would look like this:

su -c echo ‘955000\n1150000\n1250000’ > /sys/devices/system/cpu/cpufreq/vdd_table/gpu_vdd_levels

Remember that echo is using the apostraphe, for quotes. The “\n” portion becomes a litteral line break in the file. If you used the double quote, then the output would be a litteral one line file of:

955000\n1150000\n1250000

Which wouldn’t work at all. This is convenient, since the double quote would also end the String[] (array) and break it into more parts and cause errors. So, by clicking the over volt button, they are sending a pre-set string of voltage parameters to their GPU. This is very limiting for the user, but very simple to implement, and in a way prevents abuse of the GPU by an error or unknowledgable input by the user.

All that being said, it also requires some permissions to be built into the app, by placing them in the AndroidManifest.xml file, as you can see here:

[CODE]
<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android&#8221;
package=”com.alaskalinuxuser.gvc” >
<uses-permission android:name=”android.permission.ACCESS_SUPERUSER” />
<uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />

<application
android:allowBackup=”true”
[/CODE]

Notice the two “uses-permission” lines. The app has access to the superuser, and the permission to write (and consequently read) to/from files. Technically, I am not sure that I need the write permission, since the writing is done by the super user, however, I do need to read the file in question, so at a minimum, I would change this to READ_EXTERNAL_STORAGE.

I hope all of my scribbles make sense! Granted, there are probably much better ways to do this, and I hope to improve as I continue to build apps.

Linux – keep it simple.

Error:Gradle version 2.2 is required

In the continuing adventures of Android Studio and app development, I ran into yet another error while trying to import someone else’s work off of github:

[CODE]
Error:Gradle version 2.2 is required. Current version is 2.14.1. If using the gradle wrapper, try editing the distributionUrl in /home/alaskalinuxuser/AndroidStudioProjects/android_packages_apps_Trebuchet/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip.

Please fix the project’s Gradle settings.
[/CODE]

Sounds simple enough. So I opened /home/alaskalinuxuser/AndroidStudioProjects/android_packages_apps_Trebuchet/gradle/wrapper/gradle-wrapper.properties and this is what I saw:

[CODE]
#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
[/CODE]

Which I edited to say:

[CODE]
#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
[/CODE]

However, that was apparently not enough. It still didn’t work and said that the project did not have a gradle, and should be migrated to it. Odd…. I still haven’t figured out this one.

Linux – keep it simple.

Gitkraken!

As I continue to be blessed in the work of compiling roms and kernels, I have had to take a few new steps for me. One of those steps was Github. I am not very Github savvy, and I really struggled with how to push/pull/commit, etc. In fact, it was so daunting that I didn’t start posting source code and the like for my kernels or device trees, because I was unable to figure out how to make it work! Then I found a tool that actually made sense to me, Gitkraken.

Gitkraken is a program for your computer which allows you to easily work with Github repositories and files. Originally, I had forked an ArcTeam kernel repository for my personal edits, but I was strugling with the Github web interface. It was extreamly teadious to delete 30+ files, one at a time, online. Finally, I couldn’t take the web gui any more, and I began searching for computer programs that would make the interface easier. That’s when I found Gitkraken.

All I had to do was download the program from Gitkraken’s website: https://www.gitkraken.com/download , and intall it like any other Linux program from the command line:

[CODE]sudo dpkg -i gitkraken-amd64.deb [/CODE]

Note that they do not maintain a 32 bit version for Linux. They do have older versions of Gitkraken that are 32 bit, but those versions I tried do not look or work anything like the current version. Fortunately, my computer is 64 bit, so this was not a problem. Gitkraken is available for Windows and Macintosh also.

In either event, opening the program brought me to a somewhat straight forward setup screen, to which I filled in all of my Github account information. After getting set up, I wanted to open my repo. Gitkraken works with local repositories, and can push/pull them to the online Github, so the first thing I needed was my kernel repository. So I downloaded the zip file from Github for my repository (you don’t need to download each branch, just the master worked for me). I put it in a folder I appropriately named “github”, and unzipped it. I then realized I could simply choose to clone repo, and download it in one fell swoop!

Once that was done, I then opened that repository with Gitkraken, and that’s where things got a whole lot easier! Things that confused me before were now made so simple to comprehend, as I could visually see what was going on. Want to make a pull request? Sure, there’s a button for that. Want to compare each commit and see the code that changed? No problem, just click on one. It was that simple! Need to create a new branch? Absolutely, just click the button!

What really made a difference, though, was how easy it was to edit my files. Essentially, I just used a regular browser, made edits in my “github/kernelsource” folder directly to the files. Then, when I opened Gitkraken, it automatically parsed the files and found all of the new changes! All I needed to do was click the “stage”, “commit”, and “push” buttons, in that order, and presto, my online Github repository was up to date with my new changes!

Finally, a Github tool that is made the way it should be! Sleek, smooth, easy, with lots of functionality, but none of the technical heartburn!

Linux – keep it simple.