[MOD]Allow Unknown Sources By Default

Search This thread

Digitalkarma

Senior Member
Feb 3, 2011
959
1,717
After searching months for a way to allow Unknown Sources by default on the HTC One, I've finally discovered where to mod it so I thought I would share for the benefit of the community. Its one of the more convenient mods to have and I thought it would be a great for lazy people like me who want to quickly restore their setup while trying other roms and not have to deal with Blocked install messages lol.

You will need to have apktool or similar tools and decompiling knowledge before attempting this.

Previously you would need to mod SettingsProvider.apk but on Sense 5 that is no longer the case. There are two APK's to look at here. PureC_PackageInstaller and Settings.apk. PureC is the main one you want to look at.

Decompile PureC_PackageInstaller and find this directory in smali folder:
\smali\com\android\packageinstaller\PackageInstallerActivity.smali

open up PackageInstallerActivity.smali and look for this method:

Code:
.method private isInstallingUnknownAppsAllowed()Z
    .locals 3

    .prologue
    const/4 v0, 0x0

    .line 261
    invoke-virtual {p0}, Lcom/android/packageinstaller/PackageInstallerActivity;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    const-string v2, "install_non_market_apps"

    invoke-static {v1, v2, v0}, Landroid/provider/Settings$Secure;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v1

    if-lez v1, :cond_0

    const/4 v0, 0x1

    :cond_0
    return v0
.end method

change
Code:
    .locals 3

    .prologue
    const/4 v0, 0x0

    .line 261

to this
Code:
    .locals 3

    .prologue
    const/4 v0, 0x1

    .line 261

recompile and you are done

next decompile Settings.apk(optional!)
the only reason to edit this is to give the mod the appearance that Unknown Sources is visibly checked in Settings menu, otherwise the mod still works fine even if it isn't checked.

find this directory:
\smali\com\android\settings\SecuritySettings.smali

locate this method:
Code:
.method private isNonMarketAppsAllowed()Z
    .locals 3

    const/4 v0, 0x0

    invoke-virtual {p0}, Lcom/android/settings/SecuritySettings;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    const-string v2, "install_non_market_apps"

    invoke-static {v1, v2, v0}, Landroid/provider/Settings$Secure;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v1

    if-lez v1, :cond_0

    const/4 v0, 0x1

    :cond_0
    return v0
.end method

change the 0x0 to 0x1, and change the 0x1 to 0x0.
recompile and your done.

tested this and working on Sprint HTC One variant, but i'm almost certain this should work on any carrier with version of Sense 5.

also of note: there is a small glitch to this mod while toggling the checkbox on and off. it'll recheck itself if you turn it off and come back to the options screen again. Plus, I turned off the disabled function completely as a temporary solution because there was another glitch where you couldn't install apps while it was checked on if you messed around trying to turn it off, but why would you want to? lol
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 16
    After searching months for a way to allow Unknown Sources by default on the HTC One, I've finally discovered where to mod it so I thought I would share for the benefit of the community. Its one of the more convenient mods to have and I thought it would be a great for lazy people like me who want to quickly restore their setup while trying other roms and not have to deal with Blocked install messages lol.

    You will need to have apktool or similar tools and decompiling knowledge before attempting this.

    Previously you would need to mod SettingsProvider.apk but on Sense 5 that is no longer the case. There are two APK's to look at here. PureC_PackageInstaller and Settings.apk. PureC is the main one you want to look at.

    Decompile PureC_PackageInstaller and find this directory in smali folder:
    \smali\com\android\packageinstaller\PackageInstallerActivity.smali

    open up PackageInstallerActivity.smali and look for this method:

    Code:
    .method private isInstallingUnknownAppsAllowed()Z
        .locals 3
    
        .prologue
        const/4 v0, 0x0
    
        .line 261
        invoke-virtual {p0}, Lcom/android/packageinstaller/PackageInstallerActivity;->getContentResolver()Landroid/content/ContentResolver;
    
        move-result-object v1
    
        const-string v2, "install_non_market_apps"
    
        invoke-static {v1, v2, v0}, Landroid/provider/Settings$Secure;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
    
        move-result v1
    
        if-lez v1, :cond_0
    
        const/4 v0, 0x1
    
        :cond_0
        return v0
    .end method

    change
    Code:
        .locals 3
    
        .prologue
        const/4 v0, 0x0
    
        .line 261

    to this
    Code:
        .locals 3
    
        .prologue
        const/4 v0, 0x1
    
        .line 261

    recompile and you are done

    next decompile Settings.apk(optional!)
    the only reason to edit this is to give the mod the appearance that Unknown Sources is visibly checked in Settings menu, otherwise the mod still works fine even if it isn't checked.

    find this directory:
    \smali\com\android\settings\SecuritySettings.smali

    locate this method:
    Code:
    .method private isNonMarketAppsAllowed()Z
        .locals 3
    
        const/4 v0, 0x0
    
        invoke-virtual {p0}, Lcom/android/settings/SecuritySettings;->getContentResolver()Landroid/content/ContentResolver;
    
        move-result-object v1
    
        const-string v2, "install_non_market_apps"
    
        invoke-static {v1, v2, v0}, Landroid/provider/Settings$Secure;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
    
        move-result v1
    
        if-lez v1, :cond_0
    
        const/4 v0, 0x1
    
        :cond_0
        return v0
    .end method

    change the 0x0 to 0x1, and change the 0x1 to 0x0.
    recompile and your done.

    tested this and working on Sprint HTC One variant, but i'm almost certain this should work on any carrier with version of Sense 5.

    also of note: there is a small glitch to this mod while toggling the checkbox on and off. it'll recheck itself if you turn it off and come back to the options screen again. Plus, I turned off the disabled function completely as a temporary solution because there was another glitch where you couldn't install apps while it was checked on if you messed around trying to turn it off, but why would you want to? lol
    3
    You can also just edit the default.xml in customize

    <item name="def_install_non_market_apps">1</item>

    Sent from my HTCONE using Tapatalk 2
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone