Wednesday, May 24, 2017

How to detect Dual SIM using Android shell ?


getprop persist.radio.multisim.config returns "dsds" or "dsda"   on multi sim Samsung devices

source: https://android.googlesource.com/platform/frameworks/base/+/master/telephony/java/com/android/internal/telephony/TelephonyProperties.java


    public static Boolean isDualSimModel() {
        return (Boolean.valueOf("dsds".equals(SystemProperties.get("persist.radio.multisim.config")))                    Boolean.valueOf("dsda".equals(SystemProperties.get("persist.radio.multisim.config"))));
    }

Tuesday, January 24, 2017

How to install letsencrypt ssl certificate on nginx without Unable to locate package letsencrypt error

Today, I thought of moving some of the websites to ssl. so I looked up for a guide on Google and most of them says

sudo apt-get install letsencrypt


but it ends with

E: Unable to locate package letsencrypt

So, I had to go back to the original repo to fix this problem.


git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
./letsencrypt-auto --help

this will show the help. If you are trying to configure to run on nginx.

 sudo ./letsencrypt-auto --nginx

and then select the website number. Make sure you do not have anything running on port 443 now.

Wednesday, December 21, 2016

How to setup Android Studio for Java 8

Today, I wanted to move one of the project I was working on to Android Studio 2.2 to support Java 8. It's kind of amazing there is not enough information about how to convert an existing project to support Android Studio + Java 8.

1. In your project build.gradle add classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'  So it should be like this

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'me.tatarka:gradle-retrolambda:3.2.3'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

2. In your Module build.gradle add

apply plugin: 'me.tatarka.retrolambda'

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}


apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        ..
    }
    buildTypes {
        ...
    }
     
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
dependencies {
 ....
}



Wednesday, November 2, 2016

How to fix Arduino WeMos D1 (platform esp8266, package esp8266) is unknown error

fix this go to the folder:

C:\Users\[username]\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\

delete the older version folder and everything works fine again.

Monday, October 3, 2016

Deploying CefSharp with ClickOnce and Could not load file or assembly 'CefSharp.Core.dll

Could not load file or assembly 'CefSharp.Core.dll

oh boy, it is a pain in the ass.

It all started when I decided to use CefSharp in my application. Problem was I was deploying my app though MS ClickOnce and deploying CefSharp and it's dependencies is a pain.

1st lesson

Do not add CefSharp and Xilium.CefGlue to the project. They both use different versions of 'CefSharp.Core.dll' and when you deploy they replace 'CefSharp.Core.dll' with different version rather than the one you used for developments.

2. When you install CefSharp, install cef.redist.x64 and cef.redist.x86 via Package Manager

3. We need to modify the project to

1. Deploy CefSharp and it's all dependancies

2. Deploy CefSharp runtime. Which is  VC++ 2013 for 51.0.0.0

To do that:

 Unload the main project. Right click -> Edit. Just before </project> past following code

<!-- Copy CEF Stuff-->
  <ItemGroup>
    <Content Include="$(SolutionDir)packages\cef.redist.x86.3.2704.1432\CEF\**\*" Exclude="$(SolutionDir)packages\cef.redist.x86.3.2704.1432\CEF\x86\**\*;$(SolutionDir)packages\cef.redist.x86.3.2704.1432\CEF\locales\**\*.pak">
      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
    <Resource Include="Readme.txt" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="$(SolutionDir)packages\cef.redist.x86.3.2704.1432\CEF\**\en-GB.*;$(SolutionDir)packages\cef.redist.x86.3.2704.1432\CEF\**\en-US.*">
      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <Content Include="$(SolutionDir)packages\cef.redist.x86.3.2704.1432\CEF\x86\**\*">
      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <Content Include="$(SolutionDir)packages\CefSharp.Common.51.0.0\CefSharp\x86\**\CefSharp.BrowserSubprocess.*">
      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>
  <!-- Copy C++ 13 x84 redistributables  -->
  <ItemGroup>
    <Content Include="$(ProjectDir)..\External\Microsoft.VC120.CRT\**\*">
      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>

Note that this project is using cef.redist.x86.3.2704.1432, If you are using x64 you have to modify the above script.

You need to copy Microsoft.VC120.CRT from C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x64\Microsoft.VC120.CRT to a local folder and change "$(ProjectDir)..\External\Microsoft.VC120.CRT\**\*"