Monday, July 5, 2021

Debian Buster: install all in one hp ink tank 315

 

Detect hp ink tank 315 detected by system

# dmesg
...
[   66.017856] usb 3-2: new high-speed USB device number 2 using xhci_hcd
[   66.170313] usb 3-2: New USB device found, idVendor=03f0, idProduct=1053, bcdDevice= 1.00
[   66.170319] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   66.170322] usb 3-2: Product: Ink Tank 310 series
[   66.170324] usb 3-2: Manufacturer: HP
[   66.170326] usb 3-2: SerialNumber: CN83B2G1YK06PH
[   66.198225] usblp 3-2:1.1: usblp0: USB Bidirectional printer dev 2 if 1 alt 0 proto 2 vid 0x03F0 pid 0x1053
[   66.198300] usbcore: registered new interface driver usblp

Install CUPS and hplip

# apt-get install system-config-printer hplip cups hplip-ppds  

If CUPS error

# tail /var/log/cups/error_log
X [09/Jun/2021:13:20:46 +0700] No valid Listen or Port lines were found in the configuration file.

Edit /etc/cups/cupsd.conf

# vi /etc/cups/cupsd.conf
Listen 127.0.0.1:631

Configure printer via Browser http://localhost:631/

  1. Administration -> Add Printer
  2. HP Ink Tank 310 series USB CN83B2G1YK06PH HPLIP (HP Ink Tank 310 series), Next
  3. Continue
  4. Model: HP Ink Tank 310 Series hpijs, 318.12 (en), Add Printer
  5. Filled User Name with root and its password, Ok

Install XSane for scanner

# apt-get install xsane sane-utils

Detect hp ink tank 315 scanner

# lsusb
Bus 004 Device 002: ID 03f0:1053 HP, Inc
# sane-find-scanner

  # sane-find-scanner will now attempt to detect your scanner. If the
  # result is different from what you expected, first make sure your
  # scanner is powered up and properly connected to your computer.

  # No SCSI scanners found. If you expected something different, make sure that
  # you have loaded a kernel SCSI driver for your SCSI adapter.

found USB scanner (vendor=0x03f0 [HP], product=0x1053 [Ink Tank 310 series]) at libusb:004:002
  # Your USB scanner was (probably) detected. It may or may not be supported by
  # SANE. Try scanimage -L and read the backend's manpage.

  # Not checking for parallel port scanners.

  # Most Scanners connected to the parallel port or other proprietary ports
  # can't be detected by this program.

Try your scanner

# scanimage -L
device `hpaio:/usb/Ink_Tank_310_series?serial=CN83B2G1YK06PH' is a Hewlett-Packard Ink_Tank_310_series all-in-one

or

$ scanimage > image.pnm

To install driver print to pdf

# apt-get install printer-driver-cups-pdf

Wednesday, May 19, 2021

Android Studio: generate apk for ApkPure

 

You can upload your application to 3rd party like apkpure:

https://apkpure.com/submit-apk

In Anroid Studio 4, Compile option are:

  • APK
  • V1 (Jar Signature) checked
  • V2 (Full APK Signature) checked

Start Upload

  • Package Name    : com.example.com
  • What's new    : update
  • Your Name    : developer_name
  • Your Email    : developer_email@example.com

Android java: play-services-ads 20.1.0 and gradle 6.5+

 

We are going to

  1. implementation 'com.google.android.gms:play-services-ads:20.1.0'
  2. java compile with xlint to check deprecation api
  3. gradle 6.5+

Edit build.gradle project

...
buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
...
allprojects {

    repositories {
        jcenter()
        google()
    }

    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:deprecation"
        }
    }
}
...

Edit build.gradle(:app)

...
android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"
...
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.3.0'
    implementation 'com.google.android.gms:play-services-ads:20.1.0'
}
...

Edit AndroidManifest.xml

<manifest>
...
    <application>
    ...
        <!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
...


# main_activity.xml
...
    <!-- 20210220 -->
    <android.widget.FrameLayout
        android:id="@+id/adContainerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/scroll_view"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        />
...


Edit MainActivity.java

...
    private FrameLayout adContainerView; // 20210220
    private AdView adView;
...  
    private Handler myHandler = new Handler(Looper.getMainLooper()); // new Handler() deprecated 20210220  
...

    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      ...
      MobileAds.initialize(this, new OnInitializationCompleteListener() {
         @Override
         public void onInitializationComplete(InitializationStatus initializationStatus) {
         }
      });
      adContainerView = findViewById(R.id.adContainerView);
      // Step 1 - Create an AdView and set the ad unit ID on it.
      adView = new AdView(this);
      // Banner test = ca-app-pub-3940256099942544/6300978111
      adView.setAdUnitId("ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"); // CHANGE IT
      adContainerView.addView(adView);
      loadBanner();
      ...
    }

    // 20210220 start
    private void loadBanner() {
        // Create an ad request. Check your logcat output for the hashed device ID
        // to get test ads on a physical device, e.g.,
        // "Use AdRequest.Builder.addTestDevice("ABCDE0123") to get test ads on this
        // device."
        //AdRequest adRequest = new AdRequest.Builder().addTestDevice("ABCDE0123").build();
        AdRequest adRequest = new AdRequest.Builder().build();

        AdSize adSize = getAdSize();
        // Step 4 - Set the adaptive ad size on the ad view.
        adView.setAdSize(adSize);


        // Step 5 - Start loading the ad in the background.
        adView.loadAd(adRequest);
    }

    private AdSize getAdSize() {
        // Step 2 - Determine the screen width (less decorations) to use for the ad width.
        //Display display = getWindowManager().getDefaultDisplay(); // deprecated 20210220

        DisplayMetrics outMetrics = new DisplayMetrics();
        // display.getMetrics(outMetrics); // deprecated 20210220
        outMetrics = getApplicationContext().getResources().getDisplayMetrics(); //

        float widthPixels = outMetrics.widthPixels;
        float density = outMetrics.density;

        int adWidth = (int) (widthPixels / density);

        // Step 3 - Get adaptive ad size and return for setting on the ad view.
        return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth);
    }
    // 20210220 end
...

Tuesday, March 30, 2021

Evercoss Genpro X Pro S50 removing malware Android.Downloader.4930 /system/lib/libcheckperlib.so

 

Requirement:

  • rooted android or temporary root using mtk-su create by Diplomatic
  • pc with adb or Termux

This are steps to remove malware Android.Downloader.4930 /system/lib/libcheckperlib.so using Termux created by Grey Tshirts:

  1. Create these bash script and save it as s50_patch2021.sh
    #!/system/bin/sh

    FILE="/system/lib/libcheckperlib.so"

    echo "checking $FILE"

    if [ -f $FILE ]; then
     echo "File $FILE exists."
     echo "Try remount system rw."
     /system/bin/mount -o rw,remount /system
     echo "Backing up $FILE."
     /system/bin/mkdir /sdcard/dedetok
     /system/bin/cp $FILE /sdcard/dedetok
     echo "Removing $FILE"
     /system/bin/rm $FILE
     echo "Remount system ro"
     /system/bin/mount -o ro,remount /system
     echo "Done, reboot your Evercoss S50"
    else
     echo "File $FILE does not exist."
    fi
  2. Or you can download it from this site. Open Termux and type
    $ wget http://garasiku.my.id/folder/S50_patch2021.sh.txt
  3. rename it
    $ mv ./S50_patch2021.sh.txt ./S50_patch2021.sh
  4. change permission
    $ chmod 744 ./S50_patch2021.sh
  5. run mtk-su and run the cript
    # ./S50_patch2021.sh
  6. reboot your phone

Don't forget to run your antivirus after reboot your phone. android is not save operating system.

Android: How to backup your google contact when your account has been deleted by google

 

If your google account was blocked or deleted by google, Do not immediately remove your account. We need google account to backup our contact from old device into new device.

Backup your contact

  1. Open google contact
  2. Goto settings -> Export
  3. Leave name as contacts.vcf and save. It will backup all of your existing contact into Download folder on your device.

Create new google account

  1. Open Settings for your phone
  2. Goto Accounts -> Add account -> Google
  3. Fill all required data, for example dedetoke@gmail.com

Move your contact into your new google account

  1. Open google contact
  2. Tap on top right image profile and change your contact to your new google account for example dedetoke@gmail.com
  3. Goto settings -> Import
  4. Select .vcf file and choose your new google account for example dedetoke@gmail.com
  5. select contacts.vcf from Download folder
  6. Follow instruction until import finish
  7. Done, your contact will be backup into your new google account.

For whatsapp, if you want to save your chat you need to change your backup into your new google account.

You can do this, anytime google blocked or deleted your account, simple create a new account and let your dead email keep by google.