Saturday, April 24, 2021

Android 11 and Google Photos Permissions

 Got me a OnePlus 9 yesterday, which already comes with Android 11 installed. Migration of apps over there was rather smooth, many thanks again for LastPass, taking care of easily getting authenticated in all those newly (re-)installed apps.

Even moving those apps who are supposed to run on one device only, was quite easy this time. I'm speaking of authenticator apps (Microsoft and RSA) and the Banking apps.

What kept surprising me was that whenever I wanted to delete a photo in Google Photos I had to answer an additional "Allow Google Photos to ...".

I googled around and found that this was a side-effect of the new Android Scoped Storage that they finally implemented to get some more fine grained control over apps accessing the filesystem.

There is a nice article over at XDA Developers detailing this "issue" and the remedy.

OnePlus Gallery app is the owner of the photo storage area ("System Gallery") and not Google Photos (except on Pixel phones of course), but you can change that and make Google Photos the owner. 

The TL;DR: go to your pc, connect the phone and get out the adb.

adb shell cmd role add-role-holder android.app.role.SYSTEM_GALLERY com.google.android.apps.photos

Did the trick for me.

Monday, January 04, 2021

ISO compliant year-week function in DB2

 I've already shown how to create a year-month function in DB2, which - when it comes to date arithmatic - is quite straightforward, because very year (in ISO/Gregorian) calendar starts with the first month.

Some systems argue whether this should have the ordinal 1 or 0, but thats the usual 0/1 issue in programming.


Weeks however, are far more complex, because not every year starts with the begin of a week (whether this is Sunday or Monday in your preference / area).

It might just start with a Thursday... WOW.

So for that ths ISO 8601 standard set a definition on what is to be considered week 1 of a year:

The ISO 8601 definition for week 01 is the week with the first Thursday of the Gregorian year (i.e. of January) in it
Luckily, DB2 has a function for that - WEEK_ISO.

So let's just try that with a 

rtrim(char(year(TS))) || right(digits(week_iso(TS)),2)

Takes the year (need to rtrim it) and adds 2 digits week to it (you might want to insert a "w") between them.

However, this leeds to e.g. 2021-01-03 being in week 53, because week 1 start on 2021-01-04.

the yearweek for 2021-01-03 therefore should be 2020-53 not 2021-53 as the above formular would yield.

Now we need to make sure that if we get a week 53 and its January we return the previous year... Only for January, because some days in December might also be week 53, and we need to keep the year there.

Voila:

create function yearweek_iso(TS timestamp)
returns varchar(6) no external action deterministic 
return    
CASE

     WHEN (week_iso(TS)=53 AND month(TS)=1) Then
             
rtrim(char(year (TS)-1)) || right(digits(week_iso(TS)),2)   
     ELSE
              rtrim(char(year(TS))) || right(digits(week_iso(TS)),2)
END


The results now match whatever java.time package might do with week parsing. In order to get the first day of this week back (in Java, where I needed it), you parse as follow:

new DateTimeFormatterBuilder()
            .appendValue(IsoFields.WEEK_BASED_YEAR, 4)
            .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR,2)
            .parseDefaulting(WeekFields.ISO.dayOfWeek(), 1)
            .toFormatter();

Saturday, May 09, 2020

Windows 10 Folder Shortcuts

I have to admit, I did not know about that:

The shell: command can be used to open a special folder directly from the Start, Search menu or from the Run dialog. For example, the command shell:sendto opens the SendTo folder (%userprofile%\sendto) of your user profile. To launch the Documents folder of your user profile, you’d type shell:Personal. Below is a complete shell: commands listing for Windows 10/8/7/XP/Vista. The entire listing is stored in the following registry key in Windows Vista and higher:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\FolderDescriptions
So e.g. Windows-R and "shell:startup" opens the startup folder.
I used to play around with "%appdata%" etc etc where I knew there was an environment variable for it, but the shell: shortcut enables a lot more.

Found - amongst others - here 
and of course on superuser.com

Wednesday, January 08, 2020

How do I stop my Firestick from optimizing?

Well, the other day I noticed that my USB charging cable for my Amazon Fire Stick was broken. So I just dug into my USB cable carton and get the next best USB micro charger and replaced the broken one.
Done.

I thought.

A couple of days later I found the stick busy  "Optimizing systems storage and applications...", letting me know "This will take approximately 10 minutes to complete.".
Fair enough... You do your thing then...

Well, it never completed, Even rebooting did not help.

Image result for have you tried turning it off and on again

So I googled, and found a bunch of useless videos, that show you the stuck message for minutes and complain about the stick being stuck... and that not even Alexa would work.  No sh$t, Sherlock.


Oddly enough, the cause (as those google searches revealed) was related to me changing the power supply/cable. Shouldn't have picked the cheapest one.
Went back to the USB cable box, took a more expensive looking cable, and - voila - after completing the optimization the stick is now back running as it should.

And I just saved you half an hour of your life watching those not-really-helping videos.
You're welcome.

Tuesday, October 29, 2019

Google .new shortcut for Calendar

Just found this on engadget.

If you type in cal.new or meeting.new in the address bar (sorry, awesomebar, or whatever it is called these days), it will directly re-direct you to the page/dialog to create a new calendar entry for your google calendar.

Seems to have been around for google docs for a while now, but I don't really create a lot of them, compared to calendar entries.

Nice use of TLDs ;)


Saturday, February 02, 2019

Google Photos from OnePlus Camera

The latest update on my OnePlus 5T (to Android P) make OnePlus Gallery the app that opens when you click on the gallery/image icon at the lower right corner.


Just setting Google Photos as the default app does not change that...
You have actually disable the Gallery app.

To do this, go to the phone's settings, and the applications menu there.
Find the Gallery app, and click on the Disable button.


From then on, the camera will open the default app for photos, which you should make sure to set to Google Photos.

Saturday, December 15, 2018

Finally LastPass Autofill on iOS

I have to admit that I don't know how long this has been there, I just noticed it last week.
iOS (on my iPad) can finally use LastPass
(my favorite password manager) in addition to it's own keychain.

All you have to do (besides of course having a LastPass account and having the LastPass app installed on your device) is the following.

Go to the Settings menu, and find the section "Passwords & Accounts".
There you will see the item "AutoFill Passwords". Touch on the arrow to the right to get to the next step.

.

You should see all installed AutoFill applications there, in my case Keychain and LastPass.



All you need to do here, is select the check mark to the right to enable it.

Depending on your LassPass vault and settings, on the next Login (app or web-page), you will be given a choice to select the credentials from your LastPass account. In my case I have to provide a fingerprint first... but that's it.



Pretty cool. Essentially the same as with Keychain, just accross platforms. That's why I use LastPass.

Saturday, September 23, 2017

How to get a year-month value in DB2

I quickly needed to check the monthly progress of a certain variable over time. Problem was that those bookings/incomes are spread over the month, sometimes only one booking line, sometimes two... So I needed a grouping variable, that the "absolute month", i.e. the usual year-month value,that you know from financial system, e.g. 201709 for this current month.

Here's the easy way to put that into a function on DB2:

create function yearmonth(TS date) returns varchar(6) no external action deterministic return rtrim(char(year(TS))) || right(digits(month(TS)),2)

Then you can easily do a group by yearmonth(date).
(Don't omit the "not external action" and "deterministic" parts, because a) they are true and b) they are needed for grouping)

Of course you don't have to create a function for this, but easier then re-typing it, or creating a view.

(You might want to create the same function for timestamp as well... just so happened that I now only needed it with the date signature).

You're welcome :)

Sunday, July 02, 2017

Instagram is weird...

So I posted two (only 2 !!) pictures of a garden on instagram, and all of a sudden I get dozens of followers with garden-related accounts/names. I did not even tag those images as garden-something....


Weird


.

Sunday, April 23, 2017

OnePlus One with Lineage OS

So, haven't posted here in a while... sorry 'bout that... Here's what happened most recently:

My Nexus 5X decided to get stuck in a bootloop (like most others in the world). Started with random reboots a couple of weeks ago, and then, one day after I upgraded to Android 7.1.2, on the way to a friend, it decided to no longer even go into the recovery mode. Totally offline.

Luckily, this very friend of mine, had a spare OnePlus One with CM on it, which I'm now the proud owner of. Since we went for a quick vacation in Lisbon just days after the bootloop incident, I decided just to move the most important data and apps on the OnePlus One (OPO from here-on) and properly set it up after the vacation.

That's what I did yesterday. Flash it with Lineage OS 14.1 and gApps. Right after the reboot it offered to re-installed apps (and quite a lot of settings) from the last backup of the Nexus 5X.
Since I had no recent backup (adb backup) of my Nexus 5X (I should have seen the crash coming, shouldn't I...) and I could not even get into recovery mode (to pull a new adb backup) that was the only thing I could rely on.  LastPass again helped me to sign into those apps really fast, and a couple of hours later I was up and running with OPO+LIN14.1

The two most cumbersome steps on the 2 hop migration (there was the minimum install on CM two weeks ago) was my Banking app, since both times I had to call my bank to reset the default device for the mobile TAN security feature (should have known this yesterday, but then again, just a 2min call to the bank, even off-hours... real good customer service, I have to admit),  and the RSA token app I have to use for authentication for my company (vmware); that needed re-initialisation with the help from the help desk as well.

So frist thing: have a backup of the new device ... CHECK.

And again: Thanks, Max, for the fast help with the OPO...

Friday, April 15, 2016

Even more speed, speed, speed

Just two weeks after I upgraded my DSL line to 100/20 Mbps, my employer was nice enough to move our mobiles to a new contract where we finally have LTE/4G included.

116 M down/ 41 M up

Wow... that was from my Nexus 5 this afternoon in Vienna, i.e. I was not looking for an "empty" cell during off-peak hours... pretty good.

Sunday, April 10, 2016

Speed, speed, speed

After a chat with a friend (and former colleague of mine) I decided to trust my telco (A1 Telekom) to upgrade to a higher speed, though I only got 12 Mpbs down on my 16Mbps ADSL line because of the age-old copper lines.

I called them, they checked the line and told me that they could guarantee 92Mbps if I go for the 100Mbps option (VDSL).

So I did. Got a new modem (TG 588v), plugged it in and interestingly already for 14Mbps though I only had 12 with the old modem (same line, still ADSL). Then a couple of days later (as announced) they changed my line on the switch/exchange and now I'm running almost 100 down (and 20 up).

With two kids in the house, netflix, two tablets and four smart phones... it was overdue to say the least.

So finally I can work while everyone else is watching Netflix (or the other way round).

Sunday, February 21, 2016

MWC 2016 - need to go offline

So, as every year, just after CES the Mobile World Congress in Barcelona is starting right now. Time to go offline for a week... or be bored to death with all the new phone, screen, GHz, multicore and VR announcements.

Saturday, January 30, 2016

Google Play Services networking error > Phishing?

Last week my son approached me, because his Samsung all of a sudden started to show networking errors for YouTube, the PlayStore and G+ app.  Connectivity was fine, we switched from 4G to Wifi and back, with no change (he would not have asked me for a pure/true connectivity issue). The Youtube app itself worked fine and played videos, he just could not log in with his Google account.
So no wonder this problem exists across several google services/apps, but nothing else.

Opening google.com/youtube.com in the browser also showed no problem, so definitely not a networking, dns, routing... problem.

I did some googling and found (apart from nonsense like "turn on wifi"...) some hints about a broken hosts file.  So I adb'd into the device from my computer, pulled the /system/etc/hosts file:
127.0.0.1    localhost
127.127.120.139 android.clients.google.com
With a hint from the ever-helpful stackexchange and the fine coincidence that he (or was it me?) rooted his phone sometime in the past, I was able to shell in, su to root, mount the file system as read-write, comment out that last weird line (for android.clients.google.com) and change the file system back to read only. Check the details on this post on stackexchange.

And then it worked.

This looks suspiciously like a phishing attempt by some malware, that managed to manipulate the hosts file to get the google password. So thirst thing after fixing this, chance the password.
Next thing, find that f*ing app that did this.

That's the downside of having rooted your phone. So finding the phone rooted was not such a coincidence after all. 

Thursday, December 31, 2015

What happened 2015?

So, as you noticed, I did not really blog a lot this year, i.e. 2015.
Let me quickly recap what I was busy with in the last couple of month (lame excuse, I know).

In summer I changed job from Oracle to vmware. Still handling the channel/partner business, but now no longer for (boring) hardware, but for - to me - exiting software. The concept of the software defined datacenter - or SDDC for short - is something I really like. Virtualize everything. Move from on-premise to cloud(s) seamlessly... pretty cool I think.

Enough of the professional plug.
I still found time for some nice hacks at home.

I've been recording my electricity and gas consumption at home for years, nay, decades now. What started with a plain ascii file in the early 90s, turned in to a DB2 application on OS/2 (with visual REXX) , and then to a very rudimentary web application (against the same DB2 database) under Windows XP and 7. Over the years I slightly modified the web application to also be mobile friendly, so I could take my phone (Nexus 5 right now) or iPad and enter the data while I was reading the meter.
Did I mention that I'm a nerd and do this weekly? No?
Well perhaps I should.
Not very interesting from a hack perspective, is it?

So this year I decided to change this, and I

  1. created an Android app for it
  2. added the anyline meter reading to it (because I did not want to get into the OCR stuff myself)
  3. created a REST interface to my database (building upon the old web application I had), using Jersey.
Two really impressive things here. Anyline... check it out. Excellent meter reading SDK (and other OCR stuff) on iOS and Android. 
And Jersey, wow!! REST with the click of a button, yet you are still in full control. And also getting JSON and XML with the same code. Nice.

Now for step 4 I'll re-write the old web-app to a pure Ajax/jQuery/JSON thing, and will only keep the REST interface to the database.

And step 5, already started: I bought some NFC tags (from whiztags, thanks for the hint, Max). One will go to the gas meter, the other one to the electricity meter, and both are registered to my app on Android. So when I go near the meter, it will automatically open the app with the OCR scanner for the respective meter. Click, and done.

So that's the last half year - or so - in a nutshell.

Sunday, November 22, 2015

NetBeans and DB2 again

So for various reasons (mainly the 64bit v 32bit problem with the native driver) I changed my DB2 JDBC driver to type 4, i.e. the Universal driver.
However, when I connect from NetBeans with an URL like jdbc:db2://localhost:50000/sample the schema would stay empty.
Nothing. Zip. Zilch. Zero.
Nada.
Quite some googling and debugging - mainly with a little java program like this:

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;


public class MainDB2 {
    
    private static final String URL = "jdbc:db2://localhost:50000/SAMPLE";
    private static final String USER = "roman";
    private static final String PASSWORD = "pwd";
    private static final String SCHEMA = "roman";
    
  public static void main(String[] args) throws Exception {
        Class.forName("com.ibm.db2.jcc.DB2Driver");
        Connection conn = DriverManager.getConnection(URL, USER, PASSWORD);
        try {
            DatabaseMetaData dmd = conn.getMetaData();
            ResultSet rs = dmd.getTables(null, SCHEMA, "%", new String[] { "TABLE" });
            try {
                while (rs.next()) {
                    int count = rs.getMetaData().getColumnCount();
                    System.out.println("Column count: " + count);
                    int i;
                    for (i = 1; i <= count; i++) {
                        try {
                            System.out.println(rs.getString(i));
                        } catch (SQLException e) {
                            System.err.println("Exception reading column " + i);
                            e.printStackTrace();
                        }
                    }
                    System.out.println();
                }
            } finally {
                rs.close();
            }
        } finally {
            conn.close();
        }
    }
}



I was able to trace it back to an SQLCODE -443SQL0443N with diagnostic text "SYSIBM:CLI:-805". SQLSTATE=38553. Google this and you will get to here and learn that - again - a package was not bound, this time the db2schema.bnd file. Bind it as suggested in the article with the usual db2 bind db2schema.bnd blocking all grant public

and voila, NetBeans will find the schema.

Gets me every second year, it seams.

Friday, September 25, 2015

The iOS9 Podcast app is totally broken

Usually I hate and hence avoid to slam an app or service like this, but the podcast player in iOS9 really sucks. At least for video on an iPad.

No full screen video anymore, too much white space, and even with all that unused space, the controls are too small

Exhibit A:

Please Apple, we need an urgent update to fix/revert this.

Sunday, September 13, 2015

How to hide a userid from Windows login screen

With DB2 on my home PC[1] I have a service account for the DB2 instance, makes life a lot easier than trying to map it to you actual user(s).

However, regular Windows (Home) setup has 2 defaults that are annoying:
a. password and account expiry for this user.
b. the userid appears on the Windows login/lock screen, although nobody is supposed to sign in with it.

Create a maintenance free user
The first issue I fixed a couple of month ago, because that was really annoying. Because DB2 just would not start. And the first two times this happened I had to work through db2diag.log to find out what happened.
So, make sure the account actually never expires (that's separate from the password). With admin privileges run
  net user db2admin [2]
to check if the user account expires.
If it does, then run a
  net user db2admin /expires:never
to fix this.

The password expiration is trickier, since it cannot be done with the net user command.
To make the password everlasting, run
  WMIC USERACCOUNT WHERE "Name='db2admin'" SET PasswordExpires=FALSE

I found this thanks to the folks at StackExchange.

Hide the service account from the login screen
I wanted to do this on Windows 7 already, but never found the time or cared enough. Now with the move to Window 10 I thought of it again and fixed it.
So this can be done with group policies and stuff, but not on a standalone Windows Home edition.

Registry and Microsoft Technet to the rescue:

Create an entry under
  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList and list the db2admin user with a dword (32) of 0 to hide it. Remove the entry or set it to 1 to show the user again.

Voilà.

--
[1] Ha, now that I no longer work for Oracle, I can again freely admit it... Not that I really held back on this in the past 5 years.
[2] replace db2admin with the userid you need this for

Saturday, September 12, 2015

Windows 10 installed

While I finally made it to a Mac (MacBook Air 13) at work, I gave in and let Microsoft install Windows 10 over my Windows 7 on my home PC.

It went surprisingly smooth and without any problems.
Except that my Tomcat did successfully start under Window 10, because for some weird reasons Redmond decided to install and activate the Internet Information Services (which I previously did not have), and those blocked port 80 of course.
Simple de-install of those features, reboot and everything was running fine again. All apps and services I had running (or those I could think of within 30minutes) are running fine again.
Amazingly even my DB2 instance did not create any problems at all.

Now I only have to get used to the new UI, but even that seems easier than I thought.... well, as long as I have the keyboard.