Android Phones – Bulk Configuration

Recently I was tasked with configuring 27 Android smart phones for various people spread across the country. These phones were a mixture between Samsung Galaxy A3’s, A3 2006 version, S6 and S7 Edge models all supplied by EE.
Rather than hand out these phones un-configured and expect the users to set them up themselves I took it upon myself to have them as ready as possible. This involved removing or hiding the pre-installed bloatware and installing a few extra apps.

To do this on the cheap (read: free) you will need:

  • The Android Debug Bridge (ADB) from here.
  • Drivers for your phone. As we’ll have the phone in debug mode the normal Windows drivers aren’t enough. Google’s OEM device driver list.
  • A method of gaining the .apk file for the apps you want to install. An existing Android phone with an app backup app or a website such as APK Mirror will do.
  • A batch file you can run quickly and easily for each phone which I’ll go into later.

Next:

  1. Run through the phone’s initial configuration wizard. I skipped everything apart from joining the wifi.
  2. Make sure the phone is running the latest firmware version.
  3. Enable Developer Options by tapping repeatedly on the “Build Number” option under “About phone”.
  4. Turn on USB Debugging in the Developer Options menu, connect the phone to your computer and trust the device.

Now, open a command prompt and type: adb devices and you should get the phone’s serial number with “device” beside it. This means adb is working properly, if you don’t get anything listed check you’ve got the drivers installed properly. It’s always the drivers :).

adbdevices

Now we can start doing the fun stuff!

adb shell pm list packages -f

Lists all of the packages and their associated file. There will be masses of stuff here and may be truncated so you can output the results to a text file for easy searching:

adb shell pm list packages -f > packages.txt

In my case I wanted to uninstall various apps but unfortunately as carriers bake apps into their ROMs they can only be disabled/hidden. This has the effect of hiding the icon from the app drawer so your users should be none the wiser.
Once you’ve found the package’s name you can do the following:

adb shell pm hide com.facebook.katana

Which will hide the Facebook app.
Make a list of each package you want to hide but be careful not to hide any system packages as this can cause problems. Something to note here is that if you specify a package that does not exist or make a spelling mistake it will still return “hidden: true” so make sure it really is hidden!

Next, grab the .apk files of the apps you want to install. ADB should be in your environment path variable, otherwise put the apk’s in the folder beside ADB.

adb install AdobeAcrobat_16.2.apk

Will install Adobe Acrobat.

You can use: adb push file.ext /mnt/sdcard/directory/file.ext to copy files to the phone. I used this to copy our corporate branded wallpaper.

Finally, compile all the bits and pieces together into a simple Windows batch file, as below:

@ECHO OFF
adb devices
pause
REM This gives you a chance to ensure the phone
REM is properly detected and quit if not.

adb shell pm hide uk.co.ee.myee
adb shell pm hide com.amazon.mp3
adb shell pm hide com.dropbox.android
adb shell pm hide com.facebook.katana
adb shell pm hide com.instagram.android
adb shell pm hide com.amazon.kindle
adb shell pm hide com.lookout
adb shell pm hide uk.amazon.mShop.android
adb shell pm hide com.microsoft.skydrive
adb shell pm hide com.samsunguk.mygalaxy
adb shell pm hide com.sec.android.widgetapp.samsungapps
ECHO Bloatware hidden

adb install AdobeAcrobat_16.2.apk
adb install Excel_16.0.7127.1010.apk
adb install Outlook_2.1.43.apk
adb install Word_16.0.7127.1010.apk

adb push wallpaper.jpg /mnt/sdcard/directory/wallpaper.jpg

adb reboot

So there you go. It’s not elegant and still requires some manual intervention but it should save you a fair bit of time.