-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
206 lines (195 loc) · 4.76 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
* AndroFree
* by Navin Chandniya
*/
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
void listPkg(int x);
string getPkg(int x);
void searchPkg();
void disablePkg();
void uninstallPkg();
string getVendor();
void disableBloat();
void uninstallBloat();
int main()
{
int choice;
cout << "Fetching installed packages on your android device, please be patient...";
system("adb shell \"pm list packages | sort\" > .\\allPackages.txt");
system("adb shell \"pm list packages -3 | sort\" > .\\3rdPartyPackages.txt");
system("cls");
ifstream pkgFile;
pkgFile.open("allPackages.txt");
if(pkgFile.peek()==EOF) {
pkgFile.close();
cout << "\nNo ADB connections detected, exiting...\n";
return 0;
}
while(1)
{
cout << "\n\n\tANDROID DEBLOATER\t";
cout << "\n\n1. List all packages installed.";
cout << "\n\n2. List all third-party packages installed.";
cout << "\n\n3. List all safe-to-remove packages.";
cout << "\n\n4. Search a package.";
cout << "\n\n5. Disable a package.";
cout << "\n\n6. Uninstall a package.";
cout << "\n\n7. Disable recommended bloatware.";
cout << "\n\n8. Uninstall recommended bloatware.";
cout << "\n\n9. Exit.";
cout << "\n\nEnter your choice: ";
cin >> choice;
switch (choice)
{
case 1:
listPkg(1);
break;
case 2:
listPkg(2);
break;
case 3:
listPkg(3);
break;
case 4:
searchPkg();
break;
case 5:
cout << "\nProcees with caution, removing core packages could break the system.";
cout << "\nTry the 3rd option to check safe-to-remove packages for your device.";
disablePkg();
break;
case 6:
cout << "\nProcees with caution, removing core packages could break the system.";
cout << "\nTry the 3rd option to check safe-to-remove packages for your device.";
uninstallPkg();
break;
case 7:
disableBloat();
break;
case 8:
uninstallBloat();
break;
case 9:
return 0;
default:
cout << "\nInvalid input, exiting...\n";
return 0;
}
}
return 0;
}
void listPkg(int x)
{
string pkg;
ifstream pkgFile;
if (x == 1)
pkgFile.open("allPackages.txt");
else if (x==2)
pkgFile.open("3rdPartyPackages.txt");
else if (x==3)
pkgFile.open(getVendor());
system("cls");
while (pkgFile)
{
getline(pkgFile, pkg);
cout << pkg << '\n';
}
pkgFile.close();
}
string getPkg(int x)
{
string pkg;
if (x == 3)
cout << "\n\nEnter string to search: ";
else
cout << "\n\nEnter package name: ";
getchar(); // clear out stdin
getline(cin, pkg);
return pkg;
}
void searchPkg()
{
string cmd = "adb shell \"pm list packages | grep ";
cmd += getPkg(3) + "\"";
system(cmd.c_str());
}
void disablePkg()
{
string cmd = "adb shell pm disable-user --user 0 ";
cmd += getPkg(4);
system(cmd.c_str());
}
void uninstallPkg()
{
string cmd = "adb shell pm uninstall -k --user 0 ";
cmd += getPkg(5);
system(cmd.c_str());
}
string getVendor()
{
int vendorNum;
string vendor;
cout << "\n\n1. Samsung";
cout << "\n\n2. Oppo";
cout << "\n\n3. Oneplus";
cout << "\n\n4. Realme";
cout << "\n\n5. Xiaomi";
cout << "\n\n6. Redmi";
cout << "\n\n7. Poco";
cout << "\n\n8. Vivo";
cout << "\n\n9. Iqoo";
cout << "\n\nEnter your android device vendor (int): ";
cin >> vendorNum;
switch (vendorNum)
{
case 1:
vendor = "samsung.txt";
break;
case 2:
case 3:
case 4:
vendor = "oppo.txt";
break;
case 5:
case 6:
case 7:
vendor = "xiaomi.txt";
break;
case 8:
case 9:
cout << "-> Removes touchpal keyboard if installed, make sure you have an alternate keyboad installed.\n";
vendor = "vivo.txt";
break;
}
return vendor;
}
void disableBloat()
{
string pkg, cmd;
ifstream vendorFile;
vendorFile.open(getVendor());
while (vendorFile)
{
getline(vendorFile, pkg);
cmd = "adb shell pm disable-user --user 0 " + pkg;
system(cmd.c_str());
}
vendorFile.close();
}
void uninstallBloat()
{
string pkg, cmd;
ifstream vendorFile;
vendorFile.open(getVendor());
while (vendorFile)
{
getline(vendorFile, pkg);
cmd = "adb shell pm uninstall -k --user 0 " + pkg;
system(cmd.c_str());
}
vendorFile.close();
}